2020-12-11 15:05:29 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# 2020-06-13, Nico Schottelius
|
|
|
|
# See https://ungleich.ch/u/products/viirb-ipv6-box/
|
|
|
|
|
2021-01-05 13:05:16 +00:00
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo "$0 address"
|
2020-12-11 15:05:29 +00:00
|
|
|
echo " address: connect to this address, ignore the interface"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-07-19 19:52:51 +00:00
|
|
|
set -e
|
2020-12-11 15:05:29 +00:00
|
|
|
set -x
|
|
|
|
|
2021-01-05 13:05:16 +00:00
|
|
|
viwib_ip=$1; shift
|
2020-12-11 15:05:29 +00:00
|
|
|
|
|
|
|
# openwrt
|
2021-04-18 13:06:51 +00:00
|
|
|
version=19.07.7
|
2020-12-11 15:05:29 +00:00
|
|
|
filename=openwrt-${version}-ramips-mt76x8-gl-mt300n-v2-squashfs-sysupgrade.bin
|
|
|
|
|
|
|
|
# don't care about other/old known_host entries
|
|
|
|
ssh-keygen -R ${viwib_ip}
|
|
|
|
|
|
|
|
while ! ping -c1 ${viwib_ip}; do
|
|
|
|
echo "Cannot ping $viwib_ip yet - waiting"
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
cat ~/.ssh/id_rsa.pub | ssh root@${viwib_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 $viwib_ip | grep -q :; then
|
|
|
|
scp_ip="[$viwib_ip]"
|
|
|
|
else
|
|
|
|
scp_ip="$viwib_ip"
|
|
|
|
fi
|
|
|
|
|
|
|
|
scp ${filename} root@${scp_ip}:/tmp
|
|
|
|
ssh root@${viwib_ip} "sysupgrade -n /tmp/*.bin"
|
|
|
|
|
|
|
|
# It still pings for some time - wait for the reboot to happen
|
|
|
|
echo "Waiting for viwib to really disappear"
|
|
|
|
sleep 15
|
|
|
|
|
|
|
|
wait=0
|
|
|
|
found=""
|
|
|
|
|
|
|
|
while [ $wait -lt 180 ]; do
|
|
|
|
ping -c1 ${viwib_ip} >/dev/null
|
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
found=yes
|
|
|
|
# wait for ssh to come up
|
|
|
|
sleep 10
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
wait=$((wait+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! "$found" ]; then
|
|
|
|
echo "Did not find updated viwib - debug / restart it"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "viwib successfully updated to ${version}"
|