File: init.d

package info (click to toggle)
dnsproxy 1.16-0.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, sid, squeeze, stretch, wheezy
  • size: 324 kB
  • ctags: 67
  • sloc: ansic: 603; sh: 281; makefile: 103
file content (155 lines) | stat: -rw-r--r-- 2,705 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#! /bin/sh
#
# dnsproxy initscript
# Author: Patrick Schoenfeld <schoenfeld@in-medias-res.com>
# Heavily based on /etc/init.d/skeleton
#
### BEGIN INIT INFO
# Provides:          dnsproxy
# Required-Start:    $remote_fs $syslog $named
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts dnsproxy
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/dnsproxy
NAME=dnsproxy
DESC=dnsproxy

# Exit if the package is not installed
[ -x $DAEMON ] || exit 0

# Defaults for values from the defaults file
RUN_DNSPROXY="false"
ARGS="-d -c /etc/dnsproxy.conf"

# Read the defaults file if available
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

start()
{
	start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \
		|| return 1
	start-stop-daemon --start --quiet --exec $DAEMON -- \
		$ARGS \
		|| return 2
}

status()
{
	start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null
	if [ "$?" = '0' ]; then
		if [ "$RUN_DNSPROXY" = 'false' ]; then
			return 2	# Daemon is disabled
		else
			return 1	# Daemon is not running
		fi
	else
		return 0		# Daemon is running
	fi
}

stop()
{
	status
	case "$?" in
		1|2)
			return 1
			;;
		*)
			start-stop-daemon --stop --quiet --retry=0/30/KILL/5 --exec $DAEMON

			if [ "$?" = 2 ]; then
				return 2
			fi

    		return "$?"
			;;
	esac
}

case "$1" in
	start)
	    log_daemon_msg "Starting $DESC" "$NAME"
	    start
	    case "$?" in
	    	0)
				log_end_msg 0
				;;
			1)
				echo " is already running."
				;;
	        2)
				log_end_msg 1
				;;
	    esac
    	;;
	stop)
		log_daemon_msg "Stopping $DESC" "$NAME"
	    stop
		case "$?" in
        	0)
				log_end_msg 0
				;;
			1)
				echo " is not running."
				;;
			2)
				log_end_msg 1
				;;
		esac
		;;
	restart|force-reload)
		log_daemon_msg "Restarting $DESC" "$NAME"
		stop

		case "$?" in
			0|1)
				start
				case "$?" in
					0)
						log_end_msg 0
						;;
					1)
						log_end_msg 1
						;;
					*)
						log_end_msg 1
						;;
				esac
				;;
			*)
				log_end_msg 1
			;;
		esac
		;;
	status)
		log_daemon_msg "Status of $DESC"
		echo -n " "
		status
		case "$?" in
			0)
				log_success_msg "$NAME is running."
				;;
			1)
				log_success_msg "$NAME is not running."
				;;
			2)
				log_success_msg "$NAME is disabled (see /etc/default/$NAME)."
				;;
		esac
	;;
	*)
		echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2
		exit 3
		;;
esac