Skip to content

Commit fc071e0

Browse files
chglCopilotmatifaliDevelopmentCats
authored
refactor: refactored get_http_dir (#360)
Closes # ## Description <!-- Briefly describe what this PR does and why --> I just couldn't get the script to execute properly in its current form. I saw e.g. ```console [[: 1989{#d[@]}: syntax error: invalid arithmetic operator (error token is "{#d[@]}") ``` when trying to run the script locally. (GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)). This uses a likely simpler bash script, but requires both grep and awk. ## Type of Change - [ ] New module - [x] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information <!-- Delete this section if not applicable --> **Path:** `registry/coder/modules/kasmvnc` **New version:** `v1.2.3` **Breaking change:** [ ] Yes [x] No ## Testing & Validation - [ ] Tests pass (`bun test`) - [ ] Code formatted (`bun run fmt`) - [ ] Changes tested locally ## Related Issues <!-- Link related issues or write "None" if not applicable --> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Atif Ali <[email protected]> Co-authored-by: DevCats <[email protected]>
1 parent d516aff commit fc071e0

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

registry/coder/modules/kasmvnc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Automatically install [KasmVNC](https://kasmweb.com/kasmvnc) in a workspace, and
1414
module "kasmvnc" {
1515
count = data.coder_workspace.me.start_count
1616
source = "registry.coder.com/coder/kasmvnc/coder"
17-
version = "1.2.3"
17+
version = "1.2.4"
1818
agent_id = coder_agent.example.id
1919
desktop_environment = "xfce"
2020
subdomain = true

registry/coder/modules/kasmvnc/run.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ install_deb() {
6060
sudo apt-get -o DPkg::Lock::Timeout=300 -qq update
6161
fi
6262

63+
echo "Installing required Perl DateTime module..."
64+
DEBIAN_FRONTEND=noninteractive sudo apt-get -o DPkg::Lock::Timeout=300 install --yes -qq --no-install-recommends --no-install-suggests libdatetime-perl
65+
6366
DEBIAN_FRONTEND=noninteractive sudo apt-get -o DPkg::Lock::Timeout=300 install --yes -qq --no-install-recommends --no-install-suggests "$kasmdeb"
6467
rm "$kasmdeb"
6568
}
@@ -233,19 +236,17 @@ get_http_dir() {
233236

234237
# Check the system configuration path
235238
if [[ -e /etc/kasmvnc/kasmvnc.yaml ]]; then
236-
d=($(grep -E "^\s*httpd_directory:.*$" /etc/kasmvnc/kasmvnc.yaml))
237-
# If this grep is successful, it will return:
238-
# httpd_directory: /usr/share/kasmvnc/www
239-
if [[ $${#d[@]} -eq 2 && -d "$${d[1]}" ]]; then
240-
httpd_directory="$${d[1]}"
239+
d=$(grep -E '^\s*httpd_directory:.*$' "/etc/kasmvnc/kasmvnc.yaml" | awk '{print $$2}')
240+
if [[ -n "$d" && -d "$d" ]]; then
241+
httpd_directory=$d
241242
fi
242243
fi
243244

244245
# Check the home directory for overriding values
245246
if [[ -e "$HOME/.vnc/kasmvnc.yaml" ]]; then
246-
d=($(grep -E "^\s*httpd_directory:.*$" "$HOME/.vnc/kasmvnc.yaml"))
247-
if [[ $${#d[@]} -eq 2 && -d "$${d[1]}" ]]; then
248-
httpd_directory="$${d[1]}"
247+
d=$(grep -E '^\s*httpd_directory:.*$' "$HOME/.vnc/kasmvnc.yaml" | awk '{print $$2}')
248+
if [[ -n "$d" && -d "$d" ]]; then
249+
httpd_directory=$d
249250
fi
250251
fi
251252
echo $httpd_directory

0 commit comments

Comments
 (0)