aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2021-03-08 01:35:19 +0100
committerThomas Deutschmann <whissi@gentoo.org>2021-03-08 01:36:13 +0100
commit3f1a037b36a3df7ba5acb3b91f925df06dbd61da (patch)
tree7bffe482096799fb56e76e4751c52500a47f745c /defaults
parentdefaults/modules_load: Add netconsole (diff)
downloadgenkernel-3f1a037b36a3df7ba5acb3b91f925df06dbd61da.tar.gz
genkernel-3f1a037b36a3df7ba5acb3b91f925df06dbd61da.tar.bz2
genkernel-3f1a037b36a3df7ba5acb3b91f925df06dbd61da.zip
initrd.scripts: Add trim() function
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'defaults')
-rw-r--r--defaults/initrd.scripts10
-rw-r--r--defaults/unlock-luks.sh1
2 files changed, 11 insertions, 0 deletions
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index f7e6c3d..d005e0d 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1103,6 +1103,15 @@ test_success() {
fi
}
+trim() {
+ local var="$*"
+
+ var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
+ var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
+
+ printf "%s" "${var}"
+}
+
log_msg() {
is_log_enabled || return
@@ -1779,6 +1788,7 @@ openLUKS() {
eval local LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
eval local LUKS_KEYDEV_FSTYPE='"${CRYPT_'${TYPE}'_KEYDEV_FSTYPE}"'
eval local cryptsetup_options='"${CRYPT_'${TYPE}'_OPTIONS}"'
+ cryptsetup_options="$(trim "${cryptsetup_options}")"
eval local OPENED_LOCKFILE='"${CRYPT_'${TYPE}'_OPENED_LOCKFILE}"'
local DEV_ERROR=0 KEY_ERROR=0 KEYDEV_ERROR=0
local mntkey="/mnt/key/" crypt_filter_ret=
diff --git a/defaults/unlock-luks.sh b/defaults/unlock-luks.sh
index 4c99a1f..9ef54e0 100644
--- a/defaults/unlock-luks.sh
+++ b/defaults/unlock-luks.sh
@@ -47,6 +47,7 @@ main() {
eval local LUKS_DEVICE='"${CRYPT_'${TYPE}'}"'
eval local LUKS_KEY='"${CRYPT_'${TYPE}'_KEYFILE}"'
eval local cryptsetup_options='"${CRYPT_'${TYPE}'_OPTIONS}"'
+ cryptsetup_options="$(trim "${cryptsetup_options}")"
eval local OPENED_LOCKFILE='"${CRYPT_'${TYPE}'_OPENED_LOCKFILE}"'
if [ -z "${LUKS_DEVICE}" ]