mirror of
https://github.com/rocky-linux/rocky-tools.git
synced 2024-11-28 16:06:26 +00:00
Fix shellcheck issues (#146)
* Quote to prevent splitting * Remove dir_mount_map variable * Define efi_disk and efi_partition as array * Expanding an array without an index only gives the first element * Ignore shellchecking /etc/os-release * Expressions do not need to expand
This commit is contained in:
parent
3c32595b23
commit
d2b2b61afc
@ -212,6 +212,7 @@ logmessage(){
|
|||||||
|
|
||||||
# This just grabs a field from os-release and returns it.
|
# This just grabs a field from os-release and returns it.
|
||||||
os-release () (
|
os-release () (
|
||||||
|
# shellcheck source=/dev/null
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
if ! [[ ${!1} ]]; then
|
if ! [[ ${!1} ]]; then
|
||||||
return 1
|
return 1
|
||||||
@ -275,7 +276,7 @@ pre_check () {
|
|||||||
fi
|
fi
|
||||||
local -a errs dirs=("${!dir_space_map[@]}")
|
local -a errs dirs=("${!dir_space_map[@]}")
|
||||||
local dir mount avail i=0
|
local dir mount avail i=0
|
||||||
local -A mount_avail_map dir_mount_map mount_space_map
|
local -A mount_avail_map mount_space_map
|
||||||
while read -r mount avail; do
|
while read -r mount avail; do
|
||||||
if [[ $mount == 'Filesystem' ]]; then
|
if [[ $mount == 'Filesystem' ]]; then
|
||||||
continue
|
continue
|
||||||
@ -283,7 +284,6 @@ pre_check () {
|
|||||||
|
|
||||||
dir=${dirs[$((i++))]}
|
dir=${dirs[$((i++))]}
|
||||||
|
|
||||||
dir_mount_map[$dir]=$mount
|
|
||||||
mount_avail_map[$mount]=${avail%M}
|
mount_avail_map[$mount]=${avail%M}
|
||||||
(( mount_space_map[$mount]+=dir_space_map[$dir] ))
|
(( mount_space_map[$mount]+=dir_space_map[$dir] ))
|
||||||
done < <(df -BM --output=source,avail "${dirs[@]}")
|
done < <(df -BM --output=source,avail "${dirs[@]}")
|
||||||
@ -480,10 +480,10 @@ collect_system_info () {
|
|||||||
--noheadings) ||
|
--noheadings) ||
|
||||||
exit_message "Can't find EFI mount. No EFI boot detected."
|
exit_message "Can't find EFI mount. No EFI boot detected."
|
||||||
kname=$(lsblk -dno kname "$efi_mount")
|
kname=$(lsblk -dno kname "$efi_mount")
|
||||||
efi_disk=$(lsblk -dno pkname "/dev/$kname")
|
efi_disk=("$(lsblk -dno pkname "/dev/$kname")")
|
||||||
|
|
||||||
if [[ $efi_disk ]]; then
|
if [[ ${efi_disk[0]} ]]; then
|
||||||
efi_partition=$(<"/sys/block/$efi_disk/$kname/partition")
|
efi_partition=("$(<"/sys/block/${efi_disk[0]}/$kname/partition")")
|
||||||
else
|
else
|
||||||
# This is likely an md-raid or other type of virtual disk, we need
|
# This is likely an md-raid or other type of virtual disk, we need
|
||||||
# to dig a little deeper to find the actual physical disks and
|
# to dig a little deeper to find the actual physical disks and
|
||||||
@ -665,10 +665,10 @@ $'because continuing with the migration could cause further damage to system.'
|
|||||||
then
|
then
|
||||||
# System package that needs to be swapped / disabled
|
# System package that needs to be swapped / disabled
|
||||||
installed_pkg_map[$p]=
|
installed_pkg_map[$p]=
|
||||||
installed_sys_stream_repos_pkgs+=( ${stream_repos_pkgs[$p]} )
|
installed_sys_stream_repos_pkgs+=( "${stream_repos_pkgs[$p]}" )
|
||||||
elif rpm --quiet -q "${stream_repos_pkgs[$p]}"; then
|
elif rpm --quiet -q "${stream_repos_pkgs[$p]}"; then
|
||||||
# Non-system package, repos just need to be disabled.
|
# Non-system package, repos just need to be disabled.
|
||||||
installed_stream_repos_pkgs+=( ${stream_repos_pkgs[$p]} )
|
installed_stream_repos_pkgs+=( "${stream_repos_pkgs[$p]}" )
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -735,7 +735,7 @@ $'because continuing with the migration could cause further damage to system.'
|
|||||||
mod=${mod/$gl/$repl}
|
mod=${mod/$gl/$repl}
|
||||||
done
|
done
|
||||||
if [[ $mod != "${enabled_modules[$i]}" ]]; then
|
if [[ $mod != "${enabled_modules[$i]}" ]]; then
|
||||||
disable_modules+=(${enabled_modules[$i]})
|
disable_modules+=("${enabled_modules[$i]}")
|
||||||
enabled_modules[$i]=$mod
|
enabled_modules[$i]=$mod
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -843,6 +843,7 @@ package_swaps() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Rename the stream repos with a prefix and fix the baseurl.
|
# Rename the stream repos with a prefix and fix the baseurl.
|
||||||
|
# shellcheck disable=SC2016
|
||||||
sed -i \
|
sed -i \
|
||||||
-e 's/^\[/['"$stream_prefix"'/' \
|
-e 's/^\[/['"$stream_prefix"'/' \
|
||||||
-e 's|^mirrorlist=|#mirrorlist=|' \
|
-e 's|^mirrorlist=|#mirrorlist=|' \
|
||||||
|
Loading…
Reference in New Issue
Block a user