X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;ds=sidebyside;f=wrt-setup-local;h=a5fd9118db2ee5b7c60087350c564ab7d51e4a4f;hb=8bb06901ce000f76dafc73288e1fe47c3032e4af;hp=9713ada97dea2c74d6971314e15fc913539483f6;hpb=006906dba1cee38c7fce6d09e8637d5d44c94d30;p=automated-distro-installer diff --git a/wrt-setup-local b/wrt-setup-local index 9713ada..a5fd911 100755 --- a/wrt-setup-local +++ b/wrt-setup-local @@ -16,8 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -f=/usr/local/lib/err;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f - +f=/usr/local/lib/bash-bear;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f usage() { cat <&2; usage 1 ;; esac ;; @@ -93,9 +98,12 @@ shift "$((OPTIND-1))" # Discard the options and sentinel -- if [[ $1 ]]; then h=$1 +elif [[ $hostname ]]; then + h=$hostname else h=cmc fi + if [[ ! $hostname ]]; then hostname=$h fi @@ -212,7 +220,7 @@ cedit() { lan=10.0.0.0 if $test; then lan=10.1.0.0 -elif [[ $hostname == cmc ]]; then +elif [[ $hostname == cmc || $hostname == cmcap ]]; then lan=10.2.0.0 elif $client; then lan=10.3.0.0 @@ -284,8 +292,8 @@ fi uset network.lan.ipaddr $l.$lanip uset network.lan.netmask $mask -if $dev2 || $client; then - if $dev2; then +if $dev2 || $client || $ap; then + if $dev2 || $ap; then uset network.lan.gateway $l.1 uset network.wan.proto none uset network.wan6.proto none @@ -295,10 +303,16 @@ if $dev2 || $client; then /etc/init.d/odhcpd stop /etc/init.d/odhcpd disable rm -f /etc/resolv.conf - cat >/etc/resolv.conf <<'EOF' + if $ap; then + cat >/etc/resolv.conf </etc/resolv.conf <<'EOF' nameserver 8.8.8.8 nameserver 8.8.4.4 EOF + fi # things i tried to keep dnsmasq running but not enabled except local dns, # but it didnt work right and i dont need it anyways. @@ -350,7 +364,7 @@ else if [[ $mac ]]; then uset wireless.default_radio$x.macaddr $macpre$((macsuf + 2*x)) fi - # secondary device has wireless disabled + # disable/enable. secondary device has wireless disabled uset wireless.radio$x.disabled $dev2 done fi @@ -368,12 +382,15 @@ EOF uset wireless.radio0.disassoc_low_ack 0 uset wireless.radio1.disassoc_low_ack 0 fi -case $HOSTNAME in - cmc) - # found with https://openwrt.org/docs/guide-user/network/wifi/iwchan - uset wireless.radio0.channel 11 - ;; -esac + + +# found with https://openwrt.org/docs/guide-user/network/wifi/iwchan. +# However, the default also chooses 11, and better to let it choose in case things change. +# case $HOSTNAME in +# cmc) +# uset wireless.radio0.channel 11 +# ;; +# esac # usb, screen, relay are for libremanage @@ -384,10 +401,26 @@ esac # # note: prometheus-node-exporter-lua-openwrt seems to be a dependency of # prometheus-node-exporter-lua in practice. -v pi tcpdump screen rsync unbound-daemon unbound-checkconf \ - kmod-usb-storage block-mount kmod-fs-ext4 \ - prometheus-node-exporter-lua-openwrt \ + +pkgs=( + tcpdump + screen + rsync + kmod-usb-storage + block-mount + kmod-fs-ext4 + prometheus-node-exporter-lua-openwrt prometheus-node-exporter-lua +) + +if ! $ap; then + pkgs+=( + unbound-daemon + unbound-checkconf + ) +fi + +v pi "${pkgs[@]}" # nfs-kernel-server \ # openvpn-openssl adblock libusb-compat \ # kmod-usb-serial-cp210x kmod-usb-serial-ftdi \ @@ -519,9 +552,9 @@ fi cedit /etc/config/network <&2 - exit 1 + if $unbound_restart; then + /etc/init.d/unbound restart + if ! unbound-checkconf; then + echo $0: error: unbound-checkconf failed >&2 + exit 1 + fi fi -fi - +fi # end if $ap # # disabled for now. i want to selectively enable it # # for specific hosts. @@ -1203,23 +1271,20 @@ server=10.2.0.1 # default dhcp range is 100-150 # bottom port, iPXE (PCI 03:00.0) in seabios boot menu dhcp-host=c8:60:00:31:6b:75,set:kd,$l.2,kd -dhcp-host=94:05:bb:1e:2c:2e,set:sy,$l.3,sy #dhcp-host=94:05:bb:1e:2c:2e,set:bo,$l.38,bo # top port, iPXE (PCI 04:00.0) in seabios boot menu #dhcp-host=c8:60:00:2b:15:07,set:kd,$l.2,kd # 4 is reserved for a staticly configured host wrt2 -# temporarily commented -dhcp-host=f0:de:f1:81:ec:88,set:x2,$l.5,x2 -dhcp-host=c4:8e:8f:44:f5:63,set:x2w,$l.6,x2w +dhcp-host=c4:8e:8f:60:63:cb,set:x2w,$l.6,x2w dhcp-host=10:51:07:f5:f1:b8,set:syw,$l.7,syw dhcp-host=80:fa:5b:1c:6e:cf,set:amy,$l.8,amy -# This is so fai can have an explicit name to use for testing, -# or else any random machine which did a pxe boot would get -# reformatted. The mac is from doing a virt-install, cancelling it, -# and copying the generated mac, so it should be randomish. -dhcp-host=52:54:00:9c:ef:ad,set:demohost,$l.12,demohost +dhcp-host=a0:ce:c8:9f:7a:f3,set:sy,$l.12,sy +# alternate dongle +#dhcp-host=94:05:bb:1e:2c:2e,set:sy,$l.12,sy +dhcp-host=00:1f:16:16:39:24,set:x2,$l.13,x2 + ## for using different dhcp server #dhcp-host=52:54:00:9c:ef:ad,ignore # 14 = wrt3 @@ -1231,13 +1296,11 @@ dhcp-host=00:1b:a9:8c:a8:23,set:brother,$l.19,brother dhcp-host=00:26:b6:f7:d4:d8,set:amyw,$l.23,amyw dhcp-host=9a:c6:52:6f:ce:7c,set:onep9,$l.24,onep9 dhcp-host=38:63:bb:07:5a:f9,set:hp,$l.25,hp -dhcp-host=00:26:18:97:bb:16,set:frodo,$l.28,frodo -#dhcp-host=00:26:b6:f6:0f:e9,set:frodow,$l.28,frodow dhcp-host=70:a6:cc:3a:bb:b4,set:bow,$l.29,bow dhcp-host=6c:56:97:88:7b:74,set:amazontab,$l.31,amazontab dhcp-host=0a:8a:9b:cf:b5:ec,set:samsungtab,$l.32,samsungtab -# old x2 with bad fan -dhcp-host=00:1f:16:16:39:24,set:x8,$l.38,x8 +dhcp-host=14:dd:a9:d5:31:7a,set:frodo,$l.34,frodo +#dhcp-host=00:26:b6:f6:0f:e9,set:frodow,$l.34,frodow # server d16: dhcp-host=38:2c:4a:c9:33:13,set:bigs,$l.48,bigs dhcp-host=e4:5f:01:07:50:40,set:pi4,$l.49,pi4 @@ -1245,6 +1308,12 @@ dhcp-host=e4:5f:01:07:50:3f,set:pi4w,$l.50,pi4w # samsung phone dhcp-host=a8:79:8d:71:54:68,set:s22,$l.52,s22 +# This is so fai can have an explicit name to use for testing, +# or else any random machine which did a pxe boot would get +# reformatted. The mac is from doing a virt-install, cancelling it, +# and copying the generated mac, so it should be randomish. +dhcp-host=52:54:00:9c:ef:ad,set:demohost,$l.88,demohost + # faiserver vm #dhcp-host=52:54:00:56:09:f9,set:faiserver,$l.15,faiserver @@ -1266,7 +1335,7 @@ dhcp-optsfile=/var/run/dnsmasq/dhcpopts.conf EOF -if $dnsmasq_restart && ! $dev2; then +if $dnsmasq_restart && ! $dev2 && ! $ap; then # todo: can our ptr records be put in /etc/hosts? # eg: user normal /etc/hosts records, and they wont be used for A resolution # due to the other settings, but will be used for ptr? then maybe @@ -1283,7 +1352,10 @@ if $dnsmasq_restart && ! $dev2; then v /etc/init.d/dnsmasq restart fi -if $firewall_restart; then +if $ap; then + v /etc/init.d/firewall disable + v /etc/init.d/firewall stop +elif $firewall_restart; then v /etc/init.d/firewall restart fi @@ -1302,4 +1374,4 @@ if $network_restart; then reboot fi -exit 0 +v exit 0