File: diald.init

package info (click to toggle)
diald 0.99.4-7.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,100 kB
  • ctags: 935
  • sloc: ansic: 7,109; tcl: 977; sh: 880; perl: 306; makefile: 109
file content (139 lines) | stat: -rw-r--r-- 3,723 bytes parent folder | download | duplicates (2)
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
#! /bin/sh
#
# diald		Startup file for diald
#
#		Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#		Modified for Debian GNU/Linux
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#		Modified for diald by several parties, most recently
#		Jeff Licquia <licquia@debian.org>.
#
# This file was automatically customized by dh-make on Sat, 30 Oct 1999 13:05:49 -0500

### BEGIN INIT INFO
# Provides:          diald
# Required-Start:    $local_fs $remote_fs $syslog $network
# Required-Stop:     $local_fs $remote_fs $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: dial on demand daemon
### END INIT INFO

set -e

DIALD_CACHE=/var/cache/diald

check_provider ()
{
  if [ ! -e $DIALD_CACHE/options.$PROVIDER -o \
       $DIALD_CACHE/options.$PROVIDER -ot /etc/ppp/peers/$PROVIDER ]
  then
    cvt-pppconfig /etc/ppp/peers/$PROVIDER \
      > $DIALD_CACHE/options.$PROVIDER
    echo -n "config-regenerated "
  fi
}  

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/diald
NAME=diald
DESC=diald
FIFO=""

test -f $DAEMON || exit 0
test -f /etc/diald/diald.provider || exit 0
. /etc/diald/diald.provider
if [ "$PROVIDER" != "old-config" ]; then
  test -f /etc/ppp/peers/$PROVIDER || exit 0
  PROVIDER_FILE=$DIALD_CACHE/options.$PROVIDER
else
  test -f /etc/diald/diald.options || exit 0
  PROVIDER_FILE=/etc/diald/diald.options
fi

# Look for fifo in config file
NEW_FIFO=`egrep '^[[:space:]]*fifo[[:space:]]+[^[:space:]]+'\
	/etc/diald/diald.defaults | sed -e 's/^[[:space:]]*fifo[[:space:]]*//'`
if [ "$NEW_FIFO" != "" ]; then
    # The user location exists, and is a named pipe.
    FIFO="$NEW_FIFO";
fi

case "$1" in
  start)
	echo -n "Starting $DESC: "

        if [ "$FIFO" != "" ] ; then
          if test -p $FIFO ; then
            rm -f $FIFO
          fi
          mknod --mode=0660 $FIFO p
          chown root.dialout $FIFO
          if test -p $FIFO ; then
            echo -n "fifo-created "
          fi
        fi

	check_provider

	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON -- -f $PROVIDER_FILE
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
        if [ "$FIFO" != "" ] ; then
          if test -p $FIFO ; then
            rm -f $FIFO
            echo -n "fifo-removed "
          fi
        fi
	start-stop-daemon --stop --quiet --oknodo \
		--pidfile /var/run/$NAME.pid --exec $DAEMON
	echo "$NAME."
	;;
  reload|force-reload)
	#echo "Reloading $DESC configuration files."
        if [ "$FIFO" != "" ] ; then
          if test -p $FIFO ; then
	    check_provider
            echo "reset" > $FIFO
            echo "Diald configuration reloaded."
          else
            echo "Cannot reload diald configuration: $FIFO not found."
            exit 2
          fi
        else
          echo "Cannot reload diald configuration: "
          echo "  need a fifo statement in /etc/diald/diald.options."
          exit 2
        fi
	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
	#	/var/run/$NAME.pid --exec $DAEMON
  ;;
  restart)
	echo -n "Restarting $DESC: "
        #pid=`cat /var/run/$NAME.pid`
	start-stop-daemon --stop --quiet --oknodo --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
        while [ -n "`pidof $NAME`" ]; do sleep 1; echo -n .;done
        #while ps $pid >/dev/null 2>/dev/null
        #do
        #  sleep 1
        #done
	#sleep 1
	check_provider
	start-stop-daemon --start --quiet \
		--pidfile /var/run/$NAME.pid \
		--exec $DAEMON -- -f $PROVIDER_FILE
	echo "$NAME."
	;;
  *)
	#N=/etc/init.d/$NAME
	echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
	# echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0