Merge pull request #32 from pajamian/main

Move some checks to the top of the script.
This commit is contained in:
Neil Hanlon 2021-06-12 09:00:16 -04:00 committed by GitHub
commit 2d4a24b5fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,6 +32,26 @@
## Rocky is RC status. Using this script means you accept all risks of system
## instability.
# These checks need to be right at the top because we start with bash-isms right
# away in this script.
if [ -n "$POSIXLY_CORRECT" ] || [ -z "$BASH_VERSION" ]; then
printf '%s\n' "bash >= 4.0 is required for this script." >&2
exit 1
fi
# We need bash version >= 4 for associative arrays.
if (( BASH_VERSINFO < 4 )); then
printf '%s\n' "bash >= 4.0 is required for this script." >&2
exit 1
fi
# Make sure we're root.
if (( EUID != 0 )); then
printf '%s\n' "You must run this script as root. Either use sudo or 'su -c ${0}'" >&2
exit 1
fi
# Path to logfile
logfile=/var/log/migrate2rocky.log
@ -114,22 +134,11 @@ pre_check () {
# work unless it's severly broken. This is just a simple check that will cause
# the script to bail if any expected system utilities are missing.
bin_check() {
# Make sure we're root.
if (( EUID != 0 )); then
exit_message "You must run this script as root. Either use sudo or 'su -c ${0}'"
fi
# Check the platform.
if [[ $(os-release PLATFORM_ID) != "$SUPPORTED_PLATFORM" ]]; then
exit_message "This script must be run on an EL8 distribution. Migration from other distributions is not supported."
fi
# We need bash version >= 4 for associative arrays. This will also verify
# that we're actually running bash.
if (( BASH_VERSINFO < 4 )); then
exit_message "bash >= 4.0 is required for this script."
fi
local -a missing bins
bins=(
rpm dnf awk column tee tput mkdir