File: init.d

package info (click to toggle)
atheme-services 7.2.12-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,256 kB
  • sloc: ansic: 95,899; sh: 8,462; php: 5,032; perl: 3,327; makefile: 1,279; sed: 16; ruby: 15; python: 3
file content (104 lines) | stat: -rw-r--r-- 2,518 bytes parent folder | download | duplicates (5)
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
96
97
98
99
100
101
102
103
104
#! /bin/sh

### BEGIN INIT INFO
# Provides:          atheme-services
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Atheme-services daemon init.d script
# Description:       Use to manage the Atheme services daemon.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/atheme-services
NAME="atheme-services"
DESC="Atheme IRC Services"

. /lib/lsb/init-functions

test -x $DAEMON || exit 0
RUNDIR="/var/run/atheme"

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: $NAME "
	if [ ! -d "$RUNDIR" ]; then
		echo -n "run folder missing "
		rm -rf "$RUNDIR"
		echo -n "cleared "
		mkdir -p "$RUNDIR"
		chown irc:irc $RUNDIR/
		chmod 755 $RUNDIR/
		echo -n "created "
	fi
	if [ -f "$RUNDIR/atheme.pid" ] && ps `cat $RUNDIR/atheme.pid ` > /dev/null ; then
		echo "Already running!"
	else
		ps `cat $RUNDIR/atheme.pid ` > /dev/null || rm -f $RUNDIR/atheme.pid
		start-stop-daemon -u irc -c irc --start --quiet --pidfile $RUNDIR/atheme.pid \
			--exec $DAEMON
	fi
	echo "."
	;;
  stop)
	echo -n "Stopping $DESC: $NAME "
	if [ -f "$RUNDIR/atheme.pid" ]; then
		start-stop-daemon --stop --quiet --pidfile $RUNDIR/atheme.pid \
			--exec $DAEMON --signal 15
	else
		echo "not running."
	fi
	echo "."
	;;
  reload|force-reload)
    	echo -n "Reloading $DESC configuration files: $NAME "
	if [ ! -d "$RUNDIR" ]; then
		echo "run folder missing!"
	else
		if [ -f "$RUNDIR/atheme.pid" ]; then
			start-stop-daemon --stop --signal 1 --quiet --pidfile \
				$RUNDIR/atheme.pid --exec $DAEMON
		else
			echo "not running!"
		fi
		echo "."
	fi
	;;
  restart)
    	echo -n "Restarting $DESC: $NAME "
	if [ ! -d "$RUNDIR" ]; then
		echo -n "run folder missing "
		rm -rf "$RUNDIR"
		echo -n "cleared "
		mkdir -p "$RUNDIR"
		chown irc:irc $RUNDIR/
		chmod 755 $RUNDIR/
		echo -n "created "
	fi
	if [ -f "$RUNDIR/atheme.pid" ]; then
		start-stop-daemon --stop --quiet --pidfile \
			$RUNDIR/atheme.pid --exec $DAEMON --signal 15
		echo -n "."
		sleep 1
	fi
	echo -n "."
	start-stop-daemon -u irc -c irc --start --quiet --pidfile \
		$RUNDIR/atheme.pid --exec $DAEMON
	echo "."
	;;
  status)
	status_of_proc -p $RUNDIR/atheme.pid $DAEMON $NAME
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	# echo "Usage: $N {start|stop|restart|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|reload|status}" >&2
	exit 1
	;;
esac

exit 0