@@ -9,19 +9,16 @@ LOG_PATH="${LOG_PATH}"
99PORT=" ${PORT} "
1010# Pinned version (e.g., v1.19.16); overrides latest release discovery if set
1111PINNED_VERSION=" ${PINNED_VERSION} "
12- # Custom CLI Arguments# The variable from Terraform is a single, comma-separated string.
13- # We need to split it into a proper bash array using the comma (,) as the delimiter.
14- IFS=' ,' read -r -a ARGUMENTS <<< " ${ARGUMENTS}"
12+ # Custom CLI Arguments
13+ # The variable from Terraform is a series of quoted and space separated strings.
14+ # We need to parse it into a proper bash array.
15+ ARGUMENTS=(${ARGUMENTS} )
1516
1617# VARIABLE appears unused. Verify use (or export if used externally).
1718# shellcheck disable=SC2034
1819MODULE_NAME=" Copyparty"
1920
20- # VARIABLE appears unused. Verify use (or export if used externally).
21- # shellcheck disable=SC2034
22- BOLD=' \033[0;1m'
23-
24- printf ' %sInstalling %s ...\n\n' " $$ {BOLD}" " $$ {MODULE_NAME}"
21+ printf ' \e[1mInstalling %s ...\e[0m\n' " $$ {MODULE_NAME}"
2522
2623# Add code here
2724# Use variables from the templatefile function in main.tf
@@ -32,7 +29,7 @@ if ! command -v python3 &> /dev/null; then
3229 printf " ❌ Python3 could not be found. Please install it to continue.\n"
3330 exit 1
3431fi
35- printf " ✅ Python3 is installed.\n\n "
32+ printf " ✅ Python3 is installed.\n"
3633
3734RELEASE_TO_INSTALL=" "
3835# Install provided version to pin, otherwise discover latest github release from `https://github.com/9001/copyparty`.
@@ -44,7 +41,7 @@ if [[ -n "$${PINNED_VERSION}" ]]; then
4441 exit 1
4542 fi
4643 RELEASE_TO_INSTALL=" $$ {PINNED_VERSION}"
47- printf " ✅ Using pinned version %s.\n\n " " $$ {RELEASE_TO_INSTALL}"
44+ printf " ✅ Using pinned version %s.\n" " $$ {RELEASE_TO_INSTALL}"
4845else
4946 printf " 🔎 Discovering latest release from GitHub...\n"
5047 # Use curl to get the latest release tag from the GitHub API and sed to parse it
5451 exit 1
5552 fi
5653 RELEASE_TO_INSTALL=" $$ {LATEST_RELEASE}"
57- printf " 🏷️ Latest release is %s.\n\n " " $$ {RELEASE_TO_INSTALL}"
54+ printf " 🏷️ Latest release is %s.\n" " $$ {RELEASE_TO_INSTALL}"
5855fi
5956
6057# Download appropriate release version assets: `copyparty-sfx.py` and `helptext.html`.
61- printf " 🚀 Downloading copyparty v %s...\n" " $$ {RELEASE_TO_INSTALL}"
58+ printf " 🚀 Downloading copyparty %s...\n" " $$ {RELEASE_TO_INSTALL}"
6259DOWNLOAD_URL=" https://github.com/9001/copyparty/releases/download/$$ {RELEASE_TO_INSTALL}"
6360
6461printf " ⏬ Downloading copyparty-sfx.py...\n"
@@ -74,9 +71,9 @@ if ! curl -fsSL -o /tmp/helptext.html "$${DOWNLOAD_URL}/helptext.html"; then
7471fi
7572
7673chmod +x /tmp/copyparty-sfx.py
77- printf " ✅ Download complete.\n\n "
74+ printf " ✅ Download complete.\n"
7875
79- printf " 🥳 Installation complete!\n\n "
76+ printf " 🥳 Installation complete!\n"
8077
8178# Build a clean, quoted string of the command for logging purposes only.
8279log_command=" python3 /tmp/copyparty-sfx.py -p '$$ {PORT}'"
@@ -85,16 +82,16 @@ for arg in "$${ARGUMENTS[@]}"; do
8582 log_command+=" '$$ {arg}'"
8683done
8784
88- # Clear the log file and write the header and command string using printf .
85+ # Dump the executing command to a tmp file for diagnostic review .
8986{
9087 printf " === Starting copyparty at %s ===\n" " $( date) "
9188 printf " EXECUTING: %s\n" " $$ {log_command}"
92- } > " $$ {LOG_PATH} "
89+ } > " /tmp/copyparty.cmd "
9390
94- printf " 👷 Starting %s in background...\n\n " " $$ {MODULE_NAME}"
91+ printf " 👷 Starting %s in background...\n" " $$ {MODULE_NAME}"
9592
9693# Execute the actual command using the robust array expansion.
97- # Then, append its output (stdout and stderr) to the log file.
98- python3 /tmp/copyparty-sfx.py -p " $$ {PORT}" " $$ {ARGUMENTS[@]}" >> " $$ {LOG_PATH}" 2>&1 &
94+ # Then, capture its output (stdout and stderr) to the log file.
95+ python3 /tmp/copyparty-sfx.py -p " $$ {PORT}" " $$ {ARGUMENTS[@]}" > " $$ {LOG_PATH}" 2>&1 &
9996
100- printf " ✅ Service started. Check logs at %s\n\n " " $$ {LOG_PATH}"
97+ printf " ✅ Service started. Check logs at %s\n" " $$ {LOG_PATH}"
0 commit comments