This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree 1 file changed +14
-3
lines changed
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
18
18
DAEMON_OPTS=" -c $CONFIG "
19
19
DESC=" New Relic Plugin Agent"
20
20
TIMEOUT=5
21
+ PIDDIR_MODE=755
22
+ PIDDIR_OWNER=
23
+ PIDDIR_OWNER_FALLBACK=" root"
21
24
22
25
# Include newrelic plugin agent defaults if available
23
26
if [ -f /etc/default/$NAME ] ; then
@@ -45,23 +48,31 @@ check_config() {
45
48
46
49
check_pid () {
47
50
PIDDIR=$( dirname $PIDFILE )
51
+ if [ ! id -u $PIDDIR_OWNER > /dev/null 2>&1 ]; then
52
+ PIDDIR_OWNER=$PIDDIR_OWNER_FALLBACK
53
+ fi
48
54
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
50
56
log_action_msg " PID directory was not found and created" || true
51
57
fi ;
52
58
}
53
59
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
55
66
56
67
export PATH=" ${PATH: +$PATH : } /usr/sbin:/sbin/:usr/local/sbin:/usr/local/bin"
57
68
58
69
case " $1 " in
59
70
start)
60
- log_daemon_msg " Starting $DESC " " $NAME " || true
61
71
check_daemon
62
72
check_config
63
73
check_pid
64
74
75
+ log_daemon_msg " Starting $DESC " " $NAME " || true
65
76
if [ -s $PIDFILE ] && kill -0 $( cat $PIDFILE ) > /dev/null 2>&1 ; then
66
77
log_action_msg " apparently already running" || true
67
78
log_end_msg 0 || true
You can’t perform that action at this time.
0 commit comments