File: bip.init

package info (click to toggle)
bip 0.8.2-1squeeze4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 956 kB
  • ctags: 819
  • sloc: ansic: 8,752; perl: 1,424; sh: 1,311; yacc: 192; lex: 124; makefile: 33
file content (113 lines) | stat: -rw-r--r-- 2,190 bytes parent folder | download
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
105
106
107
108
109
110
111
112
113
#!/bin/sh
### BEGIN INIT INFO
# Provides:          bip
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Bip irc proxy init script
# Description:       This file should be used to start and stop bip in system
#                    mode.
### END INIT INFO

# Author: Arnaud Cornet <arnaud.cornet@gmail.com>

PATH=/sbin:/usr/sbin:/bin:/usr/bin
BIPHOME=/var/lib/bip
VRBIP=/var/run/bip
PIDFILE=$VRBIP/bip.pid
CONFIG=/etc/bip.conf
BIP=/usr/bin/bip
ENABLED=0

test -x $BIP || exit 0
test -f $CONFIG || exit 0

if [ -e /etc/default/bip ]; then
	. /etc/default/bip
fi

test "$ENABLED" != "0" || exit 0

[ -f /etc/default/rcS ] && . /etc/default/rcS
. /lib/lsb/init-functions


bip_start()
{
	if [ ! -e $VRBIP ] ; then
		# /var/run can be cleaned at reboot
		mkdir -p $VRBIP
		chown bip:bip $VRBIP
	fi
	start-stop-daemon --start --chuid bip:bip --pidfile "$PIDFILE" --exec /usr/bin/bip -- -f "$CONFIG" -s "$BIPHOME" \
		|| return 2
	return 0
}

bip_stop()
{
	start-stop-daemon --stop --user bip --pidfile "$PIDFILE" \
		|| return 2
	return 0
}

bip_reload()
{
	start-stop-daemon --stop --user bip --pidfile "$PIDFILE" --signal 1 \
		|| return 2
	return 0
}

case "$1" in
start)
	log_daemon_msg "Starting bip" "bip"
	bip_start
	case "$?" in
	0) log_end_msg 0 ;;
	1) log_end_msg 1 ; echo "pid file '$PIDFILE' found, bip not started." ;;
	2) log_end_msg 1 ;;
	esac
;;
stop)
	log_daemon_msg "Stopping bip" "bip"
	bip_stop
	case "$?" in
	0|1) log_end_msg 0 ;;
	2) log_end_msg 1 ;;
	esac
;;
reload|force-reload)
	log_daemon_msg "Reloading bip" "bip"
	bip_reload
	case "$?" in
	0|1) log_end_msg 0 ;;
	2) log_end_msg 1 ;;
	esac
;;
restart)
	log_daemon_msg "Restarting bip" "bip"
	bip_stop
	sleep 1
	bip_start
	case "$?" in
	0) log_end_msg 0 ;;
	1) log_end_msg 1 ;;
	2) log_end_msg 1 ;;
	esac
;;
status)
	# /var/run/bip/bip.pid is perm'd 600, so only use -p if readable
	if [ -r "$PIDFILE" ]; then
		status_of_proc -p "$PIDFILE" "$BIP" bip && exit 0 || exit $?
	else
		status_of_proc "$BIP" bip && exit 0 || exit $?
	fi
;;
*)
	echo "Usage: /etc/init.d/bip {start|stop|reload|restart|status}"
	exit 3
;;
esac

: