-
Notifications
You must be signed in to change notification settings - Fork 10
Fix bugs and improve VM import handling #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a925a8e
6c747a0
b826117
044de5b
1bc4215
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,7 @@ format <guest-interface-installer>. | |
| `-l`, `--log-level`=<level> | ||
|
|
||
| Define the logging level. Options: debug, info, notice (default), warn, error. | ||
| Log messages below the specified level are displayed. | ||
| Log messages at or above the specified level are displayed. | ||
|
|
||
| `-k`, `--no-boot` | ||
|
|
||
|
|
@@ -116,10 +116,6 @@ format <guest-interface-installer>. | |
|
|
||
| Enable dirty mode, where the program continues despite errors. | ||
|
|
||
| `--no-show-errors` | ||
|
|
||
| Suppress error messages. | ||
|
|
||
|
Comment on lines
-119
to
-122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in an earlier commit. |
||
| `--ci` | ||
|
|
||
| Enable CI mode for testing within Continuous Integration (CI) environments. | ||
|
|
@@ -132,7 +128,7 @@ format <guest-interface-installer>. | |
|
|
||
| Activate development mode, which sets the default download version to an empty image. | ||
|
|
||
| `--noupgrade` | ||
| `--noupdate` | ||
|
Comment on lines
-135
to
+131
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. (Typo was my fault.) |
||
|
|
||
| Skip package manager list update. For development only. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -984,6 +984,13 @@ test_pkg() { | |
|
|
||
|
|
||
| check_vm_running_general() { | ||
| if [ "${virtualbox_only}" = "1" ]; then | ||
| return 0 | ||
| fi | ||
| if [ "${hypervisor}" = "kvm" ]; then | ||
| return 0 | ||
| fi | ||
|
|
||
|
Comment on lines
+987
to
+993
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted with tweaks. |
||
| case "${guest}" in | ||
| whonix) | ||
| check_vm_running_virtualbox "${guest_full_vm_name_gateway}" | ||
|
|
@@ -1178,8 +1185,9 @@ vm_delete_maybe() { | |
| die 1 "${underline}Existing VM Check Result:${nounderline} '--import-only' option was set to 'gateway', but it already exists and '--destroy-existing-guest' option was not set." | ||
| elif [ "${workstation_exists}" = "1" ] && [ "${import_only}" = "workstation" ] ; then | ||
| die 1 "${underline}Existing VM Check Result:${nounderline} '--import-only' option was set to 'workstation', but it already exists and '--destroy-existing-guest' option was not set." | ||
| elif [ "${import_only}" = "both" ] && [ "${gateway_exists}" = "1" ] && [ "${workstation_exists}" = "1" ]; then | ||
| die 1 "${underline}Existing VM Check Result:${nounderline} '--import-only' option was set to 'both', but both VMs already exist and '--destroy-existing-guest' option was not set." | ||
| fi | ||
| ## FIXME: Shouldn't import_only=both be handled here? | ||
|
Comment on lines
+1188
to
-1182
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mostly accepted, but the |
||
| else | ||
| log info "Existing VM Check: Neither '--destroy-existing-guest' nor '--import-only' option was set, ok." | ||
| fi | ||
|
|
@@ -1356,7 +1364,7 @@ import_guest() { | |
| fi | ||
|
|
||
| if [ "${no_import}" = "1" ]; then | ||
| log notice "VM Import: Not importing guest via '--import-only' option." | ||
| log notice "VM Import: Not importing guest via '--no-import' option." | ||
|
Comment on lines
-1359
to
+1367
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| end_installer | ||
| fi | ||
|
|
||
|
|
@@ -1635,6 +1643,26 @@ get_pattern_sources_deb822_debian() { | |
| fi | ||
| done < "${file}" | ||
|
|
||
| ## Check the last stanza in case the file does not end with an empty line. | ||
| match_hit='yes' | ||
| if [ -n "${types_pattern}" ] \ | ||
| && ! [[ "${current_types}" =~ ${types_pattern} ]]; then | ||
| match_hit='no' | ||
| elif [ -n "${uris_pattern}" ] \ | ||
| && ! [[ "${current_uris}" =~ ${uris_pattern} ]]; then | ||
| match_hit='no' | ||
| elif [ -n "${suites_pattern}" ] \ | ||
| && ! [[ "${current_suites}" =~ ${suites_pattern} ]]; then | ||
| match_hit='no' | ||
| elif [ -n "${components_pattern}" ] \ | ||
| && ! [[ "${current_components}" =~ ${components_pattern} ]]; then | ||
| match_hit='no' | ||
| fi | ||
|
|
||
| if [ "${match_hit}" = 'yes' ]; then | ||
| return 0 | ||
| fi | ||
|
|
||
|
Comment on lines
+1646
to
+1665
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idea accepted, but there's an easier way to do this; just read the file into memory, append an extra blank line at the end, then parse that. |
||
| return 1 | ||
| } | ||
|
|
||
|
|
@@ -1917,12 +1945,13 @@ If that doesn't resolve the issue, consider reaching out to your operating syste | |
| #install_pkg torsocks | ||
| #fi | ||
|
|
||
| install_signify signify-openbsd torsocks | ||
| install_signify signify-openbsd | ||
| install_pkg torsocks | ||
|
Comment on lines
-1920
to
+1949
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| } | ||
|
|
||
|
|
||
| add_user_to_vbox_group() { | ||
| if id --name --groups "${id_of_user}" | grep -w -- "${virtualbox_linux_user_group}\$" >/dev/null; then | ||
| if id --name --groups "${id_of_user}" | grep -w -- "${virtualbox_linux_user_group}" >/dev/null; then | ||
|
Comment on lines
-1925
to
+1954
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| log info "Linux Group Configuration: Account '${id_of_user}' is already a member of the Linux group 'vboxusers'." | ||
| return 0 | ||
| fi | ||
|
|
@@ -3670,8 +3699,8 @@ get_download_links() { | |
| ;; | ||
| *) | ||
| ## Variables need to be set for --virtualbox-only. | ||
| site_clearnet="${site_onion_kicksecure}" | ||
| site_onion="${site_clearnet_kicksecure}" | ||
| site_clearnet="${site_clearnet_kicksecure}" | ||
| site_onion="${site_onion_kicksecure}" | ||
|
Comment on lines
-3673
to
+3703
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| ;; | ||
| esac | ||
|
|
||
|
|
@@ -3845,7 +3874,7 @@ check_hash() { | |
|
|
||
| shafile="${1}" | ||
| dir="$(dirname -- "${shafile}")" | ||
| log info "Checking SHA512 checksum: '${shafile}" | ||
| log info "Checking SHA512 checksum: '${shafile}'" | ||
|
Comment on lines
-3848
to
+3877
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| ## $checkhash needs to be executed on the same folder as the compared file. | ||
| log info "Changing to directory: '${dir}'" | ||
| if [ -n "${target_user}" ]; then | ||
|
|
@@ -4039,7 +4068,6 @@ User Options: | |
| -h, --help Show this help message and exit. | ||
|
|
||
| Developer options: | ||
| --no-show-errors Suppress error messages. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in an earlier commit. |
||
| --allow-errors Continue execution despite errors. Dirty mode. Use with caution. | ||
| --mirror=<number> Choose a download mirror by index. Defaults to mirror 0 for | ||
| clearnet and mirror 0 for onion if unspecified. | ||
|
|
@@ -4049,7 +4077,7 @@ Developer options: | |
| 2 [HU] quantum-mirror.hu | ||
| --redownload Re-download the guest image, even if previously successful. | ||
| --import-only=<vm> Select specific VM to import. Only if guest is Whonix. | ||
| Options: workstation, gateway. | ||
| Options: workstation, gateway, both. | ||
|
Comment on lines
-4052
to
+4080
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| --no-import Skip guest import. Default behavior is to import. | ||
| --destroy-existing-guest Deletes any existing virtual machine(s) and re-imports them. | ||
| Warning: This action poses a risk of data loss as it involves | ||
|
|
@@ -4497,7 +4525,7 @@ Reboot into sysmaint session and rerun this installer." | |
| else | ||
| local log_entries | ||
| log_entries=( "${log_dir_main}"/* ) | ||
| last_run_integer="$(printf '%s\0' "${log_entries[@]}" | sort -zrn | tr '\0' '\n' | head --lines=1)" || true | ||
| last_run_integer="$(printf '%s\n' "${log_entries[@]##*/}" | sort -rn | head --lines=1)" || true | ||
|
Comment on lines
-4500
to
+4528
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. (Didn't realize the log_entries array was going to end up containing a list of paths rather than basenames.) |
||
| if [ -z "${last_run_integer}" ] \ | ||
| || ! is_whole_number "${last_run_integer}"; then | ||
| last_run_integer='1' | ||
|
|
@@ -4594,7 +4622,7 @@ log_term_and_file() { | |
| 2> >(run_as_target_user tee -a -- "${log_file_debug}" >&2) | ||
|
|
||
| temp_folder="$(mktemp --directory)" | ||
| xtrace_fifo="/${temp_folder}/xtrace_fifo" | ||
| xtrace_fifo="${temp_folder}/xtrace_fifo" | ||
|
Comment on lines
-4597
to
+4625
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| mkfifo -m 600 -- "$xtrace_fifo" | ||
|
|
||
| if [ "${log_level}" = "debug" ] || test -o xtrace; then | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ _dist_installer_cli() | |
| --guest-version | --socks-proxy | --onion | --non-interactive | \ | ||
| --no-import | --no-boot | --redownload | \ | ||
| --destroy-existing-guest | --dev | --ci | --dry-run | \ | ||
| --getopt | --no-show-errors | --allow-errors | --testers | \ | ||
| --getopt | --allow-errors | --testers | \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in an earlier commit. |
||
| --noupdate | --noupgrade | --virtualbox-only | --oracle-repo | \ | ||
| --version | --help ) | ||
| return | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,7 @@ helper_path="/usr/libexec/helper-scripts/" | |
|
|
||
| if ! test -d "$helper_path" ; then | ||
| echo "$0: ERROR: directory helper_path '$helper_path' does not exist!" >&2 | ||
| exit 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accepted. |
||
| fi | ||
|
|
||
| cp -- "${template}" "${target}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ args=( | |
| '(--destroy-existing-guest)'--destroy-existing-guest'[Delete and re-import. Danger! Risk of data loss!]' | ||
| '(-n --non-interactive)'{-n,--non-interactive}'[Set non-interactive mode]' | ||
| '(--allow-errors)'--allow-errors'[Set dirty mode]' | ||
| '(--no-show-errors)'--no-show-errors'[Hide errors]' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in an earlier commit. |
||
| '(--testers)'--testers'[Set testers mode]' | ||
| '(-D --dev)'{-D,--dev}'[Set dev mode]' | ||
| '(--noupdate)'--noupdate'[Skip package manager list update (dev only)]' | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accepted.