do the cleanup in the background

This commit is contained in:
James Swineson 2019-04-09 16:12:17 +08:00
parent 0193f37946
commit 0dd89ff33b

View file

@ -116,12 +116,16 @@ unmount_old_rootfs() {
umount "${OLDROOT}" umount "${OLDROOT}"
} }
# main procedure cleanup() {
set +x # some cleanup needed after the process quits
sleep 1
clear_processes
unmount_old_rootfs
}
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" echo "This script must be run as root"
exit 1 exit 1
fi fi
echo -e "We will start a temporary RAM system as your recovery environment." echo -e "We will start a temporary RAM system as your recovery environment."
@ -131,8 +135,6 @@ echo -e "\tYou have closed all programs you can, and backed up all important dat
echo -e "\tYou can SSH into your system as root user" echo -e "\tYou can SSH into your system as root user"
confirm || exit -1 confirm || exit -1
set -x
sync_filesystem sync_filesystem
prepare_environment prepare_environment
@ -141,15 +143,9 @@ copy_config
install_software install_software
swap_root swap_root
set +x
echo -e "If you are connecting from SSH, please create a second session to this host and confirm you can get a shell." echo -e "If you are connecting from SSH, please create a second session to this host and confirm you can get a shell."
echo -e "After your confirmation, we are going to kill the old SSH server." echo -e "After your confirmation, we are going to kill the old SSH server."
confirm || exit -1 confirm || exit -1
set -x cleanup &
disown
clear_processes
unmount_old_rootfs
set +x