Skip to content

Commit

Permalink
Model SUSE script after RH init.d script.
Browse files Browse the repository at this point in the history
  • Loading branch information
trestletech committed Oct 29, 2014
1 parent 5e51189 commit 0bec4d2
Showing 1 changed file with 44 additions and 15 deletions.
59 changes: 44 additions & 15 deletions config/init.d/suse/shiny-server
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
# Description: shiny-server deploys R shiny applications
### END INIT INFO

prog=shiny-server
logfile="/var/log/${prog}.log"
lockfile="/var/run/${prog}.pid"

execute=$(which $prog)

# Exit if the package is not installed
if [ ! -x "$execute" ] ; then
echo -n $"$prog wasn't found or isn't executable."
exit 1
fi

# Source LSB init functions
. /etc/rc.status
Expand All @@ -21,43 +32,61 @@ case "$1" in
start)
echo -n "Starting shiny-server "

## Start daemon with startproc(8). If this fails
## the return value is set appropriately by startproc.
/sbin/startproc shiny-server
if [ -e $lockfile ] && [ -e /proc/`cat /var/run/shiny-server.pid` ]; then
echo -n "cannot start shiny-server: already running."
rc_failed 3
else
$execute --daemon "--pidfile=$lockfile" >> $logfile &
retval=$?
[ $retval -eq 0 ] && echo -n || rc_failed 1
fi

# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down shiny-server "

## Stop daemon with killproc(8) and if this fails
## killproc sets the return value according to LSB.
/sbin/killproc shiny-server

echo -n $"Stopping shiny-server: "
if [ ! -e $lockfile ] || [ ! -e /proc/`cat /var/run/shiny-server.pid` ]; then
echo -n "cannot stop shiny-server: not running."
rc_failed 1
else
kill `cat "$lockfile"`
retval=$?
[ $retval -eq 0 ] && echo -n || rc_failed 1
fi

# Remember status and be verbose
rc_status -v
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
sleep 1
$0 start

# Remember status and be quiet
rc_status
;;
reload)
echo -n "Reload shiny-server"
/sbin/killproc -HUP shiny-server
echo -n $"Reloading shiny-server: "
if [ ! -e $lockfile ] || [ ! -e /proc/`cat /var/run/shiny-server.pid` ]; then
echo -n $"cannot reload shiny-server: not running.";
rc_failed 1
else
kill -1 `cat "$lockfile"`
retval=$?
[ $retval -eq 0 ] && echo -n || rc_failed 1
fi

rc_status -v
;;
status)
echo -n "Checking for service rstudio-server"
echo -n "Checking for service shiny-server"

## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
/sbin/checkproc shiny-server
if [ ! -e $lockfile ] || [ ! -e /proc/`cat /var/run/shiny-server.pid` ]; then
rc_failed 2
fi

# Remember status and be verbose
rc_status -v
Expand Down

0 comments on commit 0bec4d2

Please sign in to comment.