various fixes and initial focal support
[automated-distro-installer] / wrt-setup-local
1 #!/bin/bash
2 # Copyright (C) 2016 Ian Kelling
3
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 set -eE -o pipefail
19 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
20
21
22 usage() {
23 cat <<EOF
24 usage: ${0##*/} [-h] [-t 2|3|test] [-m WIRELESS_MAC]
25 setup my router in general: dhcp, dns, etc.
26
27 Type 2 or 3 is for setting up a backup device, there are two kinds so
28 that you can switch the main device to a backup, then a backup to the
29 main. Type test is for setting up a testing device.
30
31 Passing an empty string for WIRELESS_MAC will cause the device's native
32 mac to be used.
33
34 EOF
35
36 exit $1
37 }
38
39
40
41
42 dev2=false
43 test=false
44 libremanage_host=wrt2
45
46 if [[ -e /p/router-secrets ]]; then
47 source /p/router-secrets
48 fi
49 rmac=$(cat /sys/class/net/eth0/address)
50 if [[ $rhost ]]; then
51 hostname=${rhost[$rmac]}
52 fi
53 : ${hostname:=wrt}
54
55
56 lanip=1
57 while getopts hm:t: opt; do
58 case $opt in
59 h) usage ;;
60 t)
61 case $2 in
62 2|3)
63 dev2=true
64 libremanage_host=$hostname
65 ;;&
66 2)
67 lanip=4
68 hostname=wrt2
69 ;;
70 3)
71 lanip=14
72 hostname=wrt3
73 ;;
74 test)
75 test=true
76 ;;
77 *) echo "$0: unexpected arg to -t: $*" >&2; usage 1 ;;
78 esac
79 ;;
80 m) mac=$OPTARG ;;
81 *) echo "$0: Internal error! unexpected args: $*" >&2 ; usage 1 ;;
82 esac
83 done
84 shift "$((OPTIND-1))" # Discard the options and sentinel --
85
86 if [[ ! $mac ]] && ! $test; then
87 # if we wanted to increment it
88 #WIRELESSMAC=${WIRELESSMAC:0: -1}$((${WIRELESSMAC: -1} + 2))
89 mac=$WIRELESSMAC
90 fi
91
92 if (( $# != 0 )); then
93 usage 1
94 fi
95
96
97 macpre=${mac:0: -1}
98 macsuf=${mac: -1}
99
100
101 p_updated=false
102 pmirror() {
103 if $p_updated; then
104 return
105 fi
106 # background: upgrading all packages is not recommended because it
107 # doesn't go into the firmware. build new firmware if you want
108 # lots of upgrades. I think /tmp/opkg-lists is a pre openwrt 14 location.
109 f=(/var/opkg-lists/*)
110 if ! (( $(date -r $f +%s) + 60*60*24 > $(date +%s) )); then
111 if ! opkg update; then
112 echo "$0: warning: opkg update failed" >&2
113 fi
114 p_updated=true
115 fi
116 }
117
118 pi() {
119 to_install=()
120 for p in "$@"; do
121 pname=${p##*/}
122 pname=${pname%%_*}
123 if [[ ! $(opkg list-installed "$pname") ]]; then
124 to_install+=($p)
125 pmirror
126 fi
127 done
128 if [[ $to_install ]]; then
129 opkg install ${to_install[@]}
130 fi
131 }
132
133 v() {
134 printf "+ %s\n" "$*"
135 "$@"
136 }
137
138 ######### uci example:#######
139 # # https://wiki.openwrt.org/doc/uci
140 # wan_index=$(uci show firewall | sed -rn 's/firewall\.@zone\[([0-9])+\]\.name=wan/\1/p')
141 # wan="firewall.@zone[$wan_index]"
142 # if [[ $(uci get firewall.@forwarding[0].dest) != $forward_dest ]]; then
143 # # default is wan
144 # v uci set firewall.@forwarding[0].dest=$forward_dest
145 # uci commit firewall
146 # firewall_restart=true
147 # fi
148 ####### end uci example #####
149
150 uset() {
151 printf "+ uset %s\n" "$*"
152 local key="$1"
153 local val="$2"
154 local service="${key%%.*}"
155 restart_var=${service}_restart
156 if [[ ! ${!restart_var} ]]; then
157 eval $restart_var=false
158 fi
159 if [[ $(uci get "$key") != "$val" ]]; then
160 v uci set "$key"="$val"
161 uci commit $service
162 eval $restart_var=true
163 fi
164 }
165
166 udel() {
167 printf "+ udel %s\n" "$*"
168 local key="$1"
169 local val="$2"
170 local service="${key%%.*}"
171 restart_var=${service}_restart
172 if [[ ! ${!restart_var} ]]; then
173 eval $restart_var=false
174 fi
175 if uci get "$key" &>/dev/null; then
176 v uci set "$key"="$val"
177 uci commit $service
178 eval $restart_var=true
179 fi
180 }
181
182
183
184 ### network config
185 ###
186 ssid="check out gnu.org"
187 lan=10.0.0.0
188 if $test; then
189 ssid="gnuv3"
190 lan=10.1.0.0
191 elif [[ $hostname == cmc ]]; then
192 ssid=Svenska
193 lan=10.2.0.0
194 fi
195
196 if [[ $rkey ]]; then
197 key=${rkey[$rmac]}
198 fi
199 : ${key:=pictionary49}
200
201 mask=255.255.0.0
202 cidr=16
203 l=${lan%.0}
204
205 passwd -l root ||: #already locked fails
206
207 sed -ibak '/^root:/d' /etc/shadow
208 # /root/router created by manually running passwd then copying the resulting
209 # line. We have no mkpasswd on wrt/librecmc, then we scp it in.
210 cat /root/router >>/etc/shadow
211 # otherwise, serial console gets root login with no password
212 uset system.@system[0].ttylogin 1
213
214
215
216 cat >/usr/bin/archlike-pxe-mount <<'EOFOUTER'
217 #!/bin/bash
218 # symlinks are collapsed for nfs mount points, so use a bind mount.
219 # tried putting this in /etc/config/fstab,
220 # then doing block mount, it didn't work. This doesn't persist across reboots,
221 # todo: figure that out
222 rm -f /etc/fstab
223 for d in /run/{arch,parabola}iso/bootmnt; do
224 cat >>/etc/fstab <<EOF
225 /mnt/usb/tftpboot $d none bind 0 0
226 EOF
227 mount | grep $d &>/dev/null || mount $d
228 done
229 /etc/init.d/nfsd restart
230 EOFOUTER
231 chmod +x /usr/bin/archlike-pxe-mount
232
233 sed -i '/^root:/s,/bin/ash$,/bin/bash,' /etc/passwd
234
235
236
237 uset dropbear.@dropbear[0].PasswordAuth 0
238 uset dropbear.@dropbear[0].RootPasswordAuth 0
239 uset dropbear.@dropbear[0].Port 2220
240 if ! cmp -s /root/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key; then
241 cp /root/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key
242 dropbear_restart=true
243 fi
244
245 if $dropbear_restart; then
246 v /etc/init.d/dropbear restart
247 fi
248
249
250 uset network.lan.ipaddr $l.$lanip
251 uset network.lan.netmask $mask
252 if $dev2; then
253 uset network.lan.gateway $l.1
254 uset network.wan.proto none
255 uset network.wan6.proto none
256 /etc/init.d/dnsmasq stop
257 /etc/init.d/dnsmasq disable
258 /etc/init.d/odhcpd stop
259 /etc/init.d/odhcpd disable
260 rm -f /etc/resolv.conf
261 cat >/etc/resolv.conf <<'EOF'
262 nameserver 8.8.8.8
263 nameserver 8.8.4.4
264 EOF
265
266 # things i tried to keep dnsmasq running but not enabled except local dns,
267 # but it didnt work right and i dont need it anyways.
268 # uset dhcp.wan.ignore $dev2 # default is false
269 # uset dhcp.lan.ignore $dev2 # default is false
270 # uset dhcp.@dnsmasq[0].interface lo
271 # uset dhcp.@dnsmasq[0].localuse 0
272 # uset dhcp.@dnsmasq[0].resolvfile /etc/dnsmasq.conf
273 # uset dhcp.@dnsmasq[0].noresolv 1
274 # todo: populate /etc/resolv.conf with a static value
275
276 else
277 # these are the defaults
278 uset network.lan.gateway ''
279 uset network.wan.proto dhcp
280 uset network.wan6.proto dhcpv6
281 /etc/init.d/dnsmasq start
282 # todo: figure out why this returns 1
283 /etc/init.d/dnsmasq enable ||:
284 /etc/init.d/odhcpd start
285 /etc/init.d/odhcpd enable
286 fi
287
288 wireless_restart=false
289 for x in 0 1; do
290 uset wireless.default_radio$x.ssid "$ssid"
291 uset wireless.default_radio$x.key $key
292 uset wireless.default_radio$x.encryption psk2
293 if [[ $mac ]]; then
294 uset wireless.default_radio$x.macaddr $macpre$((macsuf + 2*x))
295 fi
296 # secondary device has wireless disabled
297 uset wireless.radio$x.disabled $dev2
298 done
299
300 if $wireless_restart; then
301 v wifi
302 fi
303
304
305
306 # usb, screen, relay are for libremanage
307 # rsync is for brc
308 v pi kmod-usb-storage block-mount kmod-fs-ext4 nfs-kernel-server \
309 tcpdump openvpn-openssl adblock libusb-compat /root/relay_1.0-1_mips_24kc.ipk \
310 screen kmod-usb-serial-cp210x kmod-usb-serial-ftdi rsync
311
312 cat >/etc/libremanage.conf <<EOF
313 ${libremanage_host}_type=switch
314 ${libremanage_host}_channel=1
315 EOF
316
317
318
319 v /etc/init.d/fstab enable ||:
320
321 # rebooting makes mounting work, but comparing lsmod,
322 # i'm guessing this will too. todo, test it.
323 # 255 == module already loaded
324 for mod in scsi_mod sd_mod; do v modprobe $mod || [[ $? == 255 ]]; done
325
326 # for archlike pxe. The default settings in the installer expect to find
327 # the NFS at one of these dirs
328 mkdir -p /run/archiso/bootmnt
329 mkdir -p /run/parabolaiso/bootmnt
330
331 # todo: at some later time, i found /mnt/usb not mounted, watch to see if
332 # that is the case after running this or rebooting.
333 # wiki says safe to do in case of fstab changes:
334
335 ## ian: usb broke on old router. if that happens, can just comment this to disable problems
336 # echo | cedit /etc/config/fstab ||:
337 v cedit /etc/config/fstab <<EOF || { v block umount; v block mount; }
338 config global automount
339 option from_fstab 1
340 option anon_mount 1
341
342 config mount
343 # /overlay is an / overlay mount for installing extra packages, etc.
344 # https://openwrt.org/docs/guide-user/additional-software/extroot_configuration
345 option target /mnt/usb
346 # option target /overlay
347 option device /dev/sda1
348 option fstype ext4
349 option options rw,async,noatime,nodiratime
350 option enabled 0
351 EOF
352
353
354 # ian: disabled because afaik I don't need it, no benefit.
355 # config global autoswap
356 # option from_fstab 1
357 # option anon_swap 1
358
359 # config swap
360 # option device /dev/sda1
361 # option enabled 1
362
363
364
365
366 # exportfs -ra wont cut it when its the same path, but now a bind mount
367 # todo: restart nfs when nfs is enabled?
368 #cedit /etc/exports <<EOF || v /etc/init.d/nfsd restart ||:
369 cedit /etc/exports <<EOF ||:
370 /mnt/usb $lan/$cidr(rw,no_root_squash,insecure,sync,no_subtree_check)
371 # for arch pxe
372 /run/archiso/bootmnt $lan/$cidr(rw,no_root_squash,insecure,sync,no_subtree_check)
373 /run/parabolaiso/bootmnt $lan/$cidr(rw,no_root_squash,insecure,sync,no_subtree_check)
374 EOF
375
376
377 # todo: enable nfs when we need it only.
378 # v /etc/init.d/portmap start
379 # v /etc/init.d/nfsd start
380 # v /etc/init.d/portmap enable
381 # v /etc/init.d/nfsd enable
382
383
384
385
386
387
388
389
390 ########## openvpn exampl
391 ########## missing firewall settings for routing lan
392 ########## traffic
393 # v /etc/init.d/openvpn start
394 # v /etc/init.d/openvpn enable
395
396 # # from https://wiki.openwrt.org/doc/uci/firewall
397 # # todo: not sure if /etc/init.d/network needs restarting.
398 # # I did, and I had to restart the vpn afterwards.
399 # # This maps a uci interface to a real interface which is
400 # # managed outside of uci.
401 # v cedit /etc/config/network <<'EOF' ||:
402 # config interface 'tun0'
403 # option ifname 'tun0'
404 # option proto 'none'
405 # EOF
406 # v cedit /etc/config/openvpn <<'EOF' || v /etc/init.d/openvpn restart
407 # config openvpn my_client_config
408 # option enabled 1
409 # option config /etc/openvpn/client.conf
410 # EOF
411
412 wgip4=10.3.0.1/24
413 wgip6=fdfd::1/64
414 wgport=26000
415
416
417 v cedit /etc/config/network <<EOF || v /etc/init.d/network reload
418 config 'route' 'transmission'
419 option 'interface' 'lan'
420 option 'target' '10.173.0.0'
421 option 'netmask' '255.255.0.0'
422 option 'gateway' '$l.3'
423
424 option interface 'wg0'
425 option proto 'wireguard'
426 option private_key '$(cat /root/wg.key)'
427 option listen_port $wgport
428 list addresses '10.3.0.1/24'
429 list addresses 'fdfd::1/64'
430
431 # tp
432 config wireguard_wg0 'wgclient'
433 option public_key '3q+WJGrm85r59NgeXOIvppxoW4ux/+koSw6Fee1c1TI='
434 option preshared_key '$(cat /root/wg.psk)'
435 list allowed_ips '10.3.0.2/24'
436 list allowed_ips 'fdfd::2/64'
437 EOF
438
439
440 firewall_restart=false
441
442 firewall-cedit() {
443 v cedit /etc/config/firewall <<EOF
444
445 config redirect
446 option name ssh
447 option src wan
448 option src_dport 22
449 option dest_ip $l.2
450 option dest lan
451 config rule
452 option src wan
453 option target ACCEPT
454 option dest_port 22
455
456 config redirect
457 option name sshtp
458 option src wan
459 option src_dport 2202
460 option dest_port 22
461 option dest_ip $l.8
462 option dest lan
463 config rule
464 option src wan
465 option target ACCEPT
466 option dest_port 2202
467
468 config redirect
469 option name sshfrodo
470 option src wan
471 option src_dport 2203
472 option dest_port 22
473 option dest_ip $l.3
474 option dest lan
475 config rule
476 option src wan
477 option target ACCEPT
478 option dest_port 2203
479
480 config redirect
481 option name sshx2
482 option src wan
483 option src_dport 2205
484 option dest_port 22
485 option dest_ip $l.5
486 option dest lan
487 config rule
488 option src wan
489 option target ACCEPT
490 option dest_port 2205
491
492 config redirect
493 option name sshx3
494 option src wan
495 option src_dport 2207
496 option dest_port 22
497 option dest_ip $l.7
498 option dest lan
499 config rule
500 option src wan
501 option target ACCEPT
502 option dest_port 2207
503
504 config redirect
505 option name sshtp
506 option src wan
507 option src_dport 2208
508 option dest_port 22
509 option dest_ip $l.8
510 option dest lan
511 config rule
512 option src wan
513 option target ACCEPT
514 option dest_port 2208
515
516
517 config rule
518 option name sshwrt
519 option src wan
520 option target ACCEPT
521 option dest_port 2220
522
523 config rule
524 option name wg
525 option src wan
526 option target ACCEPT
527 option dest_port $wgport
528 option proto udp
529
530
531 config redirect
532 option name vpntp
533 option src wan
534 option src_dport 1196
535 option dest lan
536 option dest_ip $l.8
537 option proto udp
538 config rule
539 option src wan
540 option target ACCEPT
541 option dest_port 1196
542 option proto udp
543
544
545 config redirect
546 option name httptp
547 option src wan
548 option src_dport 80
549 option dest lan
550 option dest_ip $l.8
551 option proto tcp
552 config rule
553 option src wan
554 option target ACCEPT
555 option dest_port 80
556 option proto tcp
557
558 config redirect
559 option name httpstp
560 option src wan
561 option src_dport 443
562 option dest lan
563 option dest_ip $l.8
564 option proto tcp
565 config rule
566 option src wan
567 option target ACCEPT
568 option dest_port 443
569 option proto tcp
570
571 config redirect
572 option name syncthing
573 option src wan
574 option src_dport 22001
575 option dest_ip $l.8
576 option dest lan
577 config rule
578 option src wan
579 option target ACCEPT
580 option dest_port 22001
581
582
583 config rule
584 option name ssh-ipv6
585 option src wan
586 option dest lan
587 # note, using mac transform, we could allow all traffic to a host like this,
588 # replacing 1 as appropriate
589 #option dest_ip ::111:11ff:fe11:1111/::ffff:ffff:ffff:ffff
590 option dest_port 22
591 option target ACCEPT
592 option family ipv6
593
594 config rule
595 option name http-ipv6
596 option src wan
597 option dest lan
598 option dest_port 80
599 option target ACCEPT
600 option family ipv6
601
602 config rule
603 option name https-ipv6
604 option src wan
605 option dest lan
606 option dest_port 443
607 option target ACCEPT
608 option family ipv6
609
610 config rule
611 option name node-exporter
612 option src wan
613 option dest lan
614 option dest_port 9101
615 option target ACCEPT
616 option family ipv6
617
618 config rule
619 option name mail587-ipv6
620 option src wan
621 option dest lan
622 option dest_port 587
623 option target ACCEPT
624 option family ipv6
625
626 EOF
627 }
628 firewall-cedit || firewall_restart=true
629
630 if ! uci get firewall.@zone[1].network | grep wg0 &>/dev/null; then
631 # cant mix cedit plus uci
632 echo | cedit /etc/config/firewall ||:
633 uci add_list firewall.@zone[1].network=wg0
634 uci commit firewall
635 firewall-cedit ||:
636 firewall_restart=true
637 fi
638
639
640 dnsmasq_restart=false
641 v cedit /etc/hosts <<EOF || dnsmasq_restart=true
642 127.0.1.1 $hostname
643 $l.1 $hostname b8.nz
644 $l.2 kd faiserver
645 $l.3 frodo
646 $l.4 wrt2
647 $l.5 x2
648 $l.6 demohost
649 #$l.7 x3
650 $l.8 tp
651 $l.9 bb8
652 $l.14 wrt3
653 2600:3c00::f03c:91ff:fe6d:baf8 li
654 72.14.176.105 li
655 2a01:7e01::f03c:91ff:feb5:baec l2
656 172.105.84.95 l2
657
658 # netns creation looks for next free subnet starting at 10.173, but I only
659 # use one, and I would keep this one as the first created.
660 10.173.0.2 transmission
661 EOF
662
663 #mail_host=$(grep -F mail.iankelling.org /etc/hosts | awk '{print $1}')
664 # if [[ $mail_host ]]; then
665 # sed -i '/^$mail_host/a mail.iankelling.org' /etc/hosts
666 # fi
667
668
669 uset dhcp.@dnsmasq[0].domain b8.nz
670 uset dhcp.@dnsmasq[0].local /b8.nz/
671 uset system.@system[0].hostname $hostname
672
673 if [[ $(uci get adblock.global.adb_enabled) != 1 ]]; then
674 v uci set adblock.global.adb_enabled=1
675 uci commit adblock
676 /etc/init.d/adblock restart
677 fi
678 # https://github.com/openwrt/packages/tree/master/net/adblock/files
679 cat >/etc/crontabs/root <<'EOF'
680 0 06 * * * /etc/init.d/adblock reload
681 EOF
682
683
684 # useful: http://wiki.openwrt.org/doc/howto/dhcp.dnsmasq
685
686 # sometimes /mnt/usb fails, cuz it's just a flash drive,
687 # so make sure we have this dir or else dnsmasq will fail
688 # to start.
689 mkdir -p /mnt/usb/tftpboot
690 v cedit /etc/dnsmasq.conf <<EOF || dnsmasq_restart=true
691 server=/dmarctest.b8.nz/#
692 server=/_domainkey.b8.nz/#
693 server=/_dmarc.b8.nz/#
694 server=/ns1.b8.nz/#
695 server=/ns2.b8.nz/#
696 mx-host=b8.nz,mail.iankelling.org,10
697 txt-record=b8.nz,"v=spf1 a ?all"
698
699
700 # https://ret2got.wordpress.com/2018/01/19/how-your-ethereum-can-be-stolen-using-dns-rebinding/
701 stop-dns-rebind
702
703 # this says the ip of default gateway and dns server,
704 # but I think they are unneded and default
705 #dhcp-option=3,$l.1
706 #dhcp-option=6,$l.1
707
708
709
710 # results from googling around dnsmasq optimizations
711 # about 50k in memory. router has 62 megs.
712 # in a browsing session, I probably won't ever do 5000 lookups
713 # before the ttl expiration or whatever does expiration.
714 cache-size=10000
715
716 # ask all servers, use the one which responds first.
717 # http://ma.ttwagner.com/make-dns-fly-with-dnsmasq-all-servers/
718 all-servers
719
720 # namebench benchmarks dns servers. google's dns was only
721 # slightly less fast than some others, and I trust it more
722 # to give accurate results, stay relatively fast, and
723 # not do anythin too malicious, so just use that.
724 # download namebench and run it like this:
725 # for x in all regional isp global preferred nearby; do ./namebench.py -s \$x -c US -i firefox -m weighted -J 10 -w; echo \$x; hr; done
726 # google
727 server=8.8.4.4
728 server=8.8.8.8
729 server=2001:4860:4860::8888
730 server=2001:4860:4860::8844
731
732
733 # to fixup existin ips, on the client you can do
734 # sudo dhclient -r; sudo dhclient <interface-name>
735
736 # default dhcp range is 100-150
737 # bottom port, iPXE (PCI 03:00.0) in seabios boot menu
738 dhcp-host=c8:60:00:31:6b:75,set:kd,$l.2,kd
739 # top port, iPXE (PCI 04:00.0) in seabios boot menu
740 #dhcp-host=c8:60:00:2b:15:07,set:kd,$l.2,kd
741 dhcp-host=00:26:18:97:bb:16,set:frodo,$l.3,frodo
742 # 4 is reserved for a staticly configured host.
743 dhcp-host=00:1f:16:16:39:24,set:x2,$l.5,x2
744 # This is so fai can have an explicit name to use for testing,
745 # or else any random machine which did a pxe boot would get
746 # reformatted. The mac is from doing a virt-install, cancelling it,
747 # and copying the generated mac, so it should be randomish.
748 dhcp-host=52:54:00:9c:ef:ad,set:demohost,$l.6,demohost
749 dhcp-host=00:1f:16:14:01:d8,set:tp,$l.7,x3
750 dhcp-host=80:fa:5b:1c:6e:cf,set:tp,$l.8,tp
751
752 # faiserver vm
753 dhcp-host=52:54:00:56:09:f9,set:faiserver,$l.15,faiserver
754
755 # This is the ip it picks by default if dhcp fails,
756 # so might as well use it.
757 # hostname is the name it uses according to telnet
758 dhcp-host=b4:75:0e:94:29:ca,set:switch9429ca,$l.251,switch9429ca
759
760 # template
761 # dhcp-host=,$l.,
762
763 # Just leave the tftp server up even if we aren't doing pxe boot.
764 # It has no sensitive info.
765 enable-tftp=br-lan
766 tftp-root=/mnt/usb/tftpboot
767 dhcp-optsfile=/etc/dnsmasq-dhcpopts.conf
768 EOF
769
770
771
772
773 if $dnsmasq_restart && ! $dev2; then
774 v /etc/init.d/dnsmasq restart
775 fi
776
777 if $firewall_restart; then
778 v /etc/init.d/firewall restart
779 fi
780
781
782 # todo: we should catch errors and still run this if needed
783 if $network_restart; then
784 reboot
785 fi
786
787 exit 0