Skip to content

Commit 2e19eb3

Browse files
committed
fix(scripts): allow rhel init script to be run by systemd
1 parent 8c16b70 commit 2e19eb3

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

agent/scripts/init.rhel

+30-9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
# processname: newrelic-daemon
1111
# config: /etc/newrelic/newrelic.cfg
1212
#
13+
### BEGIN INIT INFO
14+
# Provides: newrelic-daemon
15+
# Required-Start: $all
16+
# Required-Stop:
17+
# Default-Start: 2 3 4 5
18+
# Default-Stop: 0 1 6
19+
# Description: The New Relic Daemon is used by the New Relic PHP Agent to communicate
20+
# with the New Relic Backend
21+
### END INIT INFO
1322

1423
LANG=C
1524
NAME=newrelic-daemon
@@ -18,7 +27,11 @@ DESC="New Relic Daemon"
1827
#
1928
# Source function library.
2029
#
21-
. /etc/init.d/functions
30+
has_initd_functions=0
31+
if [ -f /etc/init.d/functions ]; then
32+
. /etc/init.d/functions
33+
has_initd_functions=1
34+
fi
2235

2336
ulimit -n 2048 > /dev/null 2>&1
2437

@@ -223,14 +236,18 @@ EOF
223236

224237
if running ; then
225238
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
226-
success
227-
echo
239+
if [ $has_initd_functions -eq 1 ]; then
240+
success
241+
echo
242+
fi
228243
fi
229244
return 0
230245
else
231246
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
232-
failure
233-
echo
247+
if [ $has_initd_functions -eq 1 ]; then
248+
failure
249+
echo
250+
fi
234251
fi
235252
return 1
236253
fi
@@ -274,14 +291,18 @@ stop() {
274291

275292
if running ; then
276293
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
277-
failure
278-
echo
294+
if [ $has_initd_functions -eq 1 ]; then
295+
failure
296+
echo
297+
fi
279298
fi
280299
return 1
281300
else
282301
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
283-
success
284-
echo
302+
if [ $has_initd_functions -eq 1 ]; then
303+
success
304+
echo
305+
fi
285306
fi
286307
return 0
287308
fi

0 commit comments

Comments
 (0)