From 33f6ab2f4159901ee19a133304e2370f2de12141 Mon Sep 17 00:00:00 2001 From: Ralf Zerres Date: Fri, 31 Jan 2020 09:12:58 +0100 Subject: [PATCH] arch-create-system: use 'command' instead of 'which' Signed-off-by: Ralf Zerres --- usr/bin/arch-create-system | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/usr/bin/arch-create-system b/usr/bin/arch-create-system index 1436692..3145ad5 100755 --- a/usr/bin/arch-create-system +++ b/usr/bin/arch-create-system @@ -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')