openwrt/viirb monitor: update bootstrapping

This commit is contained in:
Nico Schottelius 2024-08-14 09:46:06 +02:00
parent 98f168c2d2
commit 08163641c1

View file

@ -8,14 +8,18 @@
# - monitor UPS via USB
if [ $# -lt 8 ] ; then
echo $0 "address hostname wifi-ssid wifi-psk"
echo $0 "address hostname passwd wifi-ssid wifi-psk"
fi
address=$1; shift
hostname=$1; shift
root_password=$1; shift
wifi_ssid=$1; shift
wifi_psk=$1; shift
# Allow passwordless to avoid nightmare
cat ~/.ssh/id_rsa.pub | ssh root@${address} "cat > /etc/dropbear/authorized_keys"
cat <<EOF | ssh -t "root@${address}"
set -x
opkg update
@ -33,45 +37,52 @@ uci delete network.lan.ip6assign
# uci set firewall.@defaults[0].input=ACCEPT
# uci set firewall.@defaults[0].forward=ACCEPT
# Set hostname
uci set system.@system[0].hostname="${hostname}"
# Make LAN IPv6 dynamic
uci delete network.lan.ipaddr
uci delete network.lan.netmask
uci delete network.lan.gateway
uci set network.lan.proto="dhcpv6"
#uci delete network.lan.ipaddr
#uci delete network.lan.netmask
#uci delete network.lan.gateway
#uci set network.lan.proto="dhcpv6"
# Need to remove ipv6 source based routing - leads to route not working
uci set network.lan.sourcefilter=0
#uci set network.lan.sourcefilter=0
# Disable DHCP on LAN
# Disable DHCP/RA on LAN
uci delete dhcp.lan.dhcpv4
uci delete dhcp.lan.dhcpv6
uci delete dhcp.lan.ra
uci set dhcp.lan.ignore=1
uci set wireless.default_radio0.mode='sta'
uci set wireless.default_radio0.ssid='${wifi_ssid}'
uci set wireless.default_radio0.encryption='psk2'
uci set wireless.default_radio0.key='${wifi_psk}'
# Base wifi settings
uci set wireless.radio0.htmode='HT40'
uci set wireless.radio0.channel='auto'
# Remove old AP entry
uci delete wireless.default_radio0
uci set network.wwan.proto='dhcpv6'
uci set network.wwan.device='phy0-sta0'
# Create device for wifi
uci set network.wwan=interface
uci set network.wwan.proto=dhcpv6
uci set network.wwan.device=phy0-sta0
# Create wireless entry for wifi
uci set wireless.wifinet1=wifi-iface
uci set wireless.wifinet1.device='radio0'
uci set wireless.wifinet1.mode='sta'
uci set wireless.wifinet1.network='wwan'
uci set wireless.wifinet1.ssid='${wifi_ssid}'
uci set wireless.wifinet1.encryption='psk2'
uci set wireless.wifinet1.key='${wifi_psk}'
uci delete wireless.radio0.disabled
uci commit
# TODO: Do something wireless (?), maybe disable?
printf "${root_password}\n${root_password}\n" | passwd
uci commit
/etc/init.d/bird restart
EOF
echo "Restart router to restart firewall, network, dhcp"