Skip to content

Commit

Permalink
Feature kickstart: Fix shellchek warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Gladkov <[email protected]>
  • Loading branch information
legionus committed May 17, 2021
1 parent b65ddc4 commit 22b040b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 32 deletions.
26 changes: 14 additions & 12 deletions features/kickstart/data/bin/kickstart
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ EOF

KS_IGNORED='9999000000'
KS_ORDERS=(
$KS_IGNORED:autostep
$KS_IGNORED:device
$KS_IGNORED:deviceprobe
$KS_IGNORED:dmraid
$KS_IGNORED:install
$KS_IGNORED:interactive
$KS_IGNORED:langsupport
$KS_IGNORED:method
$KS_IGNORED:monitor
$KS_IGNORED:mouse
$KS_IGNORED:multipath
$KS_IGNORED:upgrade
"$KS_IGNORED":autostep
"$KS_IGNORED":device
"$KS_IGNORED":deviceprobe
"$KS_IGNORED":dmraid
"$KS_IGNORED":install
"$KS_IGNORED":interactive
"$KS_IGNORED":langsupport
"$KS_IGNORED":method
"$KS_IGNORED":monitor
"$KS_IGNORED":mouse
"$KS_IGNORED":multipath
"$KS_IGNORED":upgrade
0000000000:cdrom
0000000000:cmdline
0000000000:driverdisk
Expand Down Expand Up @@ -281,6 +281,7 @@ ks_run_section()
local script="$ks_datadir/ks:$name-$num"
local ret=0

# shellcheck disable=SC2016
verbose "$msg ${erroronfail:+and stop in case of failure }${logfile:+and log will be in '$logfile' }..."

if [ -n "$logfile" ]; then
Expand Down Expand Up @@ -335,6 +336,7 @@ ks_parse()
local l eof='' args kwd num section='body' lineno=0 cmdbase=0
while [ -z "$eof" ]; do
if [ "$section" = 'body' ]; then
# shellcheck disable=SC2162
IFS='' read l || eof=1

if [[ "$l" =~ [[:space:]]*([^[:space:]].*) ]]; then
Expand Down
2 changes: 1 addition & 1 deletion features/kickstart/data/bin/kickstart-sh-installation
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ liveimg()
local PROG TEMP ret=0 archive='' isdir=''
local url='' proxy='' noverifyssl='' checksum=''

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l 'url:,proxy:,checksum:,noverifyssl' -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down
2 changes: 1 addition & 1 deletion features/kickstart/data/bin/kickstart-sh-postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ks_reboot()
local PROG TEMP cmd
local try_eject='' try_kexec=''

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l 'eject,kexec' -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down
36 changes: 18 additions & 18 deletions features/kickstart/data/bin/kickstart-sh-storage
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ignoredisk()
local drives='' onlyuse=''
local ret=0

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l 'drives:,only-use:' -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -96,7 +96,7 @@ clearpart()
local PROG TEMP dev skipped
local all='' disks='' list='' initlabel=''

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l 'all,drives:,list:,none,initlabel,disklabel:' -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -202,11 +202,11 @@ ks_get_dev_size()
bytes) totalsize_bytes=$value ;;
sectors) totalsize_sectors=$value ;;
esac
done <<< $(
done <<< "$(
sfdisk "$@" "/dev/$dev" |
head -1 |
sed -n -e 's|^.*, \([0-9]\+\) bytes, \([0-9]\+\) sectors|bytes \1\nsectors \2|p'
)
)"
}

ks_fstab()
Expand Down Expand Up @@ -258,7 +258,7 @@ makefs()
local dev=''
local fstype='ext4' label=''

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l "$getopt_makefs" -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -323,7 +323,7 @@ crypto()

local ret=0

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l "name:,$getopt_crypto" -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -437,7 +437,7 @@ part()

local ret=0

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l "asprimary,ondisk:,ondrive:,onpart:,usepart:,fsoptions:,size:,grow,resize,encrypted,$getopt_makefs,$getopt_crypto,$getopt_useexisting" -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -566,7 +566,7 @@ part()
prev_parttable=()
curr_parttable=()

readarray -t prev_parttable <<< $(sfdisk -d "/dev/$dev" | grep ^/dev/)
readarray -t prev_parttable <<< "$(sfdisk -d "/dev/$dev" | grep ^/dev/)"

if [ -z "$asprimary" ] && [ "$DISKLABEL" = dos ] && [ "${#prev_parttable[@]}" = 3 ]; then
verbose "creating new extended partition on /dev/$dev"
Expand All @@ -575,7 +575,7 @@ part()
sfdisk -q -W always --append "/dev/$dev" ||
break

readarray -t prev_parttable <<< $(sfdisk -d "/dev/$dev" | grep ^/dev/)
readarray -t prev_parttable <<< "$(sfdisk -d "/dev/$dev" | grep ^/dev/)"
fi

verbose "creating new partition on /dev/$dev"
Expand All @@ -590,7 +590,7 @@ part()
return 1
fi

readarray -t curr_parttable <<< $(sfdisk -d "/dev/$dev" | grep ^/dev/)
readarray -t curr_parttable <<< "$(sfdisk -d "/dev/$dev" | grep ^/dev/)"

sz=${#curr_parttable[@]}

Expand Down Expand Up @@ -628,7 +628,7 @@ part()
fi

local partnum
read partnum < "/sys/class/block/$partdev/partition"
read -r partnum < "/sys/class/block/$partdev/partition"

dev="$(readlink -ev "/sys/class/block/$partdev")"
dev="${dev%/*}"
Expand Down Expand Up @@ -676,7 +676,7 @@ volgroup()
local PROG TEMP shift_args
local useexisting='' pesize=''

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l "pesize:,$getopt_useexisting" -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -714,7 +714,7 @@ volgroup()
;;
pv.*)
for arg in $(set +f; printf '%s\n' "$ks_datadir/"$1); do
read arg < "$arg"
read -r arg < "$arg"
set -- "$@" "/dev/$arg"
done
;;
Expand Down Expand Up @@ -750,7 +750,7 @@ logvol()
local encrypted='' makefs_args='' crypto_args=''
local ret=0

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l "vgname:,name:,fsoptions:,chunksize:,percent:,size:,resize,grow,encrypted,$getopt_crypto,$getopt_makefs,$getopt_useexisting" -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -870,7 +870,7 @@ raid()
local device='' level='' chunksize='' useexisting='' fsoptions=''
local encrypted='' makefs_args='' crypto_args=''

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l "device:,level:,chunksize:,encrypted,$getopt_crypto,$getopt_makefs,$getopt_useexisting" -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -922,7 +922,7 @@ raid()
'')
;;
raid.*)
read arg < "$ks_datadir/$1"
read -r arg < "$ks_datadir/$1"
set -- "$@" "/dev/$arg"
;;
*)
Expand Down Expand Up @@ -995,7 +995,7 @@ btrfs()
local subvol='' data='' metadata='' label='' name='' fsoptions='' useexisting=''
local mntpoint i num

PROG="$FUNCNAME"
PROG="${FUNCNAME[0]}"
TEMP=`getopt -n "$PROG" -l "subvol,name:,label:,data:,metadata:,fsoptions:,$getopt_useexisting" -- "$PROG" "$@"` ||
return 1
eval set -- "$TEMP"
Expand Down Expand Up @@ -1050,7 +1050,7 @@ btrfs()
;;
btrfs.*)
for arg in $(set +f; printf '%s\n' "$ks_datadir"/$1); do
read arg < "$arg"
read -r arg < "$arg"
set -- "$@" "/dev/$arg"
done
;;
Expand Down

0 comments on commit 22b040b

Please sign in to comment.