Skip to content

Instantly share code, notes, and snippets.

@maethor
Last active December 24, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maethor/6806914 to your computer and use it in GitHub Desktop.
Save maethor/6806914 to your computer and use it in GitHub Desktop.
hubot init script for Debian
#!/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