viirb: flash latest firmware
This commit is contained in:
parent
c803679610
commit
608771dc25
1 changed files with 69 additions and 0 deletions
69
viirb-connect-flash-latest-openwrt.sh
Executable file
69
viirb-connect-flash-latest-openwrt.sh
Executable file
|
@ -0,0 +1,69 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# 2020-06-13, Nico Schottelius
|
||||||
|
# See https://ungleich.ch/u/products/viirb-ipv6-box/
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "$0 interface"
|
||||||
|
echo " interface to add the config ip address to"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
|
dev=$1; shift
|
||||||
|
id=$1; shift
|
||||||
|
dot_cdist=$1; shift
|
||||||
|
owner=$1; shift
|
||||||
|
|
||||||
|
# openwrt
|
||||||
|
version=19.07.3
|
||||||
|
filename=openwrt-${version}-ramips-mt76x8-vocore2-squashfs-sysupgrade.bin
|
||||||
|
|
||||||
|
# IP address for setting it up initially
|
||||||
|
viirb_ip=192.168.61.1
|
||||||
|
|
||||||
|
sudo ip addr del 192.168.61.2/24 dev "$dev" 2>/dev/null || true
|
||||||
|
sudo ip addr add 192.168.61.2/24 dev "$dev"
|
||||||
|
|
||||||
|
# don't care about other/old known_host entries
|
||||||
|
ssh-keygen -R ${viirb_ip}
|
||||||
|
|
||||||
|
ping -c2 ${viirb_ip}
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Cannot reach any VIIRB - exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat ~/.ssh/id_rsa.pub | ssh root@${viirb_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}
|
||||||
|
scp ${filename} root@${viirb_ip}:/tmp
|
||||||
|
ssh root@${viirb_ip} "sysupgrade /tmp/*.bin"
|
||||||
|
|
||||||
|
# It still pings for some time - wait for the reboot to happen
|
||||||
|
echo "Waiting for VIIRB to disappear"
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
wait=0
|
||||||
|
found=""
|
||||||
|
|
||||||
|
while [ $wait -lt 180 ]; do
|
||||||
|
ping -c1 ${viirb_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 viirb - debug / restart it"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "VIIRB successfully updated to ${version}"
|
Loading…
Reference in a new issue