diff options
author | Tom Gundersen <teg@jklm.no> | 2012-07-17 16:17:42 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2012-07-17 16:42:36 +0200 |
commit | 476b308f121b934859080e5ca48a93a504aadaf6 (patch) | |
tree | 56f5c908adcc30d0e8bc09bbd1ba13dd36bc7131 /functions | |
parent | 275e04adec75fe9faff246bf893842da1d6d829d (diff) | |
download | initscripts-476b308f121b934859080e5ca48a93a504aadaf6.tar.xz |
cryptsetup: refactor the output
I created a mess half-way between the legacy and the systemd outputs.
Signed-off-by: Tom Gundersen <teg@jklm.no>
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 26 |
1 files changed, 10 insertions, 16 deletions
@@ -386,8 +386,7 @@ do_unlock_legacy() { # $2 = source device # $3 = password # $4 = options - stat_append "${1}.." - printf "${C_FAIL}Using legacy crypttab format. This will stop working in the future. See crypttab(5).${C_OTHER}\n" + printf "${C_FAIL}Using legacy crypttab format. This will stop working in the future. See crypttab(5).${C_CLEAR}\n" local open=create a=$1 b=$2 failed=0 # Ordering of options is different if you are using LUKS vs. not. # Use ugly swizzling to deal with it. @@ -416,7 +415,7 @@ do_unlock_legacy() { if (( _overwriteokay == 0 )); then false elif cryptsetup -d /dev/urandom $4 $open "$a" "$b" >/dev/null; then - stat_append "creating swapspace.." + printf "creating swapspace..\n" mkswap -f -L $1 /dev/mapper/$1 >/dev/null fi;; ASK) @@ -451,18 +450,12 @@ do_unlock_legacy() { *) echo "$3" | cryptsetup $4 $open "$a" "$b" >/dev/null;; esac - if (( $? )); then - failed=1 - stat_append "failed " - else - stat_append "ok " - fi - return $failed + return $? } do_unlock_systemd() { - stat_append "${1}.." local failed=0 + if ! /usr/lib/systemd/systemd-cryptsetup attach "$1" "$2" "$3" $4; then failed=1 else @@ -480,17 +473,14 @@ do_unlock_systemd() { fi fi fi - if (( $failed )); then - stat_append "failed " - else - stat_append "ok " - fi return $failed } do_unlock() { local name=$1 device=$2 password=$3 options=$4 + printf "${C_MAIN}Unlocking $1${C_CLEAR}\n" + if [[ ${options:0:2} =~ -. ]]; then do_unlock_legacy "$name" "$device" "$password" "$options" return $? @@ -514,6 +504,10 @@ do_unlock() { do_unlock_legacy "$name" "$device" "$password" "$options" ;; esac + failed=$? + if (( $failed )); then + printf "${C_FAIL}Unlocking of $1 failed.${C_CLEAR}\n" + fi return $? } |