Skip to content

Unmount before exit #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,34 @@ export SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
source $SCRIPT_DIR/shared.sh
source $SCRIPT_DIR/args.sh

function action_on_exit() {
print_ok "Action on exit..."
## Do something before exit.
sleep 2
umount_on_exit
sleep 2
exit 0
}

function bind_signal() {
##
## * [man 1 bash](https://manpages.debian.org/stable/bash/bash.1.en.html)
## * `help trap`
##
print_ok "Bind signal..."
trap action_on_exit EXIT
judge "Bind signal"
}

function umount_on_exit() {
print_ok "Umount before exit..."
sudo umount new_building_os/dev || sudo umount -lf new_building_os/dev || true
sudo umount new_building_os/run || sudo umount -lf new_building_os/run || true
sudo umount new_building_os/proc || sudo umount -lf new_building_os/proc || true
sudo umount new_building_os/sys || sudo umount -lf new_building_os/sys || true
judge "Umount before exit"
}

function check_host() {

local os_ver
Expand Down Expand Up @@ -337,6 +365,7 @@ EOF

# ============= main ================
cd $SCRIPT_DIR
bind_signal
check_host
clean
setup_host
Expand Down