kernel: fix sanity check
[minix.git] / etc / rs.inet
blob57c4588272312c257c36d348ec9bc056932fe05a
1 #!/bin/sh
3 # Recovery script for INET/lwip. It restarts daemons dependent on it in order
4 # to recover TCP state.
6 kill_by_name()
8 label="$1"
9 pid=`ps ax | grep "$label" | grep -v grep |
10 sed 's,[ ]*\([0-9]*\).*,\1,`
11 if [ X"$pid" = X ]
12 then
13 return 1 # No such process
15 echo "killing pid $pid for $label"
16 kill -9 $pid
19 daemonize()
21 # Function to start a daemon, if it exists.
22 local IFS=':'
23 local name="$1"
24 test "$1" = tcpd && name="$2"
26 for dir in $PATH
28 if [ -f "$dir/$1" ]
29 then
31 # check if this service is disabled at the boot monitor.
32 if disabled $name; then return; fi
34 echo -n " $name"
35 "$@" &
36 return
38 done
41 disabled()
43 ifs="$IFS"; IFS=,
44 for skip in `sysenv disable`
45 do
46 if [ "$skip" = "$1" ]
47 then
48 IFS="$ifs"; unset ifs
49 return 0
51 done
52 IFS="$ifs"; unset ifs
53 return 1
56 exec > /dev/console
57 echo "Arguments: $@"
59 service down "$1"
60 kill_by_name dhcpd
61 kill_by_name nonamed
62 kill_by_name syslogd
64 # Wait a moment to let daemons clean themselves up
65 sleep 3
66 if [ X`/bin/sysenv lwip` = Xyes ]
67 then
68 service up /usr/sbin/lwip -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE_A
69 dhcpd --lwip &
70 else
71 service up /usr/sbin/inet -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE
72 daemonize dhcpd
74 daemonize nonamed -L
75 daemonize syslogd
77 # Restart SSH daemon if installed and running
78 if [ -f /usr/pkg/etc/rc.d/sshd ]
79 then
80 /usr/pkg/etc/rc.d/sshd status | grep -v not > /dev/null
81 if [ $? -eq 0 ]
82 then
83 /usr/pkg/etc/rc.d/sshd restart