This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ DAEMON=/usr/local/bin/newrelic_plugin_agent
1818DAEMON_OPTS=" -c $CONFIG "
1919DESC=" New Relic Plugin Agent"
2020TIMEOUT=5
21+ PIDDIR_MODE=755
22+ PIDDIR_OWNER=
23+ PIDDIR_OWNER_FALLBACK=" root"
2124
2225# Include newrelic plugin agent defaults if available
2326if [ -f /etc/default/$NAME ] ; then
@@ -45,23 +48,31 @@ check_config() {
4548
4649check_pid () {
4750 PIDDIR=$( dirname $PIDFILE )
51+ if [ ! id -u $PIDDIR_OWNER > /dev/null 2>&1 ]; then
52+ PIDDIR_OWNER=$PIDDIR_OWNER_FALLBACK
53+ fi
4854 if [ ! -d $PIDDIR ]; then
49- install -m 777 -o newrelic -g newrelic -d $PIDDIR
55+ install -m $PIDDIR_MODE -o $PIDDIR_OWNER -g $PIDDIR_OWNER -d $PIDDIR
5056 log_action_msg " PID directory was not found and created" || true
5157 fi ;
5258}
5359
54- PIDFILE=$( sed -n -e ' s/^[ ]*pidfile[ ]*:[ ]*//p' -e ' s/[ ]*$//' $CONFIG )
60+ if [ -e $CONFIG ]; then
61+ PIDFILE=$( sed -n -e ' s/^[ ]*pidfile[ ]*:[ ]*//p' -e ' s/[ ]*$//' $CONFIG )
62+ if [ -z " ${PIDDIR_OWNER} " ]; then
63+ PIDDIR_OWNER=$( sed -n -e ' s/^[ ]*user[ ]*:[ ]*//p' -e ' s/[ ]*$//' $CONFIG )
64+ fi
65+ fi
5566
5667export PATH=" ${PATH: +$PATH : } /usr/sbin:/sbin/:usr/local/sbin:/usr/local/bin"
5768
5869case " $1 " in
5970 start)
60- log_daemon_msg " Starting $DESC " " $NAME " || true
6171 check_daemon
6272 check_config
6373 check_pid
6474
75+ log_daemon_msg " Starting $DESC " " $NAME " || true
6576 if [ -s $PIDFILE ] && kill -0 $( cat $PIDFILE ) > /dev/null 2>&1 ; then
6677 log_action_msg " apparently already running" || true
6778 log_end_msg 0 || true
You can’t perform that action at this time.
0 commit comments