Skip to content

Commit

Permalink
supybot: added
Browse files Browse the repository at this point in the history
  • Loading branch information
jgeboski committed Sep 23, 2012
1 parent d035693 commit e5c5e65
Show file tree
Hide file tree
Showing 8 changed files with 1,390 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README
Expand Up @@ -49,7 +49,7 @@ Network:
- mangler*
- mumble*
- murmur*
- znc**
- supybot

Office:
- libreoffice
Expand Down
5 changes: 5 additions & 0 deletions network/supybot/README
@@ -0,0 +1,5 @@
Supybot is an easy to configure and highly flexible IRC bot written
in the python scripting language.

To use a different supybot user:
# SUPYBOT_USER=user ./supybot.SlackBuild
26 changes: 26 additions & 0 deletions network/supybot/doinst.sh
@@ -0,0 +1,26 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
# toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}

preserve_perms() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ -e $OLD ]; then
cp -a $OLD ${NEW}.incoming
cat $NEW > ${NEW}.incoming
mv ${NEW}.incoming $NEW
fi
config $NEW
}

config etc/supybot/supybot.conf.new
preserve_perms etc/rc.d/rc.supybot.new
46 changes: 46 additions & 0 deletions network/supybot/files/rc.supybot
@@ -0,0 +1,46 @@
#!/bin/sh

SUPYBOT_USER=${SUPYBOT_USER:-@SUPYBOT_USER@}
SUPYBOT_CONFIG=${SUPYBOT_CONFIG:-/etc/supybot/supybot.conf}

supybot_start()
{
pid=$(pgrep -U $SUPYBOT_USER supybot)

if [ -n "$pid" ]; then
echo "Supybot is already running"
exit 1
fi

su - $SUPYBOT_USER -c "/usr/bin/supybot $SUPYBOT_CONFIG -d"
}

supybot_stop()
{
pid=$(pgrep -U $SUPYBOT_USER supybot)

if [ -z "$pid" ]; then
echo "Supybot is not running"
exit 1
fi

kill $pid
}

supybot_restart()
{
supybot_stop
sleep 1
supybot_start
}

case "$1" in
start)
supybot_start ;;
stop)
supybot_stop ;;
restart)
supybot_restart ;;
*)
echo "usage: $0 start|stop|restart"
esac

0 comments on commit e5c5e65

Please sign in to comment.