From 0dd89ff33be41f316c5a560a83c4aa542b3a4394 Mon Sep 17 00:00:00 2001 From: James Swineson Date: Tue, 9 Apr 2019 16:12:17 +0800 Subject: [PATCH] do the cleanup in the background --- menhera.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/menhera.sh b/menhera.sh index dcb95d0..09e12ec 100755 --- a/menhera.sh +++ b/menhera.sh @@ -116,12 +116,16 @@ unmount_old_rootfs() { umount "${OLDROOT}" } -# main procedure -set +x +cleanup() { + # some cleanup needed after the process quits + sleep 1 + clear_processes + unmount_old_rootfs +} if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" - exit 1 + echo "This script must be run as root" + exit 1 fi 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" confirm || exit -1 -set -x - sync_filesystem prepare_environment @@ -141,15 +143,9 @@ copy_config install_software 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 "After your confirmation, we are going to kill the old SSH server." confirm || exit -1 -set -x - -clear_processes -unmount_old_rootfs - -set +x \ No newline at end of file +cleanup & +disown \ No newline at end of file