Created
November 4, 2012 02:25
-
-
Save kwstannard/4009852 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 | |
# Taken from febuiles on github. | |
# This assumes you have: | |
# 1) A user called `hubot` in charge of the bot. | |
# 2) A file called /home/hubot/.hubotrc that contains the Hubot credentials. | |
# | |
# To set the adapter either edit bin/hubot to specify what you want or append | |
# `-- -a campfire` to the $DAEMON variable below. | |
# | |
### 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 for the Campfire rooms | |
### END INIT INFO | |
. /etc/rc.conf | |
. /etc/rc.d/functions | |
C_DIR=$(pwd) | |
NAME="Lunchy" | |
LUNCHY_HOME="/home/kelly/lunchy" | |
LOGFILE="/var/log/lunchy.log" | |
PIDFILE="/var/run/lunchy.pid" | |
RC_FILE="$LUNCHY_HOME/.lunchyrc" | |
PATH=$LUNCHY_HOME/hubot/bin:$LUNCHY_HOME/lunchy:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin: | |
RAILS="cd $LUNCHY_HOME/lunchy && rails server -d && cd $C_DIR" | |
HUBOT="cd $LUNCHY_HOME/hubot && $LUNCHY_HOME/hubot/bin/hubot -a campfire -n Lunchy && cd $C_DIR" | |
[ -r /etc/conf.d/$NAME ] && . /etc/conf.d/$NAME | |
PID=$(get_pid $NAME) | |
case "$1" in | |
start) | |
stat_busy "Starting $NAME: " | |
. $RC_FILE | |
[ -z "$PID" ] && $RAILS && $HUBOT | |
if [ $? = 0 ]; then | |
add_daemon $NAME | |
stat_done | |
else | |
stat_fail | |
exit 1 | |
fi | |
;; | |
stop) | |
stat_busy "Stopping $NAME: " | |
[ -n "$PID" ] && kill $PID | |
if [ $? = 0 ]; then | |
rm_daemon $NAME | |
stat_done | |
else | |
stat_fail | |
exit 1 | |
fi | |
;; | |
restart) | |
stat_busy "Restarting $NAME: " | |
$0 stop | |
sleep 1 | |
$0 start | |
;; | |
*) | |
echo "Usage: $NAME {start|stop}" >&2 | |
exit 1 | |
;; | |
esac | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment