Skip to content

Commit

Permalink
fix(scripts): fix rhel and alpine init scripts (#919)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ZNeumann and lavarou authored Jun 18, 2024
1 parent 8c16b70 commit 756c1aa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
3 changes: 1 addition & 2 deletions agent/scripts/init.alpine
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/sbin/openrc-run
#
# Copyright 2020 New Relic Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#

#!/sbin/openrc-run

description="New Relic Daemon"
command="${nrdaemon:-/usr/bin/newrelic-daemon}"
command_args=
Expand Down
47 changes: 38 additions & 9 deletions agent/scripts/init.rhel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
# processname: newrelic-daemon
# config: /etc/newrelic/newrelic.cfg
#
### BEGIN INIT INFO
# Provides: newrelic-daemon
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: The New Relic Daemon is used by the New Relic PHP Agent to communicate
# with the New Relic Backend
### END INIT INFO

LANG=C
NAME=newrelic-daemon
Expand All @@ -18,7 +27,11 @@ DESC="New Relic Daemon"
#
# Source function library.
#
. /etc/init.d/functions
has_initd_functions=0
if [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
has_initd_functions=1
fi

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

Expand Down Expand Up @@ -223,14 +236,22 @@ EOF

if running ; then
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
success
echo
if [ $has_initd_functions -eq 1 ]; then
success
echo
else
echo " [ OK ]"
fi
fi
return 0
else
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
failure
echo
if [ $has_initd_functions -eq 1 ]; then
failure
echo
else
echo " [FAILED]"
fi
fi
return 1
fi
Expand Down Expand Up @@ -274,14 +295,22 @@ stop() {

if running ; then
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
failure
echo
if [ $has_initd_functions -eq 1 ]; then
failure
echo
else
echo " [FAILED]"
fi
fi
return 1
else
if [ -z "${NR_SILENT}" -a -z "${SILENT}" ]; then
success
echo
if [ $has_initd_functions -eq 1 ]; then
success
echo
else
echo " [ OK ]"
fi
fi
return 0
fi
Expand Down

0 comments on commit 756c1aa

Please sign in to comment.