cmdline="rd.luks.crypttab=no net.ifnames=0 console=ttyS0,${speed}n8"
else
speed=115200
- cmdline="rd.luks.crypttab=no net.ifnames=0 console=ttyS0,${speed}n8 console=tty0"
+ cmdline="rd.luks.crypttab=no net.ifnames=0 console=ttyS0,${speed}n8 console=tty0"
fi
cat >$FAI_ROOT/etc/grub.d/40_custom <<EOF
iface eth0 inet6 auto
EOF
-# previously had an else condition after
-#elif ifclass VM || ifclass LINODE; then
-# iface br0 inet dhcp
-# bridge_ports $NIC1
-# bridge_stp off
-# bridge_maxwait 0
-# however, on t9, on startup, br0, became
-# rename1 and didn't come up. i dunno why,
-# but the bridge is for vms that I rarely use,
-# so not bothering to figure it out.
+ # previously had an else condition after
+ #elif ifclass VM || ifclass LINODE; then
+ # iface $NIC1 inet manual
+ # iface br0 inet dhcp
+ # bridge_ports $NIC1
+ # bridge_stp off
+ # bridge_maxwait 0
+ # however, on t9, on startup, br0, became
+ # rename1 and didn't come up. i dunno why,
+ # but the bridge is for vms that I rarely use,
+ # so not bothering to figure it out.
fi
+rm -f $target/etc/resolv.conf
+ln -s ../run/systemd/resolve/stub-resolv.conf $target/etc/resolv.conf
+
if ifclass LINODE; then
mkdir -p $target/etc/initramfs-tools/conf.d
cat >$target/etc/initramfs-tools/conf.d/mine <<EOF
archlike() {
cat <<EOF
-dhcp-option-force=209,boot/syslinux/${type}iso.cfg
-dhcp-option-force=210,/${type}/
-dhcp-boot=${host_tag}/${type}/boot/syslinux/lpxelinux.0
+${host_tag}209,boot/syslinux/${type}iso.cfg
+${host_tag}210,/${type}/
+${host_tag}bootfile-name,/${type}/boot/syslinux/lpxelinux.0
EOF
}
# if arch based was used before, this additionally needs
# the tftp link in /mnt/usb to be changed.
cat <<EOF
-dhcp-boot=${host_tag}pxelinux.0
+${host_tag}bootfile-name,pxelinux.0
EOF
}
fai() {
cat <<EOF
-dhcp-boot=${host_tag}pxelinux.0,faiserver.b8.nz,faiserver.b8.nz
+${host_tag}bootfile-name,pxelinux.0
+${host_tag}server-ip-address,$faiserverip
+${host_tag}tftp-server,$faiserverip
EOF
+ # Note, previously used normal dnsmasq option, but it requires dnsmasq
+ # restart, which causes momentary dns failures, which can bork an
+ # install.
+ #
+ # dhcp-boot=${host_tag}pxelinux.0,faiserver.b8.nz,faiserver.b8.nz
}
ack-wait() {
if [[ $host ]]; then
if $fsf; then
host_regex=" $(getent hosts kw | awk '{print $1}' | sed 's/\./\\./g')"
- else
- host_regex=" $host"
+ else
+ host_regex=" $host"
fi
fi
regex=".*DHCPACK.*$host_regex\b"
else
e "updating dnsmasq.conf:"
m $cmd
- ${cmd:-:}|ssh wrt "cedit pxe /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
+ ${cmd:-:}|ssh wrt "dd of=/etc/dnsmasq-dhcpopts.conf; /etc/init.d/dnsmasq reload
$([[ $type == arch || $type == parabola ]] && echo archlike-pxe-mount)"
fi
}
+type -t host &>/dev/null || sudo apt-get -y install dnsutils
+faiserverip=$(host faiserver | sed -rn 's/^\S+ has address //p;T;q' ||:)
+if [[ ! $faiserverip || $faiserverip =~ [[:space:]] ]]; then
+ echo "$0: error: failed to get \$faiserverip, got: $faiserverip"
+ exit 1
+fi
+
if $set; then
set-pxe
Note, use -m "''" to send an empty mac arg. When we get a new enough
bash, we can use ${@@Q} to properly pass an empty var.
+
+Note, if we dont have internet yet, then just download the bash package,
+scp it over manually and install it, eg:
+
+cat /etc/opkg/distfeeds.conf
+wget https://librecmc.org/librecmc/downloads/snapshots/v1.5.1-core/packages/mips_24kc/packages/bash_5.0-3_mips_24kc.ipk
+scp bash_5.0-3_mips_24kc.ipk wrt:
+ssh wrt
+opkg install /root/bash_5.0-3_mips_24kc.ipk
EOF
wrt-setup-local -h
exit $1
# relay is built for openwrt 18.06.2, r7676-cddd7b4c77
sudo scp /q/root/shadow/router /p/c/machine_specific/wrt/etc/dropbear/dropbear_rsa_host_key \
/a/opt/openwrt/source/bin/packages/mips_24kc/mypackages/relay_1.0-1_mips_24kc.ipk $h:
-ssh $h <<EOF
+scp ../openwrtkeyring/usign/* $h:/etc/opkg/keys
+
+ssh $h <<EOFOUTER
set -x
+# librecmc 1.5.1 is missing nfs-kernel-server and screen
+cat >/etc/opkg/customfeeds.conf <<'EOF'
+src/gz openwrt_packages http://downloads.openwrt.org/releases/19.07.2/packages/mips_24kc/packages
+EOF
+
if ! opkg list-installed|grep bash; then
opkg update
opkg install bash
export HOME_DOMAIN=$HOME_DOMAIN
export WIRELESSMAC=$WIRELESSMAC
wrt-setup-local $@
-EOF
+EOFOUTER
chmod +x /usr/bin/archlike-pxe-mount
sed -i '/^root:/s,/bin/ash$,/bin/bash,' /etc/passwd
+
+
+
+uset dropbear.@dropbear[0].PasswordAuth 0
+uset dropbear.@dropbear[0].RootPasswordAuth 0
+uset dropbear.@dropbear[0].Port 2220
+if ! cmp -s /root/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key; then
+ cp /root/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key
+ dropbear_restart=true
+fi
+
+if $dropbear_restart; then
+ v /etc/init.d/dropbear restart
+fi
+
+
+uset network.lan.ipaddr $l.$lanip
+uset network.lan.netmask $mask
+if $dev2; then
+ uset network.lan.gateway $l.1
+ uset network.wan.proto none
+ uset network.wan6.proto none
+ /etc/init.d/dnsmasq stop
+ /etc/init.d/dnsmasq disable
+ /etc/init.d/odhcpd stop
+ /etc/init.d/odhcpd disable
+ rm -f /etc/resolv.conf
+ cat >/etc/resolv.conf <<'EOF'
+nameserver 8.8.8.8
+nameserver 8.8.4.4
+EOF
+
+ # things i tried to keep dnsmasq running but not enabled except local dns,
+ # but it didnt work right and i dont need it anyways.
+ # uset dhcp.wan.ignore $dev2 # default is false
+ # uset dhcp.lan.ignore $dev2 # default is false
+ # uset dhcp.@dnsmasq[0].interface lo
+ # uset dhcp.@dnsmasq[0].localuse 0
+ # uset dhcp.@dnsmasq[0].resolvfile /etc/dnsmasq.conf
+ # uset dhcp.@dnsmasq[0].noresolv 1
+ # todo: populate /etc/resolv.conf with a static value
+
+else
+ # these are the defaults
+ uset network.lan.gateway ''
+ uset network.wan.proto dhcp
+ uset network.wan6.proto dhcpv6
+ /etc/init.d/dnsmasq start
+ # todo: figure out why this returns 1
+ /etc/init.d/dnsmasq enable ||:
+ /etc/init.d/odhcpd start
+ /etc/init.d/odhcpd enable
+fi
+
+wireless_restart=false
+for x in 0 1; do
+ uset wireless.default_radio$x.ssid "$ssid"
+ uset wireless.default_radio$x.key $key
+ uset wireless.default_radio$x.encryption psk2
+ if [[ $mac ]]; then
+ uset wireless.default_radio$x.macaddr $macpre$((macsuf + 2*x))
+ fi
+ # secondary device has wireless disabled
+ uset wireless.radio$x.disabled $dev2
+done
+
+if $wireless_restart; then
+ v wifi
+fi
+
+
+
# usb, screen, relay are for libremanage
+# rsync is for brc
v pi kmod-usb-storage block-mount kmod-fs-ext4 nfs-kernel-server \
tcpdump openvpn-openssl adblock libusb-compat /root/relay_1.0-1_mips_24kc.ipk \
- screen kmod-usb-serial-cp210x kmod-usb-serial-ftdi
+ screen kmod-usb-serial-cp210x kmod-usb-serial-ftdi rsync
cat >/etc/libremanage.conf <<EOF
${libremanage_host}_type=switch
-uset dropbear.@dropbear[0].PasswordAuth 0
-uset dropbear.@dropbear[0].RootPasswordAuth 0
-uset dropbear.@dropbear[0].Port 2220
-if ! cmp -s /root/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key; then
- cp /root/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key
- dropbear_restart=true
-fi
-
-wireless_restart=false
-
-for x in 0 1; do
- uset wireless.default_radio$x.ssid "$ssid"
- uset wireless.default_radio$x.key $key
- uset wireless.default_radio$x.encryption psk2
- if [[ $mac ]]; then
- uset wireless.default_radio$x.macaddr $macpre$((macsuf + 2*x))
- fi
- # secondary device has wireless disabled
- uset wireless.radio$x.disabled $dev2
-done
-
-if $wireless_restart; then
- v wifi
-fi
-
########## openvpn exampl
########## missing firewall settings for routing lan
option name ssh
option src wan
option src_dport 22
- option dest_ip $l.8
+ option dest_ip $l.2
option dest lan
config rule
option src wan
option dest_port 22
config redirect
- option name sshkd
+ option name sshtp
option src wan
option src_dport 2202
option dest_port 22
- option dest_ip $l.2
+ option dest_ip $l.8
option dest lan
config rule
option src wan
v cedit /etc/hosts <<EOF || dnsmasq_restart=true
127.0.1.1 $hostname
$l.1 $hostname
-$l.2 kd
+$l.2 kd faiserver
$l.3 frodo
$l.4 wrt2
$l.5 x2
$l.6 demohost
#$l.7 x3
-$l.8 tp b8.nz faiserver
+$l.8 tp b8.nz
$l.9 bb8
$l.14 wrt3
2600:3c00::f03c:91ff:fe6d:baf8 li
# It has no sensitive info.
enable-tftp=br-lan
tftp-root=/mnt/usb/tftpboot
+dhcp-optsfile=/etc/dnsmasq-dhcpopts.conf
EOF
-uset network.lan.ipaddr $l.$lanip
-uset network.lan.netmask $mask
-if $dev2; then
- uset network.lan.gateway $l.1
- uset network.wan.proto none
- uset network.wan6.proto none
- /etc/init.d/dnsmasq stop
- /etc/init.d/dnsmasq disable
- /etc/init.d/odhcpd stop
- /etc/init.d/odhcpd disable
- # things i tried to keep dnsmasq running but not enabled except local dns,
- # but it didnt work right and i dont need it anyways.
- # uset dhcp.wan.ignore $dev2 # default is false
- # uset dhcp.lan.ignore $dev2 # default is false
- # uset dhcp.@dnsmasq[0].interface lo
- # uset dhcp.@dnsmasq[0].localuse 0
- # uset dhcp.@dnsmasq[0].resolvfile /etc/dnsmasq.conf
- # uset dhcp.@dnsmasq[0].noresolv 1
- # todo: populate /etc/resolv.conf with a static value
-else
- # these are the defaults
- uset network.lan.gateway ''
- uset network.wan.proto dhcp
- uset network.wan6.proto dhcpv6
- /etc/init.d/dnsmasq start
- # todo: figure out why this returns 1
- /etc/init.d/dnsmasq enable ||:
- /etc/init.d/odhcpd start
- /etc/init.d/odhcpd enable
-fi
-if $dnsmasq_restart; then
+if $dnsmasq_restart && ! $dev2; then
v /etc/init.d/dnsmasq restart
fi
fi
-
+# todo: we should catch errors and still run this if needed
if $network_restart; then
reboot
fi
-if $dropbear_restart; then
- v /etc/init.d/dropbear restart
-fi
exit 0