Skip to content

Commit

Permalink
init script: bring more in line with rhel init script standards
Browse files Browse the repository at this point in the history
- Source /etc/sysconfig/graphios, if it exists
- Support an $OPTIONS variable to pass additional options to the program
- Use nohup+su to start and fork graphios.py instead of relying on sudo which requires a tty in its default configuration - should
 fix Issue shawn-sterling#99
- Start the program via /usr/bin/graphios.py, not /usr/bin/graphios. Fixes Issue
 shawn-sterling#100
- Other cleanup, including text formatting, spaces, etc
  • Loading branch information
acobaugh authored and JustinLaSotten committed Jun 26, 2020
1 parent f5f0a1d commit fac5f84
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions init/rhel/graphios
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

prog="/usr/bin/graphios"
# or use the command line options:
#prog="/usr/bin/graphios --log-file=/dir/mylog.log --spool-directory=/dir/my/sool"
prog="/usr/bin/graphios.py"
OPTIONS=""
GRAPHIOS_USER="nagios"
RETVAL=0
lockfile=/var/lock/subsys/graphios

if [ -f /etc/sysconfig/graphios ]; then
. /etc/sysconfig/graphios
fi

start () {
echo -n "Starting $prog"
/usr/bin/sudo -u ${GRAPHIOS_USER} ${prog} &
echo -n $"Starting $prog: "
nohup su ${GRAPHIOS_USER} -s /bin/sh -c "${prog} ${OPTIONS}" >/dev/null 2>&1 &
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
[ $RETVAL -eq 0 ] && touch ${lockfile} && success || failure
echo
}

stop () {
echo -n "Stopping $prog"
killproc graphios
echo -n $"Stopping $prog: "
killproc graphios.py
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
[ $RETVAL -eq 0 ] && rm -f ${lockfile}
echo
}

Expand Down

0 comments on commit fac5f84

Please sign in to comment.