Add 'die()' for easier error handling
authorPhilippe Seewer <philippe.seewer@bfh.ch>
Tue, 16 Jun 2009 12:39:35 +0000 (14:39 +0200)
committerPhilippe Seewer <philippe.seewer@bfh.ch>
Wed, 17 Jun 2009 06:37:40 +0000 (08:37 +0200)
Printing out an errormessage and quitting is easier if there's a function
to call. If the script calling die has exit trapped, like in init, the
emergency_shell is automatically called.

modules.d/99base/dracut-lib
modules.d/99base/init

index df9cb52..336b235 100644 (file)
@@ -21,6 +21,12 @@ source_all() {
     for f in "/$1"/*.sh; do [ -f "$f" ] && . "$f"; done
 }
 
+die() {
+    printf "FATAL: $1\n"
+    printf "Refusing to continue\n"
+    exit 1
+}
+
 check_occurances() {
     # Count the number of times the character $ch occurs in $str
     # Return 0 if the count matches the expected number, 1 otherwise
index e417993..8a5eac0 100755 (executable)
@@ -47,10 +47,9 @@ fi
 
 if [ -n "$root" -a -z "${root%%error:*}" ]; then
     case "${root%%:*}" in
-       '') echo "FATAL: no root= option specified, and no network support" ;;
-       error) echo "FATAL: ${root#error:}" ;;
+       '') die "No root= option specified, and no network support" ;;
+       error) die "${root#error:}" ;;
     esac
-    emergency_shell
 fi
 
 # Network root scripts may need updated root= options,