-
-
Save tomashley/3a82b0b53860e222b714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: hubot | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the hubot hubot service | |
# Description: starts the hubot bot for the Campfire rooms | |
### END INIT INFO | |
PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
NAME="hubot-marvin" | |
HUBOT_DIR="/home/hubot/marvin" | |
HUBOT_CONFIG="$HUBOT_DIR/hubotrc" # Must contain "PATH", "NODE_PATH" and HUBOT environment vars | |
PIDFILE="/var/run/hubot-marvin.pid" | |
DAEMON="bin/hubot" | |
OPTIONS="-a irc" | |
set -e | |
case "$1" in | |
start) | |
echo -n "Starting $NAME: " | |
. $HUBOT_CONFIG | |
if pgrep -F $PIDFILE > /dev/null 2>&1 ; then | |
echo "$NAME is already running." | |
else | |
start-stop-daemon --start --quiet --pidfile $PIDFILE -c hubot:hubot --make-pidfile --background --chdir $HUBOT_DIR --exec $DAEMON -- $OPTIONS | |
echo "." | |
fi | |
;; | |
stop) | |
echo -n "Stopping $NAME: " | |
start-stop-daemon --stop --quiet --pidfile $PIDFILE | |
echo "." | |
;; | |
restart) | |
echo -n "Restarting $NAME: " | |
. $HUBOT_CONFIG | |
start-stop-daemon --stop --quiet --pidfile $PIDFILE | |
sleep 1 | |
start-stop-daemon --start --quiet --pidfile $PIDFILE -c hubot:hubot --make-pidfile --background --chdir $HUBOT_DIR --exec $DAEMON -- $OPTIONS | |
echo "." | |
;; | |
*) | |
N=/etc/init.d/$NAME | |
echo "Usage: $N {start|stop}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment