Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/
Date: Wed, 07 Aug 2019 15:46:18
Message-Id: 1565124032.3022031a3824aedb923aac17e6817e158f6775ed.whissi@gentoo
1 commit: 3022031a3824aedb923aac17e6817e158f6775ed
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Tue Aug 6 17:19:50 2019 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Tue Aug 6 20:40:32 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=3022031a
7
8 unlock-luks.sh: Make shellcheck happy
9
10 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
11
12 defaults/unlock-luks.sh | 19 +++++++++----------
13 1 file changed, 9 insertions(+), 10 deletions(-)
14
15 diff --git a/defaults/unlock-luks.sh b/defaults/unlock-luks.sh
16 index 16e654c..ebcd2ca 100644
17 --- a/defaults/unlock-luks.sh
18 +++ b/defaults/unlock-luks.sh
19 @@ -39,11 +39,11 @@ main() {
20
21 eval local LUKS_DEVICE='"${CRYPT_'${TYPE}'}"' LUKS_NAME="${NAME}" LUKS_KEY='"${CRYPT_KEYFILE_'${TYPE}'}"'
22 eval local LUKS_TRIM='"${CRYPT_'${TYPE}'_TRIM}"' OPENED_LOCKFILE='"${CRYPT_'${TYPE}'_OPENED_LOCKFILE}"'
23 - local cryptsetup_options=
24 + local cryptsetup_options
25
26 while true
27 do
28 - local gpg_cmd= crypt_filter_ret=
29 + local gpg_cmd crypt_filter_ret
30
31 if [ -e "${OPENED_LOCKFILE}" ]
32 then
33 @@ -53,15 +53,14 @@ main() {
34 LUKS_DEVICE=$(find_real_device "${LUKS_DEVICE}")
35 if [ -z "${LUKS_DEVICE}" ]
36 then
37 - bad_msg "Looks like CRYPT_${TYPE} kernel cmdline argument is not set." ${CRYPT_SILENT}
38 + bad_msg "Looks like CRYPT_${TYPE} kernel cmdline argument is not set." "${CRYPT_SILENT}"
39 exit 1
40 fi
41
42 - setup_md_device ${LUKS_DEVICE}
43 - cryptsetup isLuks ${LUKS_DEVICE}
44 - if [ $? -ne 0 ]
45 + setup_md_device "${LUKS_DEVICE}"
46 + if ! cryptsetup isLuks "${LUKS_DEVICE}"
47 then
48 - bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" ${CRYPT_SILENT}
49 + bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" "${CRYPT_SILENT}"
50
51 # User has SSH access and is able to call script again or
52 # able to investigate the problem on its own.
53 @@ -69,7 +68,7 @@ main() {
54 else
55 if [ "x${LUKS_TRIM}" = "xyes" ]
56 then
57 - good_msg "Enabling TRIM support for ${LUKS_NAME} ..." ${CRYPT_SILENT}
58 + good_msg "Enabling TRIM support for ${LUKS_NAME} ..." "${CRYPT_SILENT}"
59 cryptsetup_options="${cryptsetup_options} --allow-discards"
60 fi
61
62 @@ -91,10 +90,10 @@ main() {
63 if [ ${crypt_filter_ret} -eq 0 ]
64 then
65 touch "${OPENED_LOCKFILE}"
66 - good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT}
67 + good_msg "LUKS device ${LUKS_DEVICE} opened" "${CRYPT_SILENT}"
68 break
69 else
70 - bad_msg "Failed to open LUKS device ${LUKS_DEVICE}" ${CRYPT_SILENT}
71 + bad_msg "Failed to open LUKS device ${LUKS_DEVICE}" "${CRYPT_SILENT}"
72
73 # We need to stop here with a non-zero exit code to prevent
74 # a loop when invalid keyfile was sent.