PageRenderTime 274ms CodeModel.GetById 211ms app.highlight 2ms RepoModel.GetById 60ms app.codeStats 0ms

/init.d/danted

http://github.com/brinkman83/bashrc
Shell | 92 lines | 60 code | 6 blank | 26 comment | 4 complexity | 8577392e4bfeefd29a96e8ff7e7ffb43 MD5 | raw file
 1#! /bin/sh
 2### BEGIN INIT INFO
 3# Provides:          danted
 4# Required-Start:    $remote_fs $syslog
 5# Required-Stop:     $remote_fs $syslog
 6# Default-Start:     2 3 4 5
 7# Default-Stop:      0 1 6
 8# Short-Description: SOCKS (v4 and v5) proxy daemon (danted)
 9### END INIT INFO
10#
11# dante SOCKS server init.d file. Based on /etc/init.d/skeleton:
12# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels@cistron.nl
13
14PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
15DAEMON=/usr/sbin/danted
16NAME=danted
17DESC="Dante SOCKS daemon"
18PIDFILE=/var/run/$NAME.pid
19CONFFILE=/etc/$NAME.conf
20
21test -f $DAEMON || exit 0
22
23set -e
24
25# This function makes sure that the Dante server can write to the pid-file.
26touch_pidfile ()
27{
28  if [ -r $CONFFILE ]; then
29    uid="`sed -n -e 's/[[:space:]]//g' -e 's/#.*//' -e '/^user\.privileged/{s/[^:]*://p;q;}' $CONFFILE`"
30    if [ -n "$uid" ]; then
31      touch $PIDFILE
32      chown $uid $PIDFILE
33    fi
34  fi
35}
36		
37case "$1" in
38  start)
39	if ! egrep -cve '^ *(#|$)' \
40	    -e '^(logoutput|user\.((not)?privileged|libwrap)):' \
41	    $CONFFILE > /dev/null
42	then
43		echo "Not starting $DESC: not configured."
44		exit 0
45	fi
46	echo -n "Starting $DESC: "
47	touch_pidfile
48	start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE \
49		--exec $DAEMON -- -D
50	echo "$NAME."
51	;;
52  stop)
53	echo -n "Stopping $DESC: "
54	start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
55		--exec $DAEMON
56	echo "$NAME."
57	;;
58  reload|force-reload)
59	#
60	#	If the daemon can reload its config files on the fly
61	#	for example by sending it SIGHUP, do it here.
62	#
63	#	If the daemon responds to changes in its config file
64	#	directly anyway, make this a do-nothing entry.
65	#
66	 echo "Reloading $DESC configuration files."
67	 start-stop-daemon --stop --signal 1 --quiet --pidfile \
68		$PIDFILE --exec $DAEMON -- -D
69  ;;
70  restart)
71	#
72	#	If the "reload" option is implemented, move the "force-reload"
73	#	option to the "reload" entry above. If not, "force-reload" is
74	#	just the same as "restart".
75	#
76	echo -n "Restarting $DESC: "
77	start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON
78	sleep 1
79	touch_pidfile
80	start-stop-daemon --start --quiet --pidfile $PIDFILE \
81	  --exec $DAEMON -- -D
82	echo "$NAME."
83	;;
84  *)
85	N=/etc/init.d/$NAME
86	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
87	echo "Usage: $N {start|stop|restart|force-reload}" >&2
88	exit 1
89	;;
90esac
91
92exit 0