@@ -305,7 +305,7 @@ query_version() {
305305 latest_version=" $(
306306 curl -fsSL \
307307 ${kernel_api} /releases/expanded_assets/kernel_${KERNEL_TAGS} |
308- grep -oE " ${kernel_verpatch} .[0-9]+.tar.gz" | sed ' s/.tar.gz//' |
308+ grep -oE " ${kernel_verpatch} .[0-9]+.*. tar.gz" | sed ' s/.tar.gz//' |
309309 sort -urV | head -n 1
310310 ) "
311311 [[ -n " ${latest_version} " ]] || error_msg " Failed to query kernel version from [ ${kernel_api} ]."
@@ -686,9 +686,9 @@ sos_kernel() {
686686 echo -e " ${INFO} The current Armbian is running on [ /dev/${DISK_NAME} ], and the target disk for restoration is [ ${rescue_disk} ]."
687687
688688 # Create a temporary mount directory
689- umount ${rescue_path} /bootfs 2> /dev/null
690- umount ${rescue_path} /rootfs 2> /dev/null
691- rm -rf ${rescue_path}
689+ umount -f ${rescue_path} /bootfs 2> /dev/null
690+ umount -f ${rescue_path} /rootfs 2> /dev/null
691+ rm -rf ${rescue_path} 2> /dev/null
692692 mkdir -p ${rescue_path} /{bootfs/,rootfs/} && sync
693693 [[ " ${?} " -ne " 0" ]] && error_msg " Failed to create temporary mount directory [ ${rescue_path} ]"
694694
@@ -703,7 +703,7 @@ sos_kernel() {
703703 kernel_signature=" $( uname -r) "
704704
705705 # 01. For /boot files
706- [[ -d " ${rescue_path} /bootfs" ]] && {
706+ if [[ -d " ${rescue_path} /bootfs" ]]; then
707707 cd ${rescue_path} /bootfs
708708 rm -rf config-* initrd.img-* System.map-* vmlinuz-* uInitrd* * Image dtb* u-boot.ext u-boot.emmc
709709 [[ -f " /boot/u-boot.ext" ]] && {
@@ -736,32 +736,36 @@ sos_kernel() {
736736 # Adjust the initrd_addr value to 0x15000000
737737 [[ -f " boot.ini" ]] && sed -i " s|^setenv initrd_addr.*|setenv initrd_addr 0x15000000|g" boot.ini
738738 [[ -f " boot-emmc.ini" ]] && sed -i " s|^setenv initrd_addr.*|setenv initrd_addr 0x15000000|g" boot-emmc.ini
739- } || error_msg " (1/3) The [ ${rescue_path} /bootfs ] folder does not exist, stop rescuing."
739+ else
740+ error_msg " (1/3) The [ ${rescue_path} /bootfs ] folder does not exist, stop rescuing."
741+ fi
740742
741743 # 02. For /usr/lib/modules/${kernel_signature}
742- [[ -d " ${rescue_path} /rootfs/usr/lib/modules" ]] && {
744+ if [[ -d " ${rescue_path} /rootfs/usr/lib/modules" ]]; then
743745 cd ${rescue_path} /rootfs/usr/lib/modules
744746 rm -rf *
745747 cp -rf /usr/lib/modules/${kernel_signature} -t .
746748 [[ " ${?} " -ne " 0" ]] && error_msg " (2/3) [ modules ] kernel files rescue failed."
747749 echo -e " ${INFO} (2/3) [ modules ] kernel files rescue succeeded."
748- } || error_msg " (2/3) The [ ${rescue_path} /rootfs/usr/lib/modules ] folder does not exist, stop rescuing."
750+ else
751+ error_msg " (2/3) The [ ${rescue_path} /rootfs/usr/lib/modules ] folder does not exist, stop rescuing."
752+ fi
749753
750754 # 03. For /usr/src/linux-headers-${kernel_signature}
751- [[ -d " /usr/src/linux-headers-${kernel_signature} " ]] && {
755+ if [[ -d " /usr/src/linux-headers-${kernel_signature} " ]]; then
752756 cd ${rescue_path} /rootfs/usr/src
753757 rm -rf linux-headers-*
754758 cp -rf /usr/src/linux-headers-${kernel_signature} -t .
755759 [[ " ${?} " -ne " 0" ]] && error_msg " (3/3) [ headers ] kernel files rescue failed."
756760 echo -e " ${INFO} (3/3) [ headers ] kernel files rescue succeeded."
757- } || echo -e " ${PROMPT} (3/3) [ /usr/src/linux-headers-${kernel_signature} ] folder does not exist, skip rescue."
761+ else
762+ echo -e " ${PROMPT} (3/3) [ /usr/src/linux-headers-${kernel_signature} ] folder does not exist, skip rescue."
763+ fi
758764
759765 # Unmount the emmc partition
760766 cd ${rescue_path}
761- umount -f ${rescue_path} /bootfs
762- [[ " ${?} " -ne " 0" ]] && error_msg " Failed to umount [ ${rescue_path} /bootfs ]"
763- umount -f ${rescue_path} /rootfs
764- [[ " ${?} " -ne " 0" ]] && error_msg " Failed to umount [ ${rescue_path} /rootfs ]"
767+ umount -f ${rescue_path} /bootfs 2> /dev/null
768+ umount -f ${rescue_path} /rootfs 2> /dev/null
765769
766770 sync && echo " "
767771}
0 commit comments