Skip to content

Instantly share code, notes, and snippets.

@kyleparisi
Last active October 5, 2017 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleparisi/5b80ee4436c428e91ad93c160e958c71 to your computer and use it in GitHub Desktop.
Save kyleparisi/5b80ee4436c428e91ad93c160e958c71 to your computer and use it in GitHub Desktop.
hubot init script
#!/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 service
# Description: starts the Hubot bot with slack adapter
### END INIT INFO
PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME="hubot"
HUBOT_HOME="/home/hubot/diggy"
LOGFILE="/var/log/hubot.log"
PIDFILE="/var/run/hubot.pid"
DAEMON="bin/hubot"
ARGUMENTS="-a slack"
set -e
case "$1" in
start)
echo -n "Starting $NAME: "
export $(grep -v '^#' /etc/environment | xargs)
start-stop-daemon --start --quiet --chdir $HUBOT_HOME --pidfile /var/run/hubot.pid -c hubot:hubot --make-pidfile --background --exec $DAEMON -- $ARGUMENTS
echo "."
;;
stop)
echo -n "Stopping $NAME: "
start-stop-daemon --stop --quiet --pidfile $PIDFILE
echo "."
;;
restart)
echo -n "Restarting $NAME: "
export $(grep -v '^#' /etc/environment | xargs)
start-stop-daemon --stop --quiet --pidfile $PIDFILE
start-stop-daemon --start --quiet --chdir $HUBOT_HOME --pidfile /var/run/hubot.pid -c hubot:hubot --make-pidfile --background --exec $DAEMON -- $ARGUMENTS
echo "."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart}" >&2
exit 1
;;
esac
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment