diff --git a/openwrt/.gitignore b/openwrt/.gitignore new file mode 100644 index 0000000..55a0f9b --- /dev/null +++ b/openwrt/.gitignore @@ -0,0 +1,2 @@ +*.rootpw +*.public_key diff --git a/openwrt/microuter-n300-firmware-upgrade.sh b/openwrt/microuter-n300-firmware-upgrade.sh new file mode 100755 index 0000000..ed1e21b --- /dev/null +++ b/openwrt/microuter-n300-firmware-upgrade.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# 2022-01-20, Nico Schottelius +# See https://ungleich.ch/u/products/device-ipv6-box/ + +if [ $# -ne 1 ]; then + echo "$0 address" + echo " address: connect to this address" + exit 1 +fi + +set -x + +device_ip=$1; shift + +# openwrt +version=21.02.0 +filename=openwrt-${version}-ramips-mt76x8-glinet_microuter-n300-squashfs-sysupgrade.bin + +# don't care about other/old known_host entries +ssh-keygen -R ${device_ip} + +while ! ping -c1 ${device_ip}; do + echo "Cannot ping $device_ip yet - waiting" + sleep 1 +done + +cat ~/.ssh/id_rsa.pub | ssh root@${device_ip} "cat > /etc/dropbear/authorized_keys" + +# Don't re-download if we already have it +wget -c http://downloads.openwrt.org/releases/${version}/targets/ramips/mt76x8/${filename} + +if echo $device_ip | grep -q :; then + scp_ip="[$device_ip]" +else + scp_ip="$device_ip" +fi + +scp ${filename} root@${scp_ip}:/tmp +ssh root@${device_ip} "sysupgrade -n /tmp/*.bin"