Gluon Upgrade/Flash Script

Verwendung

bash flash.sh <ip> <gerät> <channel> [<sysupgrade parameter...>]

z.B. für einen vollen re-flash und reset eines lokalen knotens

bash flash.sh 192.168.1.122 cpe210-v3 experimental -a

set -euo pipefail

target="$1"
type="$2"
channel="$3"
shift 3

TMP="/tmp/ffgraz"

i() {
  tput bold
  echo "[*] $*"
  tput init
}

mkdir -p "$TMP"
cd "$TMP"

tput setaf 8 && i "resolve $type..."

IMG=$(curl -s "https://ffgraz.mkg20001.io/$channel/images/sysupgrade/" | grep "$type" | grep -o 'href=".*"' | grep -o 'gluon.*[^"]')

if [ ! -e "$IMG.ok" ]; then
  i "dl $IMG"
  curl -# "https://ffgraz.mkg20001.io/$channel/images/sysupgrade/$IMG" -o "$IMG"
  touch "$IMG.ok"
else
  tput setaf 8 && i "cached $IMG"
fi

i "copy $IMG to $target..."
scp -O -o StrictHostKeyChecking=no "$IMG" "root@$target:/tmp/fw.bin"

tput setaf 1 && i "sysupgrade $*@$target..."
ssh "root@$target" -o StrictHostKeyChecking=no sysupgrade "$@" -v /tmp/fw.bin # -n -> disable keeping config