ungleich-tools/openwrt/microuter-n300-firmware-upgrade.sh

39 lines
924 B
Bash
Executable file

#!/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"