-
Notifications
You must be signed in to change notification settings - Fork 85
should override PORT #606
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
base: main
Are you sure you want to change the base?
should override PORT #606
Changes from all commits
50298c6
ed54aa9
d9807e0
1e78f97
cf3fbed
582adaa
469f1cd
6bc4558
e39a012
484936a
b88d30a
9561764
97d3340
d59ed92
ec95aae
24919cf
b26906f
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,22 @@ | ||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # DEBUG=1 | ||||||||||||||||||||||||||
| set -eo pipefail | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| error() { | ||||||||||||||||||||||||||
| printf "💀 ERROR: %s\n" "$@" | ||||||||||||||||||||||||||
| printf "💀 ERROR: %s\n" "$*" >&2 | ||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| warn() { | ||||||||||||||||||||||||||
| printf "⚠️ WARN: %s\n" "$*" >&2 | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| debug() { | ||||||||||||||||||||||||||
| [[ "$${DEBUG:-0}" == "1" ]] || return 0 | ||||||||||||||||||||||||||
| printf "🐛 DEBUG: %s\n" "$*" >&2 | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Function to check if KasmVNC is already installed | ||||||||||||||||||||||||||
| check_installed() { | ||||||||||||||||||||||||||
| if command -v kasmvncserver &> /dev/null; then | ||||||||||||||||||||||||||
|
|
@@ -282,6 +292,68 @@ patch_kasm_http_files() { | |||||||||||||||||||||||||
| fix_server_index_file "$homedir" | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| health_check_with_retries() { | ||||||||||||||||||||||||||
| local max_attempts=3 | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| local attempt=1 | ||||||||||||||||||||||||||
| local check_tool | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if command -v curl &> /dev/null; then | ||||||||||||||||||||||||||
| check_tool=(curl -s -f -o /dev/null) | ||||||||||||||||||||||||||
| elif command -v wget &> /dev/null; then | ||||||||||||||||||||||||||
| check_tool=(wget -q -O-) | ||||||||||||||||||||||||||
| elif command -v busybox &> /dev/null; then | ||||||||||||||||||||||||||
| check_tool=(busybox wget -O-) | ||||||||||||||||||||||||||
|
Comment on lines
+303
to
+305
|
||||||||||||||||||||||||||
| check_tool=(wget -q -O-) | |
| elif command -v busybox &> /dev/null; then | |
| check_tool=(busybox wget -O-) | |
| check_tool=(wget -q -O /dev/null) | |
| elif command -v busybox &> /dev/null; then | |
| check_tool=(busybox wget -q -O /dev/null) |
Copilot
AI
Dec 17, 2025
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.
The busybox wget command with -O- flag will send output to stdout. This conflicts with the health check logic since the function redirects to /dev/null in line 311, but for busybox wget you should use busybox wget -q -O /dev/null or busybox wget --spider -q to properly discard output and just check connectivity. Using -O- will download the content to stdout unnecessarily.
| check_tool=(busybox wget -O-) | |
| check_tool=(busybox wget --spider -q) |
Copilot
AI
Dec 17, 2025
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.
The health_check_with_retries function introduces new behavior but lacks test coverage. Since this module has existing tests (main.test.ts), consider adding test cases that verify the retry logic, timeout behavior, and the interaction with different download tools (curl, wget, busybox).
Copilot
AI
Dec 17, 2025
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.
The check_port_owned_by_user function lacks a comment describing its purpose, parameters, and return values. Consider adding documentation that explains it checks if a given port is owned by the current user, accepts a port number as parameter, and returns 0 if owned by user or 1 otherwise.
| # check_port_owned_by_user | |
| # Checks whether a given TCP port is currently listened to by a process owned | |
| # by the current user. | |
| # | |
| # Arguments: | |
| # $1 - TCP port number to check. | |
| # | |
| # Returns: | |
| # 0 - if a process owned by the current user is listening on the port. | |
| # 1 - otherwise (including when lsof is not available or no listener exists). |
Copilot
AI
Dec 17, 2025
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.
The warning message contains inconsistent formatting with "skip" instead of "skipping". For consistency with other messages in the codebase, it should read "lsof not found, skipping port ownership check".
| warn "lsof not found, skip port ownership check" | |
| warn "lsof not found, skipping port ownership check" |
Copilot
AI
Dec 17, 2025
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.
When lsof is not found, the function returns 1 (failure), which means check_port_owned_by_user will indicate the port is not owned by the user. This causes the error handling in lines 375-387 to skip the health check fallback logic when lsof is unavailable. Instead, when lsof is not available, the function should either return 0 (assuming success) to allow the health check to proceed, or the caller should handle this case explicitly.
| return 1 | |
| return 0 |
Copilot
AI
Dec 17, 2025
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.
The check_port_owned_by_user function introduces new behavior but lacks test coverage. Since this module has existing tests (main.test.ts), consider adding test cases that verify port ownership detection, the lsof fallback behavior, and different user scenarios.
Copilot
AI
Dec 17, 2025
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.
The new error handling logic for exit code 255 with port ownership checking and health check retries lacks test coverage. Since this module has existing tests (main.test.ts), consider adding test cases that verify behavior when the port is already in use by the same user, when health checks pass/fail, and when the port is owned by a different user.
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.
The health_check_with_retries function lacks a comment describing its purpose, parameters, and return values. Consider adding documentation that explains it performs health checks with retry logic, returns 0 on success and 1 on failure after max attempts.