use :? to early-exit instead of :- and hope for a good error

This commit is contained in:
наб 2024-03-03 14:08:37 +01:00
parent 1f9fe814fe
commit a20c275ceb
No known key found for this signature in database
GPG Key ID: BCFD0B018D2658F1

View File

@ -6,8 +6,8 @@
PREREQ
# tcsd exits if it doesn't have tss group and user
grep tss /etc/group >> "${TARGET_DIR:-MUST_EXIST}/etc/group"
grep tss /etc/passwd >> "${TARGET_DIR:-MUST_EXIST}/etc/passwd"
grep tss /etc/group >> "${TARGET_DIR:?must exist}/etc/group"
grep tss /etc/passwd >> "${TARGET_DIR:?must exist}/etc/passwd"
for f in /lib/udev/rules.d/*tpm*; do
INST_UDEV "$f"
@ -15,13 +15,13 @@
if [ -e /etc/tcsd.conf ]; then
INST_CFG /etc/tcsd.conf
chown root:tss "${TARGET_DIR:-MUST_EXIST}/etc/tcsd.conf"
chown root:tss "${TARGET_DIR:?must exist}/etc/tcsd.conf"
system_ps_file="$(awk -F '[[:space:]]*=[[:space:]]*' '!/^[[:space:]]*#/ && !/^$/ && $1 ~ /system_ps_file$/ {gsub(/[[:space:]]*$/, "", $2); print $2}' /etc/tcsd.conf)"
system_ps_file="${system_ps_file:-/var/lib/tpm/system.data}"
fi
# tcsd can't find SRK if state not present, refuses to start if it doesn't have parent to tss dir
mkdir -p "${TARGET_DIR:-MUST_EXIST}/$(dirname "$(dirname "$system_ps_file")")"
mkdir -p "${TARGET_DIR:?must exist}/$(dirname "$(dirname "$system_ps_file")")"
[ -f "$system_ps_file" ] && INST_STATE "$system_ps_file"
}