Skip to content

Instantly share code, notes, and snippets.

@spruce
Forked from febuiles/hubot.sh
Last active March 23, 2021 21:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spruce/cfdc5551e7946dfb5c7b to your computer and use it in GitHub Desktop.
Save spruce/cfdc5551e7946dfb5c7b to your computer and use it in GitHub Desktop.
Scripts to start automatically start hubot on startup on debian
#!/bin/bash
export PORT=5555 # setting port for hubot scripts, only needed if port 8080 is not ok with you
export BIND_ADDRESS=127.0.0.1 # So that hubot is not public under port but can be proxied through e.g. nginx
export HUBOT_HIPCHAT_JID="YOUR_ID_HERE@chat.hipchat.com" # set HipChatid
export HUBOT_HIPCHAT_PASSWORD="YOUR_PASSWORD_HERE" # setting password for HipChat
export GITLAB_CHANNEL="CHANNEL@conf.hipchat.com" # channel to which to send the GITLAB messages
First file place under: /etc/init.d/hubot
Second file place under: /home/hubot/.hubotrc
Don't forget to execute
update-rc.d hubot defaults
#!/bin/sh
# 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 HipChat rooms
### END INIT INFO
PATH=/home/hubot/node_modules/hubot/bin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME="Hubot"
LOGFILE="/var/log/hubot.log"
PIDFILE="/var/run/hubot.pid"
HOME="/home/hubot"
DAEMON="$HOME/node_modules/hubot/bin/hubot -- --adapter hipchat"
set -e
start(){
echo -n "Starting $NAME: "
. /home/hubot/.hubotrc
echo "Trying to start Hubot" > $LOGFILE
start-stop-daemon -S -p $PIDFILE -c hubot:hubot -m -b -d $HOME -x $DAEMON >> $LOGFILE 2>&1
# ^Start pidfile chuid make-pid background changedir execute
echo "Success"
}
stop(){
echo -n "Stopping $NAME: "
start-stop-daemon -K -p $PIDFILE >> $LOGFILE 2>&1
echo "Success"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
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