Skip to content

Instantly share code, notes, and snippets.

@hongquan
Last active December 15, 2015 06:48
Show Gist options
  • Save hongquan/5218409 to your computer and use it in GitHub Desktop.
Save hongquan/5218409 to your computer and use it in GitHub Desktop.
Upstart job scrips to launch Supybot as multiple IRC bots.

Install

  • Make sure you installed Supybot.

  • These Upstart scripts assume you configured Supybot as:

    • Running under supybot user.
    • Have /home/supbybot/running/ folder to contain data of all running instances (multiple bot).
    • This running folder is divided to many subfolders, each for a channel each bot joins. For example, you want an instance of Supybot to listen on #fossasia channel, you create /home/supbybot/running/fossasia folder. Right in this folder, you can running supybot-wizard command to setup the bot. The name of config file has to be the channel name. For example, fossasia.conf file for #fossasia channel.
  • Upstart scrips are installed in /etc/init/.

  • Document to read more: http://supybook.fealdia.org/latest/, http://supybot.fr.cr/doc/use/index.html

Use

  • Run one bot:
start supybot CHANNEL=xxx

and there must be a bot config at /home/supybot/running/xxx/xxx.conf.

  • Run all bots:
start supybotall
  • Stop all bots:
initctl emit supybot-stop-all

or

start supybotstop

Follow update at https://gist.github.com/hongquan/5218409

description "Supybot"
author "Nguyễn Hồng Quân <ng.hong.quan@gmail.com>"
# This job is launched by supybotall
stop on (runlevel [016]
or supybot-stop-all)
env WORKDIR=/home/supybot/running
instance $CHANNEL
exec start-stop-daemon --start -c supybot --exec /usr/bin/supybot $WORKDIR/$CHANNEL/$CHANNEL.conf
respawn
description "Supybot"
author "Nguyễn Hồng Quân <ng.hong.quan@gmail.com>"
start on (net-device-up
and local-filesystems
and runlevel [2345])
# This job is not long-running
env WORKDIR=/home/supybot/running
task
script
echo "Look in $WORKDIR" > /tmp/supybot.log
for d in $(ls -d $WORKDIR/*/); do
# Use basename to remove the trailing "/"
chan=$(basename $d)
echo "Start $chan" >> /tmp/supybot.log
if [ -f $d$chan.conf ]; then
start supybot CHANNEL=$chan
fi
done
end script
description "Supybot"
author "Nguyễn Hồng Quân <ng.hong.quan@gmail.com>"
start on runlevel [016]
task
script
initctl emit supybot-stop-all
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment