Skip to content

Commit 0bec4d2

Browse files
committed
Model SUSE script after RH init.d script.
1 parent 5e51189 commit 0bec4d2

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

config/init.d/suse/shiny-server

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
# Description: shiny-server deploys R shiny applications
1111
### END INIT INFO
1212

13+
prog=shiny-server
14+
logfile="/var/log/${prog}.log"
15+
lockfile="/var/run/${prog}.pid"
16+
17+
execute=$(which $prog)
18+
19+
# Exit if the package is not installed
20+
if [ ! -x "$execute" ] ; then
21+
echo -n $"$prog wasn't found or isn't executable."
22+
exit 1
23+
fi
1324

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

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

2844
# Remember status and be verbose
2945
rc_status -v
3046
;;
3147
stop)
32-
echo -n "Shutting down shiny-server "
33-
34-
## Stop daemon with killproc(8) and if this fails
35-
## killproc sets the return value according to LSB.
36-
/sbin/killproc shiny-server
37-
48+
echo -n $"Stopping shiny-server: "
49+
if [ ! -e $lockfile ] || [ ! -e /proc/`cat /var/run/shiny-server.pid` ]; then
50+
echo -n "cannot stop shiny-server: not running."
51+
rc_failed 1
52+
else
53+
kill `cat "$lockfile"`
54+
retval=$?
55+
[ $retval -eq 0 ] && echo -n || rc_failed 1
56+
fi
57+
3858
# Remember status and be verbose
3959
rc_status -v
4060
;;
4161
restart)
4262
## Stop the service and regardless of whether it was
4363
## running or not, start it again.
4464
$0 stop
65+
sleep 1
4566
$0 start
4667

4768
# Remember status and be quiet
4869
rc_status
4970
;;
5071
reload)
51-
echo -n "Reload shiny-server"
52-
/sbin/killproc -HUP shiny-server
72+
echo -n $"Reloading shiny-server: "
73+
if [ ! -e $lockfile ] || [ ! -e /proc/`cat /var/run/shiny-server.pid` ]; then
74+
echo -n $"cannot reload shiny-server: not running.";
75+
rc_failed 1
76+
else
77+
kill -1 `cat "$lockfile"`
78+
retval=$?
79+
[ $retval -eq 0 ] && echo -n || rc_failed 1
80+
fi
81+
5382
rc_status -v
5483
;;
5584
status)
56-
echo -n "Checking for service rstudio-server"
85+
echo -n "Checking for service shiny-server"
5786

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

6291
# Remember status and be verbose
6392
rc_status -v

0 commit comments

Comments
 (0)