mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
iopupgrade: Add interactive mode.
This commit is contained in:
parent
28b3715da2
commit
ebd13be2c5
1 changed files with 192 additions and 7 deletions
|
|
@ -13,6 +13,7 @@ function upd_usage {
|
|||
echo " -c Keep configuration"
|
||||
echo " -x Force install even if firmware is not for this board"
|
||||
echo " -b Force install of bootloader regardless of version installed"
|
||||
echo " -s Use sysupgade. old upgrade method"
|
||||
}
|
||||
|
||||
function set_config_string {
|
||||
|
|
@ -28,19 +29,194 @@ function upd_ask_ok {
|
|||
printf "%20s: " "Keep config"; if [ "$upd_keepconf" == "1" ] ;then printf "Yes\n" ;else printf "No\n";fi
|
||||
printf "%20s: " "Force bootloader"; if [ "$upd_forceboot" == "1" ] ;then printf "Yes\n" ;else printf "No\n";fi
|
||||
printf "%20s: " "Force image upgrade"; if [ "$upd_forceimage" == "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 -n "Continue? [Y/n]:"
|
||||
echo -n "Continue? [Y/n/q]:"
|
||||
read answer
|
||||
|
||||
case $answer in
|
||||
n|N)
|
||||
return 1;;
|
||||
q|Q)
|
||||
exit 1;;
|
||||
y|Y|*)
|
||||
return 0;;
|
||||
esac
|
||||
}
|
||||
|
||||
function upd_select_file {
|
||||
|
||||
dialog --keep-tite --title "To select file use TAB/ARROW to hilight then press SPACEBAR -> RETURN" \
|
||||
--fselect "bin/targets/$CONFIG_TARGET_BOARD/generic/" \
|
||||
$((lines -10)) $((cols -5)) \
|
||||
2> $tempfile
|
||||
|
||||
new_file=$(cat $tempfile)
|
||||
if [ -n "$new_file" ]
|
||||
then
|
||||
upd_fw="$new_file"
|
||||
upd_fw_base=$(basename $upd_fw);
|
||||
fi
|
||||
}
|
||||
|
||||
function upd_select_target {
|
||||
|
||||
dialog --keep-tite --title "Input the name/ip number of target board" \
|
||||
--inputbox "Name/IP" \
|
||||
$((lines -10)) $((cols -5)) \
|
||||
"$upd_host" \
|
||||
2> $tempfile
|
||||
|
||||
new_file=$(cat $tempfile)
|
||||
if [ -n "$new_file" ]
|
||||
then
|
||||
upd_host="$new_file"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function upd_select_reboot {
|
||||
dialog --keep-tite --radiolist "Should the board reboot after download finished" \
|
||||
$((lines -5)) $((cols -5)) $((lines -5 -5)) \
|
||||
"Reboot" "Restart board after done" `if [ "$upd_noreboot" == "0" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
"No reboot" "Continue running old system" `if [ "$upd_noreboot" == "1" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
2> $tempfile
|
||||
|
||||
res=$(cat $tempfile)
|
||||
case $res in
|
||||
"No reboot")
|
||||
upd_noreboot=1
|
||||
;;
|
||||
"Reboot")
|
||||
upd_noreboot=0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function upd_select_config {
|
||||
dialog --keep-tite --radiolist "Should the configuration be keept" \
|
||||
$((lines -5)) $((cols -5)) $((lines -5 -5)) \
|
||||
"Keep" "Keep the config from old system" `if [ "$upd_keepconf" == "1" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
"Default" "Use default config for new system" `if [ "$upd_keepconf" == "0" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
2> $tempfile
|
||||
|
||||
res=$(cat $tempfile)
|
||||
case $res in
|
||||
"Keep")
|
||||
upd_keepconf=1
|
||||
;;
|
||||
"Default")
|
||||
upd_keepconf=0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function upd_select_forceboot {
|
||||
dialog --keep-tite --radiolist "Should the boot loader be updated reagardless of version installed" \
|
||||
$((lines -5)) $((cols -5)) $((lines -5 -5)) \
|
||||
"Force" "Alwasy update boot loader" `if [ "$upd_forceboot" == "1" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
"Version check" "Only upgrade if version is newer" `if [ "$upd_forceboot" == "0" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
2> $tempfile
|
||||
|
||||
res=$(cat $tempfile)
|
||||
case $res in
|
||||
"Force")
|
||||
upd_forceboot=1
|
||||
;;
|
||||
"Version check")
|
||||
upd_forceboot=0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function upd_select_forceimage {
|
||||
dialog --keep-tite --radiolist "Should the image be stored in flash even if sanity checks would reject it" \
|
||||
$((lines -5)) $((cols -5)) $((lines -5 -5)) \
|
||||
"Force" "Dissable sanity check and force use of image (dangerous)" `if [ "$upd_forceimage" == "1" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
"Only compatible" "Normal checks apply" `if [ "$upd_forceimage" == "0" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
2> $tempfile
|
||||
|
||||
res=$(cat $tempfile)
|
||||
case $res in
|
||||
"Force")
|
||||
upd_forceimage=1
|
||||
;;
|
||||
"Only compatible")
|
||||
upd_forceimage=0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function upd_select_sysupgrade {
|
||||
dialog --keep-tite --radiolist "Use the old way to upgrade a board" \
|
||||
$((lines -5)) $((cols -5)) $((lines -5 -5)) \
|
||||
"iopu" "Use the iop upgrade methode" `if [ "$upd_sysupgrade" == "0" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
"sysupgrade" "Use the old sysupgrade methode" `if [ "$upd_sysupgrade" == "1" ] ;then echo "ON" ;else echo "OFF";fi` \
|
||||
2> $tempfile
|
||||
|
||||
res=$(cat $tempfile)
|
||||
case $res in
|
||||
"iopu")
|
||||
upd_sysupgrade=0
|
||||
;;
|
||||
"sysupgrade")
|
||||
upd_sysupgrade=1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function upd_select {
|
||||
|
||||
dialog --keep-tite --ok-label "Select" --cancel-label "Done" --menu "Select Item to change" \
|
||||
$((lines -5)) $((cols -5)) $((lines -5 -5)) \
|
||||
"Firmare file" "$upd_fw_base"\
|
||||
"Host ip" "$upd_host" \
|
||||
"Reboot" `if [ "$upd_noreboot" == "0" ] ;then printf "Yes\n" ;else printf "No\n";fi` \
|
||||
"Keep config" `if [ "$upd_keepconf" == "1" ] ;then printf "Yes\n" ;else printf "No\n";fi` \
|
||||
"Force bootloader" `if [ "$upd_forceboot" == "1" ] ;then printf "Yes\n" ;else printf "No\n";fi` \
|
||||
"Force image upgrade" `if [ "$upd_forceimage" == "1" ] ;then printf "Yes\n" ;else printf "No\n";fi` \
|
||||
"sysupgrade" `if [ "$upd_sysupgrade" == "1" ] ;then printf "Yes\n" ;else printf "No\n";fi` \
|
||||
2> $tempfile
|
||||
|
||||
|
||||
case $(cat $tempfile) in
|
||||
"Firmare file")
|
||||
upd_select_file
|
||||
;;
|
||||
"Host ip")
|
||||
upd_select_target
|
||||
;;
|
||||
"Reboot")
|
||||
upd_select_reboot
|
||||
;;
|
||||
"Keep config")
|
||||
upd_select_config
|
||||
;;
|
||||
"Force bootloader")
|
||||
upd_select_forceboot
|
||||
;;
|
||||
"Force image upgrade")
|
||||
upd_select_forceimage
|
||||
;;
|
||||
"sysupgrade")
|
||||
upd_select_sysupgrade
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
upd_select
|
||||
}
|
||||
function upd_select_start {
|
||||
lines=$(tput lines)
|
||||
cols=$(tput cols)
|
||||
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
|
||||
trap "rm -f $tempfile" 0 1 2 5 15
|
||||
upd_select
|
||||
|
||||
}
|
||||
|
||||
function ssh_upgrade {
|
||||
upd_noreboot=0
|
||||
upd_forceboot=0
|
||||
|
|
@ -49,8 +225,10 @@ function ssh_upgrade {
|
|||
upd_fw_base=""
|
||||
upd_fw=""
|
||||
upd_host="192.168.1.1"
|
||||
upd_sysupgrade=0
|
||||
do_dialog=0
|
||||
|
||||
while getopts "f:hnxt:i" opt; do
|
||||
while getopts "f:hnxt:is" opt; do
|
||||
case $opt in
|
||||
n)
|
||||
upd_noreboot=1
|
||||
|
|
@ -75,8 +253,10 @@ function ssh_upgrade {
|
|||
upd_host=$OPTARG
|
||||
;;
|
||||
i)
|
||||
echo "not supported"
|
||||
return
|
||||
do_dialog=1
|
||||
;;
|
||||
s)
|
||||
upd_sysupgrade=1
|
||||
;;
|
||||
h)
|
||||
upd_usage
|
||||
|
|
@ -104,10 +284,15 @@ function ssh_upgrade {
|
|||
upd_fw="bin/targets/$CONFIG_TARGET_BOARD/generic/$upd_fw_base"
|
||||
fi
|
||||
|
||||
[ $do_dialog -eq 1 ] && upd_select_start
|
||||
|
||||
if ! upd_ask_ok
|
||||
then
|
||||
echo "Aborting"
|
||||
exit 1
|
||||
upd_select_start
|
||||
if ! upd_ask_ok
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f $upd_fw ]
|
||||
|
|
@ -118,7 +303,7 @@ function ssh_upgrade {
|
|||
file_size_kb=`du -k "$upd_fw" | cut -f1`
|
||||
|
||||
|
||||
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@192.168.1.1 iopu
|
||||
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@192.168.1.1 iopu
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue