summaryrefslogtreecommitdiff
path: root/initrc/znc
blob: 7f7bcb08f20faf1e3cceb192ff1be56b2641bd1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -e

USER="horus"
DATADIR="/home/${USER}/.znc"
NAME=znc
DESC="ZNC, the IRC Bouncer"

DAEMON="/usr/bin/znc"
DAEMON_OPTS="--foreground --datadir=$DATADIR"

PIDFILE="/var/run/${NAME}.pid"

START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --chuid $USER"
END_OPTS="--stop --pidfile ${PIDFILE}"

case "$1" in
        start)
                echo "Starting ${DESC}"
                start-stop-daemon $START_OPTS --exec ${DAEMON} -- $DAEMON_OPTS
                ;;  
        stop)
                echo "Stopping ${DESC}"
                start-stop-daemon $END_OPTS
                rm -f "${PIDFILE}"
                ;;  
        restart)
                "$0" stop
                rm -f "${PIDFILE}"
                sleep 1
                "$0" start
                ;;  
        *)  
                echo "Usage: $0 {start|stop|restart}"
                exit 1
                ;;  
esac