diff options
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 39 |
1 files changed, 29 insertions, 10 deletions
@@ -72,9 +72,19 @@ unset TZ # sanitize the locale settings unset "${localevars[@]}" +unquote() { + local -r quotes=$'[\'"]' + + if [[ ${1:0:1} = $quotes && ${1:(-1)} = "${1:0:1}" ]]; then + printf '%s' "${1:1:(-1)}" + else + printf '%s' "$1" + fi +} + parse_envfile() { local file=$1 validkeys=("${@:2}") ret=0 lineno=0 key= val= - local -r quotes=$'[\'"]' comments=$'[;#]*' + local -r comments=$'[;#]*' if [[ -z $file ]]; then printf "error: no environment file specified\n" @@ -101,8 +111,7 @@ parse_envfile() { [[ -z $key || ${key:0:1} = $comments ]] && continue # trim whitespace, strip matching quotes - val=$(echo "$val" | { read -r val; echo "$val"; }) - [[ ${val:0:1} = $quotes && ${val:(-1)} = "${val:0:1}" ]] && val=${val:1:(-1)} + val=$(echo "$val" | { read -r val; unquote "$val"; }) if [[ -z $val ]]; then printf "error: found key \`%s' without value on line %s of %s\n" \ @@ -357,14 +366,14 @@ print_welcome() { load_modules() { local rc=0 - /usr/lib/systemd/systemd-modules-load &>/dev/null - rc=$? - - if (( ${#MODULES[*]} )); then - modprobe -ab "${MODULES[@]}" - (( rc += $? )) + if [[ $MODULES ]]; then + /usr/lib/systemd/arch-modules-load + rc=$? fi + /usr/lib/systemd/systemd-modules-load + (( rc+=$? )) + return $rc } @@ -475,6 +484,16 @@ do_unlock_legacy() { do_unlock_systemd() { local name=$1 device=$2 password=$3 options=$4 failed=0 + # lazily convert tags to udev symlinks + case $device in + UUID=*) + device=/dev/disk/by-uuid/$(unquote "${device#UUID=}") + ;; + PARTUUID=*) + device=/dev/disk/by-partuuid/$(unquote "${device#PARTUUID=}") + ;; + esac + if ! /usr/lib/systemd/systemd-cryptsetup attach "$name" "$device" "$password" $options; then failed=1 else @@ -517,7 +536,7 @@ do_unlock() { do_unlock_legacy "$name" "$device" "$password" "$options" fi ;; - /*|none|-) + /*|none|-|'') do_unlock_systemd "$name" "$device" "$password" "$options" ;; *) |