etc/services - sync with NetBSD-8
[minix3.git] / etc / rs.lwip
blobc413a3cce544f6ff9a018c59b41faa7d9feb015c
1 #!/bin/sh
3 # Recovery script for LWIP. Aside from restarting the LWIP service itself, the
4 # script aims to restart all of networking. This includes in particular any
5 # network daemons: these daemons typically have open (listening) sockets that
6 # will now have become invalid, and the daemons typically do not know how to
7 # deal with that. Unfortunately, there is no reliable way to determine the
8 # list of rc scripts that concern network daemons, so for now we hardcode a
9 # list of known ones here: this is the list of network-related rc.d scripts.
10 # FIXME: since we are not yet done importing etc/rc.d from NetBSD, this list is
11 # still incomplete and should be extended as more scripts are imported!
12 RC_SCRIPTS="dhclient dhcpcd dhcpd dhcrelay ftpd inetd named network rtadvd \
13 sshd staticroute syslogd"
15 exec < /dev/console
16 exec > /dev/console
17 exec 2> /dev/console
19 export HOME=/
20 export PATH=/sbin:/usr/sbin:/bin:/usr/bin
22 . /etc/rc.subr
23 . /etc/rc.conf
25 # Restart the LWIP service.
27 # There is no need to shut down daemons before bringing back up the service.
28 # Note that "minix-service restart" does not do the same as these steps, and in
29 # fact breaks a proper LWIP restart.
30 restarts=$(grep restarts /proc/service/$1 | cut -d: -f2)
31 minix-service down "$1"
32 minix-service up /service/lwip -dev /dev/bpf -script /etc/rs.lwip \
33 -restarts $(($restarts + 1))
35 # Reload TCP ISN, or make a new one if there is none. Do not save anything.
36 TCPISN_FILE=/usr/adm/tcpisn.dat
37 TCPISN_LEN=$(sysctl -n net.inet.tcp.isn_secret | awk '{print length/2}')
38 if [ ! -f $TCPISN_FILE ]; then TCPISN_FILE=/dev/random; fi
39 sysctl -qw net.inet.tcp.isn_secret=`dd if=$TCPISN_FILE bs=$TCPISN_LEN \
40 count=1 2>/dev/null | hexdump -v -e '/1 "%02x"'` 2>/dev/null
42 # Let LWIP find all network drivers before performing initialization.
43 sleep 1
45 # Restart all network daemons.
47 # Start with dhcpcd, which may be launched directly from ifconfig.if(5) scripts
48 # and therefore may not be enabled in, and thus stopped by, rc.d scripts below.
49 service dhcpcd onestop >/dev/null 2>&1
51 # Then stop and start all known network daemons using their rc.d scripts.
52 regex='/('"$(echo $RC_SCRIPTS | tr ' ' '|')"')$'
53 scripts=$(for rcd in ${rc_directories:-/etc/rc.d}; do
54 test -d ${rcd} && echo ${rcd}/*; done)
55 files=$(rcorder ${scripts} | grep -E "$regex")
57 for _rc_elem in $(reverse_list $files); do
58 # We have already stopped dhcpcd if it was running, so skip it here.
59 [ $_rc_elem != /etc/rc.d/dhcpcd ] && run_rc_script $_rc_elem stop
60 done
62 for _rc_elem in $files; do
63 run_rc_script $_rc_elem start
64 done