iop upgrade: add sysupgrade option.

Needed to be able to update old boards.
This commit is contained in:
Kenneth Johansson 2019-01-14 15:22:07 +01:00
parent ebd13be2c5
commit c2776532c5

View file

@ -13,7 +13,7 @@ function upd_usage {
echo " -c Keep configuration" echo " -c Keep configuration"
echo " -x Force install even if firmware is not for this board" echo " -x Force install even if firmware is not for this board"
echo " -b Force install of bootloader regardless of version installed" echo " -b Force install of bootloader regardless of version installed"
echo " -s Use sysupgade. old upgrade method" echo " -s Use sysupgade. old upgrade method, needed for old releases that do not have iopu"
} }
function set_config_string { function set_config_string {
@ -32,6 +32,11 @@ function upd_ask_ok {
printf "%20s: " "Use sysupgrade"; if [ "$upd_sysupgrade" == "1" ] ;then printf "Yes\n" ;else printf "No\n";fi printf "%20s: " "Use sysupgrade"; if [ "$upd_sysupgrade" == "1" ] ;then printf "Yes\n" ;else printf "No\n";fi
echo "-----------------------------------------" echo "-----------------------------------------"
if [ "$upd_sysupgrade" == "0" ]
then
if [ "$upd_keepconf" == "1" ] ;then echo "keeping config is just a fantasy it's not yet implemented, try sysupgrade";fi
fi
echo -n "Continue? [Y/n/q]:" echo -n "Continue? [Y/n/q]:"
read answer read answer
@ -228,7 +233,7 @@ function ssh_upgrade {
upd_sysupgrade=0 upd_sysupgrade=0
do_dialog=0 do_dialog=0
while getopts "f:hnxt:is" opt; do while getopts "f:hnxt:isc" opt; do
case $opt in case $opt in
n) n)
upd_noreboot=1 upd_noreboot=1
@ -241,7 +246,6 @@ function ssh_upgrade {
;; ;;
c) c)
upd_keepconf=1 upd_keepconf=1
upd_keepconf=0 # not yet supported
;; ;;
v) v)
verbose=$OPTARG verbose=$OPTARG
@ -300,11 +304,16 @@ function ssh_upgrade {
echo "firmware file $firmware do not exist" echo "firmware file $firmware do not exist"
exit 1 exit 1
fi fi
file_size_kb=`du -k "$upd_fw" | cut -f1`
if [ $upd_sysupgrade -eq 0 ]
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@192.168.1.1 iopu then
exit 0 file_size_kb=`du -k "$upd_fw" | cut -f1`
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@$upd_host iopu
else
scp $upd_fw root@$upd_host:/tmp/ &&
ssh -o ConnectTimeout=60 root@$upd_host "sysupgrade -v $3 /tmp/$upd_fw_base" &&
echo "sysupgrade done!"
fi
} }
register_command "ssh_upgrade" "-h <host> -f <file> [opts] Install firmware on remote host with SSH" register_command "ssh_upgrade" "-h <host> -f <file> [opts] Install firmware on remote host with SSH"