Commit f49c6c70 authored by Birger Schacht's avatar Birger Schacht

Add init script

To run errbot using an init script, we also need a user (so it does
not run as root), so we have to add a postinst and a postrm file to
do cleanup. In addition we have to create a default config file.
parent b4700614
Pipeline #43519 passed with stages
in 6 minutes and 40 seconds
......@@ -32,6 +32,7 @@ Package: errbot
Architecture: any
Multi-Arch: foreign
Depends:
adduser,
python3,
python3-ansi,
python3-bottle,
......@@ -51,6 +52,7 @@ Depends:
python3-yapsy,
${misc:Depends},
${python3:Depends}
Pre-Depends: ${misc:Pre-Depends}
Description: Chatbot designed to be simple to extend with plugins written in Python
Errbot is a chatbot. It allows you to start scripts interactively from your
chatrooms for any reason: random humour, chatops, starting a build, monitoring
......
#CONFIGFILE=/etc/errbot/config-template.py
etc/errbot
var/lib/errbot
var/lib/errbot/data
var/lib/errbot/plugins
errbot/config-template.py etc/errbot/
#!/bin/sh
set -e
case "$1" in
configure)
if ! id errbot >/dev/null 2>&1; then
adduser --system --group --gecos "Errbot Chat Bot" \
--no-create-home --home /var/lib/errbot errbot > /dev/null
fi
chmod 0750 /var/lib/errbot
chown errbot /var/lib/errbot
chown errbot /var/lib/errbot/data
chown errbot /var/lib/errbot/plugins
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;
*)
echo "postinst called with unknown argument $1"
exit 1
;;
esac
#DEBHELPER#
#!/bin/sh
set -e
case "$1" in
purge)
rm -rf /var/lib/errbot
;;
upgrade|remove|failed-upgrade|abort-install|abort-upgrade|disappear)
;;
*)
echo "postrm called with unknown argument $1"
exit 1
;;
esac
#DEBHELPER#
#!/bin/sh
### BEGIN INIT INFO
# Provides: errbot
# Required-Start: $local_fs $network $remote_fs $syslog
# Required-Stop: $local_fs $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Chatbot designed to be simple to extend with plugins written in Python
# Description: Errbot is a chatbot. It allows you to start scripts interactively from your
# chatrooms for any reason: random humour, chatops, starting a build, monitoring
# commits, triggering alerts...
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=errbot
DAEMON=/usr/bin/errbot
DESC="Errbot chat bot"
PIDFILE=/var/lib/$NAME/data/err.pid
SCRIPTNAME=/etc/init.d/$NAME
CONFIGFILE=/etc/$NAME/config-template.py
if test -f /etc/default/$NAME; then
. /etc/default/$NAME
fi
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
. /lib/init/vars.sh
. /lib/lsb/init-functions
errbot_start()
{
if [ -f "$PIDFILE" ]; then
log_failure_msg "$DESC is running already."
exit 1
fi
if ! id $USER >/dev/null 2>&1; then
log_failure_msg "USER $USER does not exist."
exit 1
fi
start-stop-daemon --start --exec $DAEMON --chuid $NAME -- -c $CONFIGFILE -d -p $PIDFILE
}
errbot_stop()
{
if [ -f "$PIDFILE" ]; then
start-stop-daemon --stop --signal INT --user $NAME --pidfile $PIDFILE
rm -f $PIDFILE
fi
}
errbot_status() {
if [ ! -e $PIDFILE ]; then
status_of_proc "${DAEMON}" "${DESC}"
else
status_of_proc -p "${PIDFILE}" "${DAEMON}" "${DESC}"
fi
}
case "$1" in
start)
log_begin_msg "Starting ${DESC}"
errbot_start
log_end_msg $?
;;
stop)
log_begin_msg "Stopping ${DESC}"
errbot_stop
log_end_msg $?
;;
status)
erbot_status
;;
restart|reload|force-reload)
log_begin_msg "Restarting ${DESC}"
errbot_stop
errbot_start
log_end_msg $?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}"
exit 1
;;
esac
......@@ -22,3 +22,6 @@ override_dh_auto_test:
override_dh_installsystemd:
dh_installsystemd errbot@.service
override_dh_installinit:
dh_installinit --no-start
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment