Skip to content

Commit 756c1aa

Browse files
ZNeumannlavarou
andauthored
fix(scripts): fix rhel and alpine init scripts (#919)
Systemd systems may not have access to the functions file provided by initscripts. The code from initscripts is provided under the GNU v2 license and will not be pulled in. Additionally, a header comment block must be added, using https://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/initscrcomconv.html for specs --------- Co-authored-by: Michal Nowacki <[email protected]>
1 parent 8c16b70 commit 756c1aa

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

agent/scripts/init.alpine

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
#!/sbin/openrc-run
12
#
23
# Copyright 2020 New Relic Corporation. All rights reserved.
34
# SPDX-License-Identifier: Apache-2.0
45
#
56

6-
#!/sbin/openrc-run
7-
87
description="New Relic Daemon"
98
command="${nrdaemon:-/usr/bin/newrelic-daemon}"
109
command_args=

agent/scripts/init.rhel

Lines changed: 38 additions & 9 deletions
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,22 @@ 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+
else
243+
echo " [ OK ]"
244+
fi
228245
fi
229246
return 0
230247
else
231248
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
232-
failure
233-
echo
249+
if [ $has_initd_functions -eq 1 ]; then
250+
failure
251+
echo
252+
else
253+
echo " [FAILED]"
254+
fi
234255
fi
235256
return 1
236257
fi
@@ -274,14 +295,22 @@ stop() {
274295

275296
if running ; then
276297
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
277-
failure
278-
echo
298+
if [ $has_initd_functions -eq 1 ]; then
299+
failure
300+
echo
301+
else
302+
echo " [FAILED]"
303+
fi
279304
fi
280305
return 1
281306
else
282307
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
283-
success
284-
echo
308+
if [ $has_initd_functions -eq 1 ]; then
309+
success
310+
echo
311+
else
312+
echo " [ OK ]"
313+
fi
285314
fi
286315
return 0
287316
fi

0 commit comments

Comments
 (0)