Skip to content

Commit 1b913e7

Browse files
committed
Merge remote-tracking branch 'origin/pull/485'
* origin/pull/485: installkernel: remove bashisms
2 parents d0b8d99 + e30717d commit 1b913e7

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

contrib/installkernel/91-sbctl.install

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,32 @@ ver=${1}
77
img=${2}
88

99
die() {
10-
echo -e " ${NOCOLOR-\e[1;31m*\e[0m }${*}" >&2
11-
exit 1
10+
printf ' \033[1;31m*\033[0m %s\n' "$*" >&2
11+
exit 1
1212
}
1313

1414
einfo() {
15-
[[ ${INSTALLKERNEL_VERBOSE} == 1 ]] || return 0
16-
echo -e " ${NOCOLOR-\e[1;32m*\e[0m }${*}"
15+
: "${INSTALLKERNEL_VERBOSE:=1}"
16+
printf ' \033[1;32m*\033[0m %s\n' "$*" >&2
1717
}
1818

1919
main() {
20-
# re-define for subst to work
21-
[[ -n ${NOCOLOR+yes} ]] && NOCOLOR=
22-
23-
# do nothing if secureboot key directory doesn't exist
24-
if ! [ "$(sbctl setup --print-state --json | awk '/installed/ { gsub(/,$/,"",$2); print $2 }')" = "true" ]; then
25-
einfo "Secureboot key directory doesn't exist, not signing!"
26-
exit 0
27-
fi
28-
29-
[[ ${EUID} -eq 0 ]] || die "Please run this script as root"
30-
31-
einfo "sbctl: Signing kernel $img"
32-
sbctl sign -s $img 1> /dev/null
20+
[ -t 2 ] || NOCOLOR=1
21+
# re-define for subst to work
22+
[ "${NOCOLOR+yes}" ] && NOCOLOR=
23+
24+
# do nothing if secureboot key directory doesn't exist
25+
if ! [ "$(sbctl setup --print-state --json | awk '/installed/ { gsub(/,$/,"",$2); print $2 }')" = "true" ]; then
26+
einfo "Secureboot key directory doesn't exist, not signing!"
27+
exit 0
28+
fi
29+
30+
[ "$(id -u)" -eq 0 ] || die "Please run this script as root"
31+
32+
einfo "sbctl: Signing kernel $img"
33+
if ! sbctl sign -s "$img" >/dev/null 2>&1; then
34+
die "Failed to sign kernel: $img"
35+
fi
3336
}
3437

35-
main
36-
38+
main "$@"

0 commit comments

Comments
 (0)