From c0e086339b7df4a98e70c8001a083641444c182f Mon Sep 17 00:00:00 2001 From: default Date: Tue, 28 Oct 2025 10:35:02 -0500 Subject: [PATCH 1/7] Allow for commas in Copyparty arguments --- .../modules/copyparty/copyparty.tftest.hcl | 27 +++++++++++++++++-- registry/djarbz/modules/copyparty/main.tf | 2 +- registry/djarbz/modules/copyparty/run.sh | 6 ++--- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/registry/djarbz/modules/copyparty/copyparty.tftest.hcl b/registry/djarbz/modules/copyparty/copyparty.tftest.hcl index e6fab8439..2a823fabc 100644 --- a/registry/djarbz/modules/copyparty/copyparty.tftest.hcl +++ b/registry/djarbz/modules/copyparty/copyparty.tftest.hcl @@ -80,7 +80,7 @@ run "test_defaults" { } assert { - condition = strcontains(coder_script.copyparty.script, "IFS=',' read -r -a ARGUMENTS \u003c\u003c\u003c \"\"") + condition = strcontains(coder_script.copyparty.script, "ARGUMENTS=()") error_message = "Script content does not reflect default empty arguments" } } @@ -138,7 +138,7 @@ run "test_custom_values" { } assert { - condition = strcontains(coder_script.copyparty.script, "IFS=',' read -r -a ARGUMENTS \u003c\u003c\u003c \"--verbose,-v\"") + condition = strcontains(coder_script.copyparty.script, "ARGUMENTS=(\"--verbose\" \"-v\")") error_message = "Script content does not reflect custom arguments" } @@ -179,3 +179,26 @@ run "test_invalid_share" { var.share, ] } + +# --- Test Case 7: Comma in Arguments [Readme Example 2] --- +run "test_comma_args" { + # Arguments containing commas + variables { + agent_id = "example-agent-id" + arguments = [ + "-v", "/tmp:/tmp:r", # Share tmp directory (read-only) + "-v", "/home/coder/:/home:rw", # Share home directory (read-write) + "-v", "/work:/work:A:c,dotsrch", # Share work directory (All Perms) + "-e2dsa", # Enables general file indexing" + "--re-maxage", "900", # Rescan filesystem for changes every SEC + "--see-dots", # Show dotfiles by default if user has correct permissions on volume + "--xff-src=lan", # List of trusted reverse-proxy CIDRs (comma-separated) or `lan` for private IPs. + "--rproxy", "1", # Which ip to associate clients with, index of X-FWD IP. + ] + } + + assert { + condition = strcontains(coder_script.copyparty.script, "ARGUMENTS=(\"-v\" \"/tmp:/tmp:r\" \"-v\" \"/home/coder/:/home:rw\" \"-v\" \"/work:/work:A:c,dotsrch\" \"-e2dsa\" \"--re-maxage\" \"900\" \"--see-dots\" \"--xff-src=lan\" \"--rproxy\" \"1\")") + error_message = "Script content does not reflect Readme Example #2 arguments with commas" + } +} diff --git a/registry/djarbz/modules/copyparty/main.tf b/registry/djarbz/modules/copyparty/main.tf index 822387c1e..e9976da51 100644 --- a/registry/djarbz/modules/copyparty/main.tf +++ b/registry/djarbz/modules/copyparty/main.tf @@ -129,7 +129,7 @@ resource "coder_script" "copyparty" { LOG_PATH : var.log_path, PORT : var.port, PINNED_VERSION : var.pinned_version, - ARGUMENTS : join(",", var.arguments), + ARGUMENTS : join(" ", formatlist("\"%s\"", var.arguments)), }) run_on_start = true run_on_stop = false diff --git a/registry/djarbz/modules/copyparty/run.sh b/registry/djarbz/modules/copyparty/run.sh index a138f5402..dd817e042 100755 --- a/registry/djarbz/modules/copyparty/run.sh +++ b/registry/djarbz/modules/copyparty/run.sh @@ -11,7 +11,7 @@ PORT="${PORT}" PINNED_VERSION="${PINNED_VERSION}" # Custom CLI Arguments# The variable from Terraform is a single, comma-separated string. # We need to split it into a proper bash array using the comma (,) as the delimiter. -IFS=',' read -r -a ARGUMENTS <<< "${ARGUMENTS}" +ARGUMENTS=(${ARGUMENTS}) # VARIABLE appears unused. Verify use (or export if used externally). # shellcheck disable=SC2034 @@ -89,12 +89,12 @@ done { printf "=== Starting copyparty at %s ===\n" "$(date)" printf "EXECUTING: %s\n" "$${log_command}" -} > "$${LOG_PATH}" +} > "/tmp/copyparty.cmd" printf "👷 Starting %s in background...\n\n" "$${MODULE_NAME}" # Execute the actual command using the robust array expansion. # Then, append its output (stdout and stderr) to the log file. -python3 /tmp/copyparty-sfx.py -p "$${PORT}" "$${ARGUMENTS[@]}" >> "$${LOG_PATH}" 2>&1 & +python3 /tmp/copyparty-sfx.py -p "$${PORT}" "$${ARGUMENTS[@]}" > "$${LOG_PATH}" 2>&1 & printf "✅ Service started. Check logs at %s\n\n" "$${LOG_PATH}" From 40808b0c2a29e0400743018b2122871feeff1249 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 28 Oct 2025 10:38:33 -0500 Subject: [PATCH 2/7] chore: bump module versions (patch) --- registry/djarbz/modules/copyparty/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/registry/djarbz/modules/copyparty/README.md b/registry/djarbz/modules/copyparty/README.md index fdd3ad56e..ab535f447 100644 --- a/registry/djarbz/modules/copyparty/README.md +++ b/registry/djarbz/modules/copyparty/README.md @@ -17,7 +17,7 @@ This module installs Copyparty, an alternative to Filebrowser. module "copyparty" { count = data.coder_workspace.me.start_count source = "registry.coder.com/djarbz/copyparty/coder" - version = "1.0.0" + version = "1.0.1" } ``` @@ -35,7 +35,7 @@ Some basic command line options: module "copyparty" { count = data.coder_workspace.me.start_count source = "registry.coder.com/djarbz/copyparty/coder" - version = "1.0.0" + version = "1.0.1" agent_id = coder_agent.example.id arguments = [ "-v", "/home/coder/:/home:r", # Share home directory (read-only) @@ -51,7 +51,7 @@ module "copyparty" { module "copyparty" { count = data.coder_workspace.me.start_count source = "registry.coder.com/djarbz/copyparty/coder" - version = "1.0.0" + version = "1.0.1" agent_id = coder_agent.example.id subdomain = true arguments = [ From 3e8f76797f64636a1238ede72aae77ea3bd722b3 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 28 Oct 2025 10:46:07 -0500 Subject: [PATCH 3/7] Log formatting --- registry/djarbz/modules/copyparty/run.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/registry/djarbz/modules/copyparty/run.sh b/registry/djarbz/modules/copyparty/run.sh index dd817e042..f82f60937 100755 --- a/registry/djarbz/modules/copyparty/run.sh +++ b/registry/djarbz/modules/copyparty/run.sh @@ -17,11 +17,9 @@ ARGUMENTS=(${ARGUMENTS}) # shellcheck disable=SC2034 MODULE_NAME="Copyparty" -# VARIABLE appears unused. Verify use (or export if used externally). -# shellcheck disable=SC2034 BOLD='\033[0;1m' -printf '%sInstalling %s ...\n\n' "$${BOLD}" "$${MODULE_NAME}" +printf '%sInstalling %s ...\n' "${BOLD}" "$${MODULE_NAME}" # Add code here # Use variables from the templatefile function in main.tf @@ -32,7 +30,7 @@ if ! command -v python3 &> /dev/null; then printf "❌ Python3 could not be found. Please install it to continue.\n" exit 1 fi -printf "✅ Python3 is installed.\n\n" +printf "✅ Python3 is installed.\n" RELEASE_TO_INSTALL="" # Install provided version to pin, otherwise discover latest github release from `https://github.com/9001/copyparty`. @@ -44,7 +42,7 @@ if [[ -n "$${PINNED_VERSION}" ]]; then exit 1 fi RELEASE_TO_INSTALL="$${PINNED_VERSION}" - printf "✅ Using pinned version %s.\n\n" "$${RELEASE_TO_INSTALL}" + printf "✅ Using pinned version %s.\n" "$${RELEASE_TO_INSTALL}" else printf "🔎 Discovering latest release from GitHub...\n" # Use curl to get the latest release tag from the GitHub API and sed to parse it @@ -54,7 +52,7 @@ else exit 1 fi RELEASE_TO_INSTALL="$${LATEST_RELEASE}" - printf "🏷️ Latest release is %s.\n\n" "$${RELEASE_TO_INSTALL}" + printf "🏷️ Latest release is %s.\n" "$${RELEASE_TO_INSTALL}" fi # Download appropriate release version assets: `copyparty-sfx.py` and `helptext.html`. @@ -74,9 +72,9 @@ if ! curl -fsSL -o /tmp/helptext.html "$${DOWNLOAD_URL}/helptext.html"; then fi chmod +x /tmp/copyparty-sfx.py -printf "✅ Download complete.\n\n" +printf "✅ Download complete.\n" -printf "🥳 Installation complete!\n\n" +printf "🥳 Installation complete!\n" # Build a clean, quoted string of the command for logging purposes only. log_command="python3 /tmp/copyparty-sfx.py -p '$${PORT}'" @@ -91,10 +89,10 @@ done printf "EXECUTING: %s\n" "$${log_command}" } > "/tmp/copyparty.cmd" -printf "👷 Starting %s in background...\n\n" "$${MODULE_NAME}" +printf "👷 Starting %s in background...\n" "$${MODULE_NAME}" # Execute the actual command using the robust array expansion. # Then, append its output (stdout and stderr) to the log file. python3 /tmp/copyparty-sfx.py -p "$${PORT}" "$${ARGUMENTS[@]}" > "$${LOG_PATH}" 2>&1 & -printf "✅ Service started. Check logs at %s\n\n" "$${LOG_PATH}" +printf "✅ Service started. Check logs at %s\n" "$${LOG_PATH}" From de4b5354a10000fbbc3a8663c03e23be3c9e20ee Mon Sep 17 00:00:00 2001 From: default Date: Tue, 28 Oct 2025 10:52:37 -0500 Subject: [PATCH 4/7] Fix bold text --- registry/djarbz/modules/copyparty/run.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/registry/djarbz/modules/copyparty/run.sh b/registry/djarbz/modules/copyparty/run.sh index f82f60937..e28956545 100755 --- a/registry/djarbz/modules/copyparty/run.sh +++ b/registry/djarbz/modules/copyparty/run.sh @@ -17,9 +17,7 @@ ARGUMENTS=(${ARGUMENTS}) # shellcheck disable=SC2034 MODULE_NAME="Copyparty" -BOLD='\033[0;1m' - -printf '%sInstalling %s ...\n' "${BOLD}" "$${MODULE_NAME}" +printf '\e[1mInstalling %s ...\e[0m\n' "$${MODULE_NAME}" # Add code here # Use variables from the templatefile function in main.tf From 351f7a076e2a70c51a81fd462e1efc477d2fc183 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 28 Oct 2025 11:02:15 -0500 Subject: [PATCH 5/7] fix log version output --- registry/djarbz/modules/copyparty/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/djarbz/modules/copyparty/run.sh b/registry/djarbz/modules/copyparty/run.sh index e28956545..da329beff 100755 --- a/registry/djarbz/modules/copyparty/run.sh +++ b/registry/djarbz/modules/copyparty/run.sh @@ -54,7 +54,7 @@ else fi # Download appropriate release version assets: `copyparty-sfx.py` and `helptext.html`. -printf "🚀 Downloading copyparty v%s...\n" "$${RELEASE_TO_INSTALL}" +printf "🚀 Downloading copyparty %s...\n" "$${RELEASE_TO_INSTALL}" DOWNLOAD_URL="https://github.com/9001/copyparty/releases/download/$${RELEASE_TO_INSTALL}" printf "⏬ Downloading copyparty-sfx.py...\n" From 1a94f01d3c67ef608522bbf141c46e1057ad7a84 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 29 Oct 2025 11:18:04 -0500 Subject: [PATCH 6/7] Remove stray quote from comment --- registry/djarbz/modules/copyparty/README.md | 2 +- registry/djarbz/modules/copyparty/copyparty.tftest.hcl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/djarbz/modules/copyparty/README.md b/registry/djarbz/modules/copyparty/README.md index ab535f447..1209f8527 100644 --- a/registry/djarbz/modules/copyparty/README.md +++ b/registry/djarbz/modules/copyparty/README.md @@ -58,7 +58,7 @@ module "copyparty" { "-v", "/tmp:/tmp:r", # Share tmp directory (read-only) "-v", "/home/coder/:/home:rw", # Share home directory (read-write) "-v", "${local.root_dir}:/work:A:c,dotsrch", # Share work directory (All Perms) - "-e2dsa", # Enables general file indexing" + "-e2dsa", # Enables general file indexing "--re-maxage", "900", # Rescan filesystem for changes every SEC "--see-dots", # Show dotfiles by default if user has correct permissions on volume "--xff-src=lan", # List of trusted reverse-proxy CIDRs (comma-separated) or `lan` for private IPs. diff --git a/registry/djarbz/modules/copyparty/copyparty.tftest.hcl b/registry/djarbz/modules/copyparty/copyparty.tftest.hcl index 2a823fabc..a6cb66afc 100644 --- a/registry/djarbz/modules/copyparty/copyparty.tftest.hcl +++ b/registry/djarbz/modules/copyparty/copyparty.tftest.hcl @@ -189,7 +189,7 @@ run "test_comma_args" { "-v", "/tmp:/tmp:r", # Share tmp directory (read-only) "-v", "/home/coder/:/home:rw", # Share home directory (read-write) "-v", "/work:/work:A:c,dotsrch", # Share work directory (All Perms) - "-e2dsa", # Enables general file indexing" + "-e2dsa", # Enables general file indexing "--re-maxage", "900", # Rescan filesystem for changes every SEC "--see-dots", # Show dotfiles by default if user has correct permissions on volume "--xff-src=lan", # List of trusted reverse-proxy CIDRs (comma-separated) or `lan` for private IPs. From a153b2ba6cd901d3ef83a3127d69e854b82a9dd7 Mon Sep 17 00:00:00 2001 From: default Date: Wed, 29 Oct 2025 11:19:02 -0500 Subject: [PATCH 7/7] Rework comments --- registry/djarbz/modules/copyparty/run.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/registry/djarbz/modules/copyparty/run.sh b/registry/djarbz/modules/copyparty/run.sh index da329beff..993887593 100755 --- a/registry/djarbz/modules/copyparty/run.sh +++ b/registry/djarbz/modules/copyparty/run.sh @@ -9,8 +9,9 @@ LOG_PATH="${LOG_PATH}" PORT="${PORT}" # Pinned version (e.g., v1.19.16); overrides latest release discovery if set PINNED_VERSION="${PINNED_VERSION}" -# Custom CLI Arguments# The variable from Terraform is a single, comma-separated string. -# We need to split it into a proper bash array using the comma (,) as the delimiter. +# Custom CLI Arguments +# The variable from Terraform is a series of quoted and space separated strings. +# We need to parse it into a proper bash array. ARGUMENTS=(${ARGUMENTS}) # VARIABLE appears unused. Verify use (or export if used externally). @@ -81,7 +82,7 @@ for arg in "$${ARGUMENTS[@]}"; do log_command+=" '$${arg}'" done -# Clear the log file and write the header and command string using printf. +# Dump the executing command to a tmp file for diagnostic review. { printf "=== Starting copyparty at %s ===\n" "$(date)" printf "EXECUTING: %s\n" "$${log_command}" @@ -90,7 +91,7 @@ done printf "👷 Starting %s in background...\n" "$${MODULE_NAME}" # Execute the actual command using the robust array expansion. -# Then, append its output (stdout and stderr) to the log file. +# Then, capture its output (stdout and stderr) to the log file. python3 /tmp/copyparty-sfx.py -p "$${PORT}" "$${ARGUMENTS[@]}" > "$${LOG_PATH}" 2>&1 & printf "✅ Service started. Check logs at %s\n" "$${LOG_PATH}"