Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
adrelanos committed Jun 23, 2023
1 parent 97462a6 commit 3c13d0b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions usr/bin/installer-dist
Expand Up @@ -872,12 +872,12 @@ check_vm_exists_virtualbox(){
workstation_exists=0
gateway_exists=0
if vboxmanage showvminfo \
"${guest_pretty}-Gateway-${interface_all_caps}" >/dev/null 2>&1
"${guest_pretty}-Gateway-${interface_name}" >/dev/null 2>&1
then
gateway_exists=1
fi
if vboxmanage showvminfo \
"${guest_pretty}-Workstation-${interface_all_caps}" >/dev/null 2>&1
"${guest_pretty}-Workstation-${interface_name}" >/dev/null 2>&1
then
workstation_exists=1
fi
Expand Down Expand Up @@ -907,7 +907,7 @@ check_vm_exists_virtualbox(){
else
log warn "Deleting previously imported gateway because reimport is set."
log_run vboxmanage unregistervm \
"${guest_pretty}-Gateway-${interface_all_caps}" --delete
"${guest_pretty}-Gateway-${interface_name}" --delete
fi
fi
## Remove Workstation if it exists.
Expand All @@ -919,7 +919,7 @@ check_vm_exists_virtualbox(){
else
log warn "Deleting previously imported workstation because reimport is set."
log_run vboxmanage unregistervm \
"${guest_pretty}-Workstation-${interface_all_caps}" --delete
"${guest_pretty}-Workstation-${interface_name}" --delete
fi
fi
elif test -n "${import_only}"; then
Expand Down Expand Up @@ -953,15 +953,15 @@ check_vm_exists_virtualbox(){
;;
kicksecure)
if vboxmanage showvminfo \
"${guest_pretty}-${interface_all_caps}" >/dev/null 2>&1
"${guest_pretty}-${interface_name}" >/dev/null 2>&1
then
log notice "${underline}Existing VM Check:${nounderline} Virtual Machine(s) were imported previously."
if test "${reimport}" = "1"; then
## If VMs exists and reimport is set, remove VMs as they are gonna
## be imported later by main.
log warn "Deleting previously imported Virtual Machine(s) because reimport is set."
log_run vboxmanage unregistervm \
"${guest_pretty}-${interface_all_caps}" --delete
"${guest_pretty}-${interface_name}" --delete
else
## 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 @@ -1008,11 +1008,11 @@ check_guest_boot(){
## Ask user to start guest or not
case "${guest}" in
whonix)
log notice "Available guest: ${guest_pretty}-Gateway-${interface_all_caps}"
log notice "Available guest: ${guest_pretty}-Workstation-${interface_all_caps}"
log notice "Available guest: ${guest_pretty}-Gateway-${interface_name}"
log notice "Available guest: ${guest_pretty}-Workstation-${interface_name}"
;;
kicksecure)
log notice "Available guest: ${guest_pretty}-${interface_all_caps}"
log notice "Available guest: ${guest_pretty}-${interface_name}"
;;
esac
log notice "${bold}Question:${nobold} Do you want to start the ${guest_pretty} Virtual Machine(s) now? [y/n] (default: yes): "
Expand Down Expand Up @@ -1121,13 +1121,13 @@ start_virtualbox(){
case "${guest}" in
whonix)
log_run vboxmanage startvm \
"${guest_pretty}-Gateway-${interface_all_caps}" || virtualbox_start_failed
"${guest_pretty}-Gateway-${interface_name}" || virtualbox_start_failed
log_run vboxmanage startvm \
"${guest_pretty}-Workstation-${interface_all_caps}" || virtualbox_start_failed
"${guest_pretty}-Workstation-${interface_name}" || virtualbox_start_failed
;;
kicksecure)
log_run vboxmanage startvm \
"${guest_pretty}-${interface_all_caps}" || virtualbox_start_failed
"${guest_pretty}-${interface_name}" || virtualbox_start_failed
;;
esac
log notice "${underline}Virtual Machine Startup Result:${nounderline} ${green}${bold}SUCCESS${nobold}${nocolor}"
Expand Down Expand Up @@ -2295,7 +2295,7 @@ main(){

guest_pretty="$(capitalize_first_char "${guest}")"
interface_pretty="$(capitalize_first_char "${interface}")"
interface_all_caps="$(echo "${interface}" | tr "[:lower:]" "[:upper:]")"
interface_name="$(echo "${interface}" | tr "[:lower:]" "[:upper:]")"

case "${hypervisor}" in
virtualbox)
Expand Down Expand Up @@ -2344,7 +2344,7 @@ main(){
## specified the desired version.
## If version is set, use it now to set the download flag path.
if test -n "${guest_version}"; then
guest_file="${guest_pretty}-${interface_all_caps}-${guest_version}"
guest_file="${guest_pretty}-${interface_name}-${guest_version}"
download_flag="${directory_prefix}/${guest_file}.${guest_file_ext}.flag"
fi

Expand All @@ -2360,7 +2360,7 @@ main(){
fi
get_version "${url_version}"
log notice "Version: ${guest_version}."
guest_file="${guest_pretty}-${interface_all_caps}-${guest_version}"
guest_file="${guest_pretty}-${interface_name}-${guest_version}"
download_flag="${directory_prefix}/${guest_file}.${guest_file_ext}.flag"
url_domain="${url_domain}/${guest_version:?}"
url_guest_file="${url_domain}/${guest_file}"
Expand Down

0 comments on commit 3c13d0b

Please sign in to comment.