Skip to content

Instantly share code, notes, and snippets.

@philchristensen
Created November 9, 2011 18:30
Show Gist options
  • Save philchristensen/1352381 to your computer and use it in GitHub Desktop.
Save philchristensen/1352381 to your computer and use it in GitHub Desktop.
hubot init script
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/fubot/bin/hubot
NAME=fubot
DESC="Jabber Bot"
CONF="-a xmpp --name $NAME"
BOT_USER=fubot
BOT_GROUP=fubot
PIDFILE=/var/run/fubot/pid.fubot
RUN_DIR=/opt/fubot
[email protected]\/fubot
PASSWORD=oyk:Cz5\/Zo\>H3M\$\{
[email protected]
ERROR_LOG=/var/log/fubot/error.log
set -e
function start_bot(){
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec /usr/bin/env \
--make-pidfile --chuid $BOT_USER --group $BOT_GROUP -- \
PATH=$PATH:/opt/node/bin PWD=$RUN_DIR HUBOT_XMPP_ROOMS=$ROOMS \
HUBOT_XMPP_USERNAME=$USERNAME HUBOT_XMPP_PASSWORD=$PASSWORD \
$DAEMON $CONF 2>&1 | ( while read line; do echo "$(date): ${line}"; done ) > $ERROR_LOG &
}
function stop_bot(){
start-stop-daemon --stop --quiet --pidfile $PIDFILE
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
start_bot
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
stop_bot
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
stop_bot
sleep 1
start_bot
echo "."
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment