mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
iop upgrade: add handling of no reboot option.
This commit is contained in:
parent
8a83899eba
commit
4fa352c5fc
3 changed files with 70 additions and 43 deletions
|
|
@ -307,8 +307,11 @@ function ssh_upgrade {
|
||||||
|
|
||||||
if [ $upd_sysupgrade -eq 0 ]
|
if [ $upd_sysupgrade -eq 0 ]
|
||||||
then
|
then
|
||||||
file_size_kb=`du -k "$upd_fw" | cut -f1`
|
extra_args=""
|
||||||
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@$upd_host iopu
|
[ $upd_noreboot -eq 1 ] && extra_args="$extra_args -n"
|
||||||
|
|
||||||
|
file_size_kb=`du -k "$upd_fw" | cut -f1`
|
||||||
|
cat $upd_fw | pv -s ${file_size_kb}k | ssh root@$upd_host "iopu $extra_args"
|
||||||
else
|
else
|
||||||
scp $upd_fw root@$upd_host:/tmp/ &&
|
scp $upd_fw root@$upd_host:/tmp/ &&
|
||||||
ssh -o ConnectTimeout=60 root@$upd_host "sysupgrade -v $3 /tmp/$upd_fw_base" &&
|
ssh -o ConnectTimeout=60 root@$upd_host "sysupgrade -v $3 /tmp/$upd_fw_base" &&
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,26 @@
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Global variables. can be used directly in any function called.
|
# Global variables. can be used directly in any function called.
|
||||||
cur_vol="" # num,[0/1] Number used for ubifs root filesystem volume name. eg: rootfs_0 or rootfs_1, currently used
|
cur_vol="" # num,[0/1] Number used for ubifs root filesystem volume name.
|
||||||
upd_vol="" # num,[0/1] Number used for ubifs root filesystem volume name. eg: rootfs_0 or rootfs_1, the one we want to update
|
# eg: rootfs_0 or rootfs_1, currently used
|
||||||
|
upd_vol="" # num,[0/1] Number used for ubifs root filesystem volume name.
|
||||||
|
# eg: rootfs_0 or rootfs_1, the one we want to update
|
||||||
cmdline="" # optional command line settings. for cfe and kernel that is not on every board.
|
cmdline="" # optional command line settings. for cfe and kernel that is not on every board.
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# file local variables. should not be used in imported functions. Can be used by functions declared in this script
|
# file local variables. should not be used in imported functions. Can be used
|
||||||
board="" # string, Board name that is going to be matched against header of firmware image
|
# by functions declared in this script
|
||||||
upd_ubi_id="" # num, UBI volume number for the volume name "rootfs_$upd_vol", use to know what volume to run ubiupdatevol on.
|
board="" # string, Board name that is going to be matched
|
||||||
|
# against header of firmware image
|
||||||
|
upd_ubi_id="" # num, UBI volume number for the volume name
|
||||||
|
# "rootfs_$upd_vol", use to know what volume to run
|
||||||
|
# ubiupdatevol on.
|
||||||
run_cleanup=0 # if set the cleanup should be run otherwise we skip it.
|
run_cleanup=0 # if set the cleanup should be run otherwise we skip it.
|
||||||
run_mount_cleanup=0 # set if we should run umount in cleanup
|
run_mount_cleanup=0 # set if we should run umount in cleanup
|
||||||
upd_kernel=0 # set to 1 if system has the kernel in own mtd partition
|
upd_kernel=0 # set to 1 if system has the kernel in own mtd partition
|
||||||
upd_cfe=0 # set to 1 if system is using cfe as bootloader.
|
upd_cfe=0 # set to 1 if system is using cfe as bootloader.
|
||||||
log_stdout=1 # set to 0 to prevent the log to also print to stdout
|
log_stdout=1 # set to 0 to prevent the log to also print to stdout
|
||||||
|
upd_noreboot=0 # set to 1 if we should not reboot after programming
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# import external functions
|
# import external functions
|
||||||
source /lib/upgrade/iopsys.sh
|
source /lib/upgrade/iopsys.sh
|
||||||
|
|
@ -58,6 +64,7 @@ function finish {
|
||||||
|
|
||||||
lock -u /tmp/iopu.lock
|
lock -u /tmp/iopu.lock
|
||||||
}
|
}
|
||||||
|
|
||||||
function sig_pipe {
|
function sig_pipe {
|
||||||
log_stdout=0 # stdin,stdout,stderr do not exist anymore
|
log_stdout=0 # stdin,stdout,stderr do not exist anymore
|
||||||
log "Got sigpipe. Turning of log printing to stdout"
|
log "Got sigpipe. Turning of log printing to stdout"
|
||||||
|
|
@ -69,28 +76,6 @@ function timeout {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# just one instance
|
|
||||||
# this check has to be done before we install handler to avoid removing the lock even if it was not available.
|
|
||||||
if ! lock -n /tmp/iopu.lock
|
|
||||||
then
|
|
||||||
echo "Another instance of iopu already running"
|
|
||||||
echo "If you are sure this is wrong remove file /tmp/iopu.lock"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
trap finish EXIT
|
|
||||||
trap timeout SIGALRM
|
|
||||||
trap sig_pipe SIGPIPE
|
|
||||||
|
|
||||||
# put a timeout on this if it takes longer than 60 seconds we should abort and clean up
|
|
||||||
(
|
|
||||||
sleep 120 # if 2 minutes pass
|
|
||||||
kill -ALRM $$ 2>/dev/null # send it a SIGALRM signal
|
|
||||||
)&
|
|
||||||
TIMEOUT_PID=$!
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
function mount_newroot {
|
function mount_newroot {
|
||||||
run_mount_cleanup=1
|
run_mount_cleanup=1
|
||||||
mkdir -p /tmp/newroot
|
mkdir -p /tmp/newroot
|
||||||
|
|
@ -124,6 +109,38 @@ function umount_newroot {
|
||||||
umount /tmp/newroot
|
umount /tmp/newroot
|
||||||
run_mount_cleanup=0
|
run_mount_cleanup=0
|
||||||
}
|
}
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
# just one instance
|
||||||
|
# this check has to be done before we install handler to avoid removing the lock even if it was not available.
|
||||||
|
if ! lock -n /tmp/iopu.lock
|
||||||
|
then
|
||||||
|
echo "Another instance of iopu already running"
|
||||||
|
echo "If you are sure this is wrong remove file /tmp/iopu.lock"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
trap finish EXIT
|
||||||
|
trap timeout SIGALRM
|
||||||
|
trap sig_pipe SIGPIPE
|
||||||
|
|
||||||
|
# put a timeout on this if it takes longer than 120 seconds we should abort and clean up
|
||||||
|
(
|
||||||
|
sleep 120 # if 2 minutes pass
|
||||||
|
kill -ALRM $$ 2>/dev/null # send it a SIGALRM signal
|
||||||
|
)&
|
||||||
|
TIMEOUT_PID=$!
|
||||||
|
|
||||||
|
|
||||||
|
while getopts "n" opt; do
|
||||||
|
case $opt in
|
||||||
|
n)
|
||||||
|
upd_noreboot=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
log "Firmware upgrade started"
|
log "Firmware upgrade started"
|
||||||
|
|
||||||
|
|
@ -134,8 +151,6 @@ board=$(db get hw.board.iopVerBoard)
|
||||||
cur_vol=$(get_flashbank_current)
|
cur_vol=$(get_flashbank_current)
|
||||||
upd_vol=$(get_flashbank_next)
|
upd_vol=$(get_flashbank_next)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# convert volume name "rootfs_$upd_vol" into ubifs volume id
|
# convert volume name "rootfs_$upd_vol" into ubifs volume id
|
||||||
upd_ubi_id=$(ubinfo -d 0 -N rootfs_$upd_vol | awk "/Volume ID:/ {print \$3}")
|
upd_ubi_id=$(ubinfo -d 0 -N rootfs_$upd_vol | awk "/Volume ID:/ {print \$3}")
|
||||||
log "installing Root Fileystem into UBI volume rootfs_$upd_vol"
|
log "installing Root Fileystem into UBI volume rootfs_$upd_vol"
|
||||||
|
|
@ -161,7 +176,7 @@ log "Firmware programmed to flash."
|
||||||
|
|
||||||
log "Transfering configuration to new system."
|
log "Transfering configuration to new system."
|
||||||
mount_newroot
|
mount_newroot
|
||||||
chroot /tmp/newroot_overlay /bin/true
|
chroot /tmp/newroot_overlay /sbin/iopu_chroot
|
||||||
umount_newroot
|
umount_newroot
|
||||||
|
|
||||||
log "Update fully installed."
|
log "Update fully installed."
|
||||||
|
|
@ -171,16 +186,22 @@ run_cleanup=0
|
||||||
upd_finnish
|
upd_finnish
|
||||||
|
|
||||||
# spawn the reboot to a subshell to allow the main program to quit before reset to avoid any hanged network connection like ssh
|
# spawn the reboot to a subshell to allow the main program to quit before reset to avoid any hanged network connection like ssh
|
||||||
(
|
if [ $upd_noreboot -eq 0 ]
|
||||||
log_stdout=0 # stdin,stdout,stderr do not exist anymore, we are in a subshell and then the trap is no longer working.
|
then
|
||||||
|
(
|
||||||
sleep 1
|
log_stdout=0 # stdin,stdout,stderr do not exist anymore, we are in a
|
||||||
log "Rebooting NOW!!!"
|
# subshell and then the trap is no longer working.
|
||||||
log ""
|
sleep 1
|
||||||
reboot
|
log "Rebooting NOW!!!"
|
||||||
)&
|
log ""
|
||||||
|
reboot
|
||||||
log "Reboot initiated"
|
)&
|
||||||
|
log "Reboot initiated"
|
||||||
|
else
|
||||||
|
log "Skipping reboot"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
3
iopupgrade/files/sbin/iopu_chroot
Executable file
3
iopupgrade/files/sbin/iopu_chroot
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "now we run in chroot"
|
||||||
Loading…
Add table
Reference in a new issue