File: uml-utilities.init

package info (click to toggle)
uml-utilities 20070815.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 728 kB
  • sloc: ansic: 3,391; perl: 1,277; makefile: 239; exp: 129; sh: 122
file content (96 lines) | stat: -rw-r--r-- 2,354 bytes parent folder | download | duplicates (4)
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
#! /bin/sh -e
#
### BEGIN INIT INFO
# Short-Description: start and stop UML networking services
# Description: uml-utilities provide some simple UML networking configuration services
# X-implementor: Matt Zimmerman <mdz@debian.org>
# Default-Start:  2 3 4 5
# Default-Stop: 0 1 6
# Provides: uml-utilities
# Required-Start: $remote_fs
# Required-Stop:  $remote_fs
### END INIT INFO

# Start LSB function logging
. /lib/lsb/init-functions
DISTRO=$(lsb_release -is 2>/dev/null || echo Debian)


PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/uml_switch
NAME=uml_switch
DESC="User-mode networking switch"
UML_DIR=/var/run/uml-utilities
PIDFILE=$UML_DIR/$NAME.pid

test -x $DAEMON || exit 0

UML_SWITCH_OPTIONS=""
UML_SWITCH_USER="uml-net"
UML_SWITCH_CTL="$UML_DIR/uml_switch.ctl"

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

OPTIONS="$UML_SWITCH_OPTIONS -unix $UML_SWITCH_CTL"

case "$1" in
  start)
	if [ "x$UML_SWITCH_START" = "xfalse" ] ; then
		[ "$VERBOSE" = "yes" ] && log_warning_msg "$DESC disabled"
		exit 0
	fi
	# create $UML_DIR if it doesn't exist (RAMRUN=yes in /etc/default/rcS)
	if [ ! -d "$UML_DIR" ] ; then
		mkdir -p $UML_DIR
		chown uml-net:uml-net $UML_DIR
	fi
        log_daemon_msg "Starting $DESC" "$NAME"
	if ! start-stop-daemon --start --quiet --pidfile $PIDFILE \
			--make-pidfile --background --chuid $UML_SWITCH_USER \
			--exec $DAEMON -- $OPTIONS; then
		log_end_msg 1
		exit 1
	fi

        WAIT=5
        while ! test -e $UML_SWITCH_CTL; do
            sleep 1
            WAIT=$(($WAIT - 1))
            if [ $WAIT -le 0 ]; then
		log_warning_msg "$DAEMON never created control socket $UML_SWITCH_CTL"
		log_end_msg 1
                exit 1
            fi
        done

        chmod 777 $UML_SWITCH_CTL
	log_end_msg 0
	;;
  stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
        if start-stop-daemon --stop --quiet --pidfile $PIDFILE \
			--oknodo --exec $DAEMON; then 
		rm -f $PIDFILE $UML_SWITCH_CTL $UML_SWITCH_DATA
		log_end_msg 0
	else
		log_end_msg 1
	fi
	;;
  restart|force-reload)
        $0 stop
        $0 start
	;;
  status)
	status_of_proc "$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|status}" >&2
	exit 1
	;;
esac

exit 0