| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | ### BEGIN INIT INFO |
| 4 | # Provides: shiny-server |
| 5 | # Required-Start: $local_fs $remote_fs $syslog $network $named |
| 6 | # Required-Stop: $local_fs $remote_fs $syslog $network $named |
| 7 | # Default-Start: 3 5 |
| 8 | # Default-Stop: 0 1 2 6 |
| 9 | # Short-Description: shiny-server deploys R shiny applications |
| 10 | # Description: shiny-server deploys R shiny applications |
| 11 | ### END INIT INFO |
| 12 | |
| 13 | prog=shiny-server |
| 14 | logfile="/var/log/${prog}.log" |
| 15 | lockfile="/var/run/${prog}.pid" |
| 16 | |
| 17 | execute=$(whichscip-shell system . . which. $prog) |
| 18 | |
| 19 | # Exit if the package is not installed |
| 20 | if [scip-shell system . . `[`. ! -x "$execute" ] ; then |
| 21 | echoscip-shell system . . echo. -n $"$prog wasn't found or isn't executable." |
| 22 | exit 1 |
| 23 | fi |
| 24 | |
| 25 | # Source LSB init functions |
| 26 | . /etc/rc.statusscip-shell source . . `/etc/rc.status`. |
| 27 | |
| 28 | # Reset status of this service |
| 29 | rc_reset |
| 30 | |
| 31 | case "$1" in |
| 32 | start) |
| 33 | echoscip-shell system . . echo. -n "Starting shiny-server " |
| 34 | |
| 35 | if [scip-shell system . . `[`. -e $lockfile ] && [scip-shell system . . `[`. -e /proc/`catscip-shell system . . cat. /var/run/shiny-server.pidscip-shell filesystem . . `/var/run/shiny-server.pid`.` ]; then |
| 36 | echoscip-shell system . . echo. -n "cannot start shiny-server: already running." |
| 37 | rc_failed 3 |
| 38 | else |
| 39 | $execute --daemon "--pidfile=$lockfile" >> $logfile 2>&1 & |
| 40 | retval=$? |
| 41 | [scip-shell system . . `[`. $retval -eq 0 ] && echoscip-shell system . . echo. -n || rc_failed 1 |
| 42 | fi |
| 43 | |
| 44 | # Remember status and be verbose |
| 45 | rc_status -v |
| 46 | ;; |
| 47 | stop) |
| 48 | echoscip-shell system . . echo. -n $"Stopping shiny-server: " |
| 49 | if [scip-shell system . . `[`. ! -e $lockfile ] || [scip-shell system . . `[`. ! -e /proc/`catscip-shell system . . cat. /var/run/shiny-server.pidscip-shell filesystem . . `/var/run/shiny-server.pid`.` ]; then |
| 50 | echoscip-shell system . . echo. -n "cannot stop shiny-server: not running." |
| 51 | rc_failed 1 |
| 52 | else |
| 53 | killscip-shell system . . kill. `catscip-shell system . . cat. "$lockfile"` |
| 54 | retval=$? |
| 55 | [scip-shell system . . `[`. $retval -eq 0 ] && echoscip-shell system . . echo. -n || rc_failed 1 |
| 56 | fi |
| 57 | |
| 58 | # Remember status and be verbose |
| 59 | rc_status -v |
| 60 | ;; |
| 61 | restart) |
| 62 | ## Stop the service and regardless of whether it was |
| 63 | ## running or not, start it again. |
| 64 | $0 stop |
| 65 | sleepscip-shell system . . sleep. 1 |
| 66 | $0 start |
| 67 | |
| 68 | # Remember status and be quiet |
| 69 | rc_status |
| 70 | ;; |
| 71 | reload) |
| 72 | echoscip-shell system . . echo. -n $"Reloading shiny-server: " |
| 73 | if [scip-shell system . . `[`. ! -e $lockfile ] || [scip-shell system . . `[`. ! -e /proc/`catscip-shell system . . cat. /var/run/shiny-server.pidscip-shell filesystem . . `/var/run/shiny-server.pid`.` ]; then |
| 74 | echoscip-shell system . . echo. -n $"cannot reload shiny-server: not running."; |
| 75 | rc_failed 1 |
| 76 | else |
| 77 | killscip-shell system . . kill. -1 `catscip-shell system . . cat. "$lockfile"` |
| 78 | retval=$? |
| 79 | [scip-shell system . . `[`. $retval -eq 0 ] && echoscip-shell system . . echo. -n || rc_failed 1 |
| 80 | fi |
| 81 | |
| 82 | rc_status -v |
| 83 | ;; |
| 84 | status) |
| 85 | echoscip-shell system . . echo. -n "Checking for service shiny-server" |
| 86 | |
| 87 | if [scip-shell system . . `[`. ! -e $lockfile ] || [scip-shell system . . `[`. ! -e /proc/`catscip-shell system . . cat. /var/run/shiny-server.pidscip-shell filesystem . . `/var/run/shiny-server.pid`.` ]; then |
| 88 | rc_failed 2 |
| 89 | fi |
| 90 | |
| 91 | # Remember status and be verbose |
| 92 | rc_status -v |
| 93 | ;; |
| 94 | esac |
| 95 | rc_exit |
| 96 | |
| 97 | |
| 98 |