diff options
Diffstat (limited to 'functions')
-rw-r--r-- | functions | 34 |
1 files changed, 29 insertions, 5 deletions
@@ -65,9 +65,19 @@ if (( $? != 3 )); then fi unset TERM_COLORS +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" @@ -94,8 +104,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" \ @@ -121,6 +130,10 @@ deltext() { printf "${DEL_TEXT}" } +print_depr() { + printf "${C_FAIL} ${1} is deprecated. See ${2} for details.${C_CLEAR} \n" +} + printhl() { printf "${C_OTHER}${PREFIX_HL} ${C_H1}${1}${C_CLEAR} \n" } @@ -351,6 +364,7 @@ load_modules() { local rc=0 if [[ $MODULES ]]; then + print_depr "MODULES=" "rc.conf(5) and modules-load.d(5)" /usr/lib/systemd/arch-modules-load rc=$? fi @@ -398,7 +412,7 @@ do_unlock_legacy() { # $2 = source device # $3 = password # $4 = options - printf "${C_FAIL}Using legacy crypttab format. This will stop working in the future. See crypttab(5).${C_CLEAR}\n" + print_depr "The legacy crypttab format" "crypttab(5)" 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. @@ -468,6 +482,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 @@ -510,7 +534,7 @@ do_unlock() { do_unlock_legacy "$name" "$device" "$password" "$options" fi ;; - /*|none|-) + /*|none|-|'') do_unlock_systemd "$name" "$device" "$password" "$options" ;; *) |