arch-create-system: use 'command' instead of 'which'

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-01-31 09:12:58 +01:00
parent 0970d5254e
commit 33f6ab2f41

View File

@@ -73,18 +73,18 @@ echo () { printf %s\\n "$*" ; }
check_prerequisites () {
# requested binaries:
which chattr >/dev/null 2>&1 || { printf "'chattr' is not installed." && exit 1; }
which btrfs >/dev/null 2>&1 || { printf "'btrfs' is not installed." && exit 1; }
which fallocate >/dev/null 2>&1 || { printf "'findmnt' is not installed." && exit 1; }
which gawk >/dev/null 2>&1 || { printf "'gawk' is not installed." && exit 1; }
which mkfs >/dev/null 2>&1 || { printf "'mkfs' is not installed." && exit 1; }
which mkswap >/dev/null 2>&1 || { printf "'mkswap' is not installed." && exit 1; }
which mount >/dev/null 2>&1 || { printf "'mount' is not installed." && exit 1; }
which pacman >/dev/null 2>&1 || { printf "'pacman' is not installed." && exit 1; }
which pacstrap >/dev/null 2>&1 || { printf "'pacstrap' is not installed." && exit 1; }
which sed >/dev/null 2>&1 || { printf "'sed' is not installed." && exit 1; }
which sgdisk >/dev/null 2>&1 || { printf "'sgdisk' is not installed." && exit 1; }
which umount >/dev/null 2>&1 || { printf "'umount' is not installed." && exit 1; }
command -v chattr >/dev/null 2>&1 || { printf "'chattr' is not installed." && exit 1; }
command -v btrfs >/dev/null 2>&1 || { printf "'btrfs' is not installed." && exit 1; }
command -v fallocate >/dev/null 2>&1 || { printf "'findmnt' is not installed." && exit 1; }
command -v gawk >/dev/null 2>&1 || { printf "'gawk' is not installed." && exit 1; }
command -v mkfs >/dev/null 2>&1 || { printf "'mkfs' is not installed." && exit 1; }
command -v mkswap >/dev/null 2>&1 || { printf "'mkswap' is not installed." && exit 1; }
command -v mount >/dev/null 2>&1 || { printf "'mount' is not installed." && exit 1; }
command -v pacman >/dev/null 2>&1 || { printf "'pacman' is not installed." && exit 1; }
command -v pacstrap >/dev/null 2>&1 || { printf "'pacstrap' is not installed." && exit 1; }
command -v sed >/dev/null 2>&1 || { printf "'sed' is not installed." && exit 1; }
command -v sgdisk >/dev/null 2>&1 || { printf "'sgdisk' is not installed." && exit 1; }
command -v umount >/dev/null 2>&1 || { printf "'umount' is not installed." && exit 1; }
if [ $(id -u) -ne 0 ] ; then printf "$progname: must be run as root\n" ; exit 1 ; fi
}
@@ -402,14 +402,14 @@ error () {
printf "\n==> ERROR: %s\n" "$@"
} >&2
get_config_id () {
get_config () {
local config_json=${configfile:-$config_json}
local config_id=${1}
local config=${1}
local cmd
if [ $verbose -ge 1 ]; then
printf "${BLUE}get_config_id ...${NO_COLOR}\n"
printf "${BLUE}get_config ...${NO_COLOR}\n"
fi
if test ! -r ${config_json}; then
@@ -420,12 +420,13 @@ get_config_id () {
exit 1
fi
cmd="jq -r --monochrome-output --ascii-output ' .ConfigEnvironment[] \
| select(.ConfigName == \"${name}\") \
| .ConfigName ' \
${config_json}"
#cmd="jq --monochrome-output --ascii-output ' .ConfigEnvironment[] \
# | {Id: .ConfigId, Name: .ConfigName} ' \
# ${config_json}"
cmd="jq --monochrome-output --ascii-output ' .ConfigEnvironment[] \
| .ConfigName ' \
${config_json}"
config_name=$(eval $cmd)
#config_name=$(echo $config_name | sed -e 's/\n//g')