From 2bc641aa225428e657d2ab5ae59a2159e09f5ed9 Mon Sep 17 00:00:00 2001 From: timoxa0 Date: Sun, 11 Aug 2024 16:01:21 +0500 Subject: [PATCH] Add CTRL+C handler --- common.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common.sh b/common.sh index e74cd1a..a5c16f1 100755 --- a/common.sh +++ b/common.sh @@ -5,10 +5,19 @@ SIMPLEINIT_CMDLINE="root=PARTLABEL=linux loglevel=3 fbcon=rotate:1" function log() { printf "\e[1m\e[92m==>\e[0m \e[1m%s\e[0m\n" "$*" } + function log_err() { printf "\e[1m\e[31m==>\e[0m \e[1m%s\e[0m\n" "$*" } +function sigterm_handler() { + printf "\e[1m\e[31m>\e[0m \e[1m%s\e[0m\n" "Shutdown signal received." + exit 1 +} + +trap 'trap " " SIGINT SIGTERM SIGHUP; kill 0; wait; sigterm_handler' SIGINT SIGTERM SIGHUP + + function create_image() { name="$(realpath "./raw/${1}.img")" if [ -z "$2" ]; then