Skip to content

Fix bugs and improve VM import handling#21

Closed
assisted-by-ai wants to merge 5 commits intoKicksecure:masterfrom
assisted-by-ai:claude/fix-dist-installer-bugs-5qV3X
Closed

Fix bugs and improve VM import handling#21
assisted-by-ai wants to merge 5 commits intoKicksecure:masterfrom
assisted-by-ai:claude/fix-dist-installer-bugs-5qV3X

Conversation

@assisted-by-ai
Copy link
Copy Markdown
Contributor

Summary

This PR addresses multiple bugs and improvements in the dist-installer-cli script, including fixes for VM import logic, variable assignments, string matching, and documentation updates.

Key Changes

VM Import and Deletion Logic

  • Added handling for --import-only=both option to check if both gateway and workstation VMs already exist before attempting import
  • Removed FIXME comment that was addressed by the above change
  • Added early return in check_vm_running_general() for virtualbox-only and KVM hypervisor modes to skip unnecessary VM checks

Bug Fixes

  • Fixed incorrect variable assignments in get_download_links(): swapped site_clearnet and site_onion assignments for Kicksecure (were reversed)
  • Fixed log message in import_guest(): changed '--import-only' to '--no-import' to match the actual option being checked
  • Fixed missing closing quote in check_hash() log message
  • Fixed regex anchor in add_user_to_vbox_group(): removed unnecessary \$ escape sequence from grep pattern
  • Fixed path construction in log_term_and_file(): changed /${temp_folder} to ${temp_folder} to avoid double slashes
  • Fixed log entry sorting in installer main logic: replaced null-delimited sort with newline-delimited approach for better compatibility

Package Installation

  • Separated install_signify and install_pkg torsocks into two distinct function calls instead of combining them

File Processing

  • Added logic to get_pattern_sources_deb822_debian() to check the last stanza in case the file doesn't end with an empty line, preventing missed matches

Documentation and Help Text

  • Updated help text to include both as an option for --import-only parameter
  • Removed --no-show-errors option from help text and bash/zsh completions (option no longer exists)
  • Fixed man page description: changed "below the specified level" to "at or above the specified level" for log-level documentation
  • Fixed man page typo: changed --noupgrade to --noupdate
  • Removed --no-show-errors from zsh completion definitions

Build Script

  • Added missing exit 1 statement in build script error handling when helper_path directory doesn't exist

https://claude.ai/code/session_01GD1tL2UN9BxWya2mz812cc

claude added 5 commits April 9, 2026 11:07
- Fix swapped clearnet/onion URLs for --virtualbox-only (site_clearnet
  was assigned the onion domain and vice versa)
- Fix wrong option name in import_guest() log message (said
  --import-only instead of --no-import)
- Add missing exit 1 in build-dist-installer-cli when helper_path
  directory doesn't exist (script continued after error)
- Fix duplicate --noupgrade in man page (first instance should be
  --noupdate)
- Fix double slash in xtrace_fifo path (mktemp returns absolute path,
  prepending / created //tmp/...)

https://claude.ai/code/session_01GD1tL2UN9BxWya2mz812cc
- Fix torsocks silently dropped: install_signify() only uses $1, so
  the second arg 'torsocks' on Debian was never installed. Split into
  separate install_signify and install_pkg calls.
- Fix log directory increment broken past run 2: sort -rn on full
  paths doesn't work numerically, so last_run_integer always reset
  to 1. Use ${log_entries[@]##*/} to extract basenames before sorting.
- Remove --no-show-errors leftovers from usage(), man page, bash and
  zsh completions (option was removed from code in 2023 per changelog
  but docs/completions were not cleaned up).
- Fix man page log-level description: said "below" but log levels
  show messages at or above the specified level.

https://claude.ai/code/session_01GD1tL2UN9BxWya2mz812cc
When --import-only=both was used without --destroy-existing-guest and
both VMs already existed, the code silently fell through without error
instead of telling the user to pass --destroy-existing-guest. This was
marked with a FIXME comment.

https://claude.ai/code/session_01GD1tL2UN9BxWya2mz812cc
- Fix missing closing quote in check_hash log message (line 3850):
  "Checking SHA512 checksum: '${shafile}" was missing trailing quote.
- Add hypervisor/virtualbox-only guards to check_vm_running_general:
  function called VirtualBox-specific vboxmanage commands even when
  hypervisor was KVM. Matches the guards in check_vm_exists_general.
- Add missing 'both' option to --import-only in usage() output:
  the code, man page, and completions all accept 'both' but --help
  only showed 'workstation, gateway'.

https://claude.ai/code/session_01GD1tL2UN9BxWya2mz812cc
- Fix deb822 parser (get_pattern_sources_deb822_debian): the match
  check only triggered on empty lines (stanza separators). If the
  last stanza in a .sources file had no trailing blank line, it was
  never checked, so existing repository configurations could go
  undetected and get re-added.
- Fix add_user_to_vbox_group grep pattern: the '\$' end-of-line
  anchor meant the group was only detected if vboxusers was the
  last group in 'id --groups' output. If any group was added after
  vboxusers, the check failed and tried to re-add the user. The
  -w flag alone is sufficient for whole-word matching.

https://claude.ai/code/session_01GD1tL2UN9BxWya2mz812cc
Copy link
Copy Markdown
Contributor

@ArrayBolt3 ArrayBolt3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly accepted in ArrayBolt3@4c71b99.


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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted.

Comment on lines -119 to -122
`--no-show-errors`

Suppress error messages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in an earlier commit.

Comment on lines -135 to +131
`--noupgrade`
`--noupdate`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted. (Typo was my fault.)

Comment on lines +987 to +993
if [ "${virtualbox_only}" = "1" ]; then
return 0
fi
if [ "${hypervisor}" = "kvm" ]; then
return 0
fi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted with tweaks.

Comment on lines +1188 to -1182
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?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly accepted, but the gateway_exists && workstation_exists logic needs to use ||, not &&, because import_virtualbox bails out if either VM exists, and we're trying to match the logic there.

Comment on lines -4500 to +4528
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.)

Comment on lines -4597 to +4625
xtrace_fifo="/${temp_folder}/xtrace_fifo"
xtrace_fifo="${temp_folder}/xtrace_fifo"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted.

--no-import | --no-boot | --redownload | \
--destroy-existing-guest | --dev | --ci | --dry-run | \
--getopt | --no-show-errors | --allow-errors | --testers | \
--getopt | --allow-errors | --testers | \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in an earlier commit.


if ! test -d "$helper_path" ; then
echo "$0: ERROR: directory helper_path '$helper_path' does not exist!" >&2
exit 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted.

'(--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]'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in an earlier commit.

@adrelanos adrelanos closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants