File: inspircd.init

package info (click to toggle)
inspircd 2.0.27-1%2Bdeb10u1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 4,560 kB
  • sloc: cpp: 48,118; perl: 2,927; ansic: 271; sh: 143; makefile: 40; sql: 38
file content (95 lines) | stat: -rw-r--r-- 2,511 bytes parent folder | download | duplicates (2)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
### BEGIN INIT INFO
# Provides:          inspircd
# Required-Start:    $remote_fs $network $syslog $time
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $local_fs
# Should-Stop:       $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start inspircd
# Description:       Starts the inspircd irc server
### END INIT INFO
# GPL Licensed

NAME="inspircd"
IRCD="/usr/sbin/inspircd"
IRCDPID="/var/run/inspircd.pid"
IRCDLOG="/var/log/inspircd.log"
IRCDCONF="/etc/inspircd/inspircd.conf"
IRCDARGS="--logfile $IRCDLOG --config $IRCDCONF"
USER="irc"
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

if [ -f "/etc/default/inspircd" ]; then
	. /etc/default/inspircd
fi

# Define LSB log_* functions (status_of_proc)
. /lib/lsb/init-functions

if [ ! -x "$IRCD" ]; then exit 0; fi

if [ -f "$IRCDPID" ]; then
        IRCDPIDN=`cat "$IRCDPID" 2> /dev/null`
fi

start_ircd()
{
	[ -f "$IRCDPID" ] || ( touch "$IRCDPID" ; chown "$USER" "$IRCDPID" )
	[ -f "$IRCDLOG" ] || ( touch "$IRCDLOG" ; chown "$USER:adm" "$IRCDLOG" ; chmod 0640 "$IRCDLOG" )
        export LD_LIBRARY_PATH=/usr/lib/inspircd
	start-stop-daemon --start --quiet --oknodo --chuid "$USER" --pidfile "$IRCDPID" --exec "$IRCD" -- $IRCDARGS start > /dev/null
}

stop_ircd()
{
        start-stop-daemon --stop --quiet --pidfile "$IRCDPID" > /dev/null 2> /dev/null
        rm -f "$IRCDPID"
        return 0
}

reload_ircd()
{
        if [ ! -z "$IRCDPIDN" ] && kill -0 $IRCDPIDN 2> /dev/null; then
                kill -HUP $IRCDPIDN >/dev/null 2>&1 || return 1
                return 0
        else
                echo "Error: IRCD is not running."
                return 1
        fi
}

case "$1" in
  start)
	if [ "$INSPIRCD_ENABLED" != "1" ]; then
		echo -n "Please configure inspircd first and edit /etc/default/inspircd, otherwise inspircd won't start"
		exit 0
	fi
        echo -n "Starting Inspircd... "
        start_ircd && echo "done."
        ;;
  stop)
        echo -n "Stopping Inspircd... "
        stop_ircd && echo "done."
        ;;
  status)
	status_of_proc "$IRCD" "$NAME" && exit 0 || exit $?
 	;;
  force-reload|reload)
        echo -n "Reloading Inspircd... "
        reload_ircd && echo "done."
        ;;
  restart)
        $0 stop
        sleep 2
        $0 start
        ;;
  cron)
        start_ircd || echo "Inspircd not running, starting it"
        ;;

  *)
        echo "Usage: $0 {start|stop|status|restart|reload|force-reload|cron}"
        exit 1
esac