Skip to content

Commit

Permalink
Remove redundant fail from error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
grass committed Jul 24, 2023
1 parent b9afa1e commit 5820d57
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions usr/bin/installer-dist
Expand Up @@ -159,7 +159,7 @@ capitalize_first_char(){

## Block running as root.
not_as_root(){
test "$(id -u)" = "0" && die 1 "${underline}Non-Root Check:${nounderline} 'FAIL' - Running as root. This installer should not be run as root. Please run as normal user."
test "$(id -u)" = "0" && die 1 "${underline}Non-Root Check:${nounderline} Running as root. This installer should not be run as root. Please run as normal user."
return 0
}

Expand Down Expand Up @@ -824,7 +824,7 @@ install_pkg(){
log notice "Updating package list."
# shellcheck disable=SC2086
root_cmd ${pkg_mngr_update} ||
die 1 "${underline}Package List Update:${nounderline} 'FAIL' - Could not update package lists.
die 1 "${underline}Package List Update:${nounderline} Could not update package lists.
- This issue is most likely not caused by this installer.
- This is most likely a package manager configuration or network issue.
Expand All @@ -840,7 +840,7 @@ The user is advised to attempt to debug this with the following steps:
log notice "Installing package(s): '${pkg_not_installed}'"
# shellcheck disable=SC2086
root_cmd ${pkg_mngr_install} ${pkg_not_installed} ||
die 1 "${underline}Package Installation:${nounderline} 'FAIL' - Failed to install package: '${pkg_not_installed}'"
die 1 "${underline}Package Installation:${nounderline} Failed to install package: '${pkg_not_installed}'"
## Test if installation worked.
test_pkg "${pkg_not_installed}"
fi
Expand Down Expand Up @@ -883,7 +883,7 @@ check_vm_running_virtualbox(){
grep -qE "^State:[[:space:]]+(running|paused)"
then
log error "Cannot proceed. You have the following VM running: ${vm}"
die 1 "${underline}VM Running Check:${nounderline} 'FAIL' - Please turn it off before re-running this installer."
die 1 "${underline}VM Running Check:${nounderline} Please turn it off before re-running this installer."
fi
}

Expand Down Expand Up @@ -954,11 +954,11 @@ check_vm_exists_virtualbox(){
if test "${gateway_exists}" = "1" &&
test "${import_only}" = "gateway"
then
die 1 "${underline}Check Existing VM Test:${nounderline} 'FAIL' - import_only was set to 'gateway', but it already exists and reimport was not set."
die 1 "${underline}Check Existing VM Test:${nounderline} import_only was set to 'gateway', but it already exists and reimport was not set."
elif test "${workstation_exists}" = "1" &&
test "${import_only}" = "workstation"
then
die 1 "${underline}Check Existing VM Test:${nounderline} 'FAIL' - import_only was set to 'workstation', but it already exists and reimport was not set."
die 1 "${underline}Check Existing VM Test:${nounderline} import_only was set to 'workstation', but it already exists and reimport was not set."
fi
else
## One of the guests doesn't exist, but neither reimport nor
Expand All @@ -967,9 +967,9 @@ check_vm_exists_virtualbox(){
test "${gateway_exists}" = "0"
then
test "${workstation_exists}" = "0" &&
die 1 "${underline}Check Existing VM Test:${nounderline} 'FAIL' - Workstation cannot be started because it doesn't exist, try '--import-only=workstation'."
die 1 "${underline}Check Existing VM Test:${nounderline} Workstation cannot be started because it doesn't exist, try '--import-only=workstation'."
test "${gateway_exists}" = "0" &&
die 1 "${underline}Check Existing VM Test:${nounderline} 'FAIL' - Gateway cannot be started because it doesn't exist, try '--import-only=gateway'."
die 1 "${underline}Check Existing VM Test:${nounderline} Gateway cannot be started because it doesn't exist, try '--import-only=gateway'."
fi
## VMs already exist, check if user wants to start them.
log info "Checking if user wants to start Virtual Machine(s) now."
Expand Down Expand Up @@ -1113,14 +1113,14 @@ import_virtualbox(){
# shellcheck disable=SC2086
log_run vboxmanage import \
"${directory_prefix}/${guest_file}.${guest_file_ext}" ${vbox_arg} ||
die 105 "${underline}VM Import:${nounderline} 'FAIL' - Failed to import virtual machines."
die 105 "${underline}VM Import:${nounderline} Failed to import virtual machines."

## VirtualBox does not accept any command to import a single virtual system
## out from an ova with multiple ones.
## https://forums.virtualbox.org/viewtopic.php?f=1&t=107965
if test -n "${import_only}"; then
log_run vboxmanage unregistervm ${vm_purge} --delete ||
die 1 "${underline}VM Import:${nounderline} 'FAIL' - Failed to remove extraneous virtual system."
die 1 "${underline}VM Import:${nounderline} Failed to remove extraneous virtual system."
fi

log notice "VM Import: 'success'"
Expand Down Expand Up @@ -1196,7 +1196,7 @@ write_sources_debian(){
url="${1}"
file="${2}"
echo "${url}" | root_cmd tee "${file}" ||
die 1 "${underline}Sources List Writer:${nounderline} 'FAIL' - Failed to write to file: '${file}'"
die 1 "${underline}Sources List Writer:${nounderline} Failed to write to file: '${file}'"
}

## https://stackoverflow.com/a/54239534
Expand Down Expand Up @@ -1238,16 +1238,16 @@ install_virtualbox_debian_common_end(){
if test "${dry_run}" = "1"; then
log error "Failed to locate 'vboxmanage' program. - ignoring because dry_run is set."
else
die 1 "${underline}vboxmanage test:${nounderline} 'FAIL' - Failed to locate 'vboxmanage' program."
die 1 "${underline}vboxmanage test:${nounderline} Failed to locate 'vboxmanage' program."
fi
fi
virtualbox_linux_user_group="vboxusers"
id_of_user="$(id --name --user)" || die 1 "${underline}Linux user ID check:${nounderline} 'FAIL' - Failed to run: 'id --name --user'"
id_of_user="$(id --name --user)" || die 1 "${underline}Linux user ID check:${nounderline} Failed to run: 'id --name --user'"
if id -nG "$id_of_user" | grep -qw "${virtualbox_linux_user_group}\$"; then
log info "Linux account '$id_of_user' is already a member of the Linux group 'vboxusers'."
return 0
fi
root_cmd adduser "$id_of_user" "${virtualbox_linux_user_group}" || die 1 "${underline}adduser to Linux user group virtualbox:${nounderline} 'FAIL' - Failed to add user '$id_of_user' to group '${virtualbox_linux_user_group}'."
root_cmd adduser "$id_of_user" "${virtualbox_linux_user_group}" || die 1 "${underline}adduser to Linux user group virtualbox:${nounderline} Failed to add user '$id_of_user' to group '${virtualbox_linux_user_group}'."
}

install_repositories_for_virtualbox_on_debian(){
Expand Down Expand Up @@ -1312,7 +1312,7 @@ install_repositories_for_virtualbox_on_debian(){
## tor by other means to ensure a working connection (bridges, proxy etc).
log info "APT is supposed to be torified, checking if package apt-transport-tor is installed."
test_pkg apt-transport-tor ||
die 1 "${underline}Torified APT CHECK:${nounderline} 'FAIL' - APT is supposed to be torified, but package apt-transport-tor is not installed. Please install."
die 1 "${underline}Torified APT CHECK:${nounderline} APT is supposed to be torified, but package apt-transport-tor is not installed. Please install."
fi


Expand Down Expand Up @@ -1357,7 +1357,7 @@ install_repositories_for_virtualbox_on_debian(){
;;
esac

die 1 "${underline}Repository Add:${nounderline} 'FAIL' - Unsupported distribution codename: '${distro_codename}'!"
die 1 "${underline}Repository Add:${nounderline} Unsupported distribution codename: '${distro_codename}'!"
}


Expand Down Expand Up @@ -1514,7 +1514,7 @@ check_license(){
log notice "${underline}License Check:${nounderline} 'success' - User has accepted the license."
;;
*)
log warn "${underline}License Check:${nounderline} 'FAIL' - User replied: '${license_agreement}'"
log warn "${underline}License Check:${nounderline} User replied: '${license_agreement}'"
return 1
;;
esac
Expand All @@ -1529,7 +1529,7 @@ get_su_cmd(){
has doas && sucmd=doas && break
has su && sucmd=su && break
test -z "${sucmd}" && {
die 1 "${underline}get_su_cmd:${nounderline} 'FAIL' - Failed to find program to run as another user."
die 1 "${underline}get_su_cmd:${nounderline} Failed to find program to run as another user."
}
case "${sucmd}" in
sudo) :;;
Expand All @@ -1539,13 +1539,13 @@ get_su_cmd(){

log info "Testing root_cmd function"
root_cmd echo "test" ||
die 1 "${underline}get_su_cmd:${nounderline} 'FAIL' - Failed to run test command as root."
die 1 "${underline}get_su_cmd:${nounderline} Failed to run test command as root."

if test "${ci}" = "1"; then
root_output="$(timeout --kill-after 5 5 sudo --non-interactive -- test -d /usr 2>&1)"
if test -n "${root_output}"; then
log error "sudo output: '${root_output}'"
die 1 "${underline}get_su_cmd:${nounderline} 'FAIL' - Unexpected non-empty output for sudo test in CI mode."
die 1 "${underline}get_su_cmd:${nounderline} Unexpected non-empty output for sudo test in CI mode."
fi
return 0
fi
Expand All @@ -1560,7 +1560,7 @@ get_su_cmd(){
root_output="$(timeout --kill-after 5 5 sudo -- test -d /usr 2>&1)"
if test -n "${root_output}"; then
log error "sudo output: '${root_output}'"
die 1 "${underline}get_su_cmd:${nounderline} 'FAIL' - Unexpected non-empty output for sudo test in normal mode."
die 1 "${underline}get_su_cmd:${nounderline} Unexpected non-empty output for sudo test in normal mode."
fi
fi
}
Expand All @@ -1573,7 +1573,7 @@ get_checkhash_cmd(){
has openssl && checkhash="openssl dgst -sha512 -r" && break
has digest && checkhash="digest -a sha512" && break
test -z "${checkhash}" && {
die 1 "${underline}get_checkhash_cmd:${nounderline} 'FAIL' - Failed to find program that checks SHA512 hash sum."
die 1 "${underline}get_checkhash_cmd:${nounderline} Failed to find program that checks SHA512 hash sum."
}
done
}
Expand Down Expand Up @@ -1693,7 +1693,7 @@ set_trap(){
## Check if system status is supported
get_system_stat(){
if [ "${arch}" != "x86_64" ]; then
die 101 "${underline}Architecture Check:${nounderline} 'FAIL' - Only supported architecture is 'x86_64', yours is: '${arch}'."
die 101 "${underline}Architecture Check:${nounderline} Only supported architecture is 'x86_64', yours is: '${arch}'."
fi

## https://www.whonix.org/wiki/RAM#Whonix_RAM_and_VRAM_Defaults
Expand Down Expand Up @@ -1767,7 +1767,7 @@ get_system_stat(){

if [ "${free_space_available}" -lt "$free_space_required" ]; then
die 101 "\
${underline}Free Disk Space Check:${nounderline} 'FAIL' - Insufficient free disk space!
${underline}Free Disk Space Check:${nounderline} Insufficient free disk space!
- available: '${free_space_available}G'
- required : '${free_space_required}G'
Expand Down Expand Up @@ -1961,10 +1961,10 @@ get_version(){
## that could inhibit the user from seeing the error message.
## The user would still see a failed exit code.
[ "${guest_version%%*[^0-9.]*}" ] ||
die 1 "${underline}Version Check:${nounderline} 'FAIL' - Invalid guest version: contains unexpected characters."
die 1 "${underline}Version Check:${nounderline} Invalid guest version: contains unexpected characters."
## block string containing more than 12 chars
[ "${#guest_version}" -le 12 ] ||
die 1 "${underline}Version Check:${nounderline} 'FAIL' - Invalid guest version: contains more than 12 characters."
die 1 "${underline}Version Check:${nounderline} Invalid guest version: contains more than 12 characters."
}


Expand Down Expand Up @@ -2019,7 +2019,7 @@ download_files(){
log_time
log_run touch "${download_flag}"
else
die 103 "${underline}Download:${nounderline} 'FAIL' - Failed to download files."
die 103 "${underline}Download:${nounderline} Failed to download files."
fi
}

Expand Down Expand Up @@ -2144,7 +2144,7 @@ get_virtualization(){
msr="/dev/cpu/0/msr"
if root_cmd test ! -r "${msr}"; then
root_cmd modprobe msr ||
die 1 "${underline}modprobe:${nounderline} 'FAIL' - Could not add module 'msr' to the kernel."
die 1 "${underline}modprobe:${nounderline} Could not add module 'msr' to the kernel."
fi
if root_cmd test ! -r "${msr}"; then
log error "Cannot read: '${msr}'"
Expand Down Expand Up @@ -2241,12 +2241,12 @@ get_download_links(){
## does not have TLS for Rsync
## When using rsync-ssl, this message appears:
## rsync: did not see server greeting
die 1 "${underline}Mirror Selection:${nounderline} 'FAIL' - Mirror ${mirror} doesn't support TLS for rsync."
die 1 "${underline}Mirror Selection:${nounderline} Mirror ${mirror} doesn't support TLS for rsync."
site_download_clearnet="ftp.icm.edu.pl/pub/Linux/dist/${guest}"
site_download_onion=""
;;
5)
die 1 "${underline}Mirror Selection:${nounderline} 'FAIL' - Mirror ${mirror} is currently using an invalid certificate."
die 1 "${underline}Mirror Selection:${nounderline} Mirror ${mirror} is currently using an invalid certificate."
site_download_clearnet="mirror.gigenet.com/${guest}"
site_download_onion=""
;;
Expand Down Expand Up @@ -2280,7 +2280,7 @@ get_download_links(){
url_origin="${protocol_prefix_onion}://www.${site_onion}"
## URL to download files from.
test -n "${site_download_onion}" ||
die 1 "${underline}Mirror Selection:${nounderline} 'FAIL' - Mirror ${mirror} doesn't provide an onion service."
die 1 "${underline}Mirror Selection:${nounderline} Mirror ${mirror} doesn't provide an onion service."
url_download="${url_download_onion}"
## Used to query version number.
url_version_domain="http://www.${site_onion}"
Expand Down Expand Up @@ -2318,7 +2318,7 @@ get_download_links(){

kvm)
if test "${testers}" = "1"; then
die 1 "${underline}Version Selection:${nounderline} 'FAIL' - KVM does not have testers version."
die 1 "${underline}Version Selection:${nounderline} KVM does not have testers version."
#url_version_template=""
else
url_version_template="Version_KVM"
Expand Down Expand Up @@ -2385,8 +2385,8 @@ check_integrity(){
return 0
fi
log notice "Performing integrity checks..."
check_signature || die 104 "${underline}Signify Signature Verification:${nounderline} 'FAIL' - Failed to verify signature."
check_hash || die 104 "${underline}SHA512 Hash Verification:${nounderline} 'FAIL' - Failed hash checking."
check_signature || die 104 "${underline}Signify Signature Verification:${nounderline} Failed to verify signature."
check_hash || die 104 "${underline}SHA512 Hash Verification:${nounderline} Failed hash checking."
}


Expand Down Expand Up @@ -2429,7 +2429,7 @@ main(){
log notice "If you wish to cancel installation, press Ctrl+C."
fi
## The license function sleeps for some seconds to give time to abort
check_license || die 100 "${underline}License Check:${nounderline} 'FAIL' - User declined the license."
check_license || die 100 "${underline}License Check:${nounderline} User declined the license."

pre_check

Expand Down Expand Up @@ -2461,7 +2461,7 @@ main(){
cmd_check_internet="timeout --foreground ${transfer_max_time_small_file} ${transfer_proxy_prefix:-} ${transfer_utility} ${transfer_proxy_suffix:-} ${transfer_dryrun_opt} ${transfer_size_opt} ${transfer_size_test_connection} ${url_origin}"
log info "Executing: $ ${cmd_check_internet}"
${cmd_check_internet} >/dev/null ||
die $? "${underline}Connectivity Test:${nounderline} 'FAIL' - Cannot connect to ${url_origin}, perhaps no internet?"
die $? "${underline}Connectivity Test:${nounderline} Cannot connect to ${url_origin}, perhaps no internet?"
log notice "Connection to ${url_origin} succeeded."
fi
get_version "${url_version}"
Expand All @@ -2473,7 +2473,7 @@ main(){

## Check again for download flag after version was queried.
if should_download; then
download_files || die 103 "${underline}Download:${nounderline} 'FAIL' - Failed to download files."
download_files || die 103 "${underline}Download:${nounderline} Failed to download files."
fi
else
log notice "Version: '${guest_version}'"
Expand Down

0 comments on commit 5820d57

Please sign in to comment.