From 1f7bf74970988c9ba4c8a2a92e8c45620cfd02c6 Mon Sep 17 00:00:00 2001 From: MacRimi <123239993+MacRimi@users.noreply.github.com> Date: Sat, 18 Apr 2026 00:36:30 +0200 Subject: [PATCH] Add syntax check for installed launcher script Added defensive checks to ensure the installed launcher script passes syntax validation before proceeding with installation. --- install_proxmenux.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/install_proxmenux.sh b/install_proxmenux.sh index 1f34cc10..de98e245 100755 --- a/install_proxmenux.sh +++ b/install_proxmenux.sh @@ -821,6 +821,13 @@ install_normal_version() { cp "./version.txt" "$LOCAL_VERSION_FILE" cp "./install_proxmenux.sh" "$BASE_DIR/install_proxmenux.sh" + # Defensive: strip CRLF and reject a broken launcher before we declare success. + sed -i 's/\r$//' "$INSTALL_DIR/$MENU_SCRIPT" "$UTILS_FILE" 2>/dev/null || true + if ! bash -n "$INSTALL_DIR/$MENU_SCRIPT" 2>/dev/null; then + msg_error "Installed launcher failed syntax check. Installation aborted." + exit 1 + fi + # Wipe the scripts tree before copying so any file removed upstream # (renamed, consolidated, deprecated) disappears from the user install. # Only $BASE_DIR/scripts/ is cleared; config.json, cache.json, @@ -963,13 +970,19 @@ install_translation_version() { cp "./menu" "$INSTALL_DIR/$MENU_SCRIPT" cp "./version.txt" "$LOCAL_VERSION_FILE" cp "./install_proxmenux.sh" "$BASE_DIR/install_proxmenux.sh" - + + sed -i 's/\r$//' "$INSTALL_DIR/$MENU_SCRIPT" "$UTILS_FILE" 2>/dev/null || true + if ! bash -n "$INSTALL_DIR/$MENU_SCRIPT" 2>/dev/null; then + msg_error "Installed launcher failed syntax check. Installation aborted." + exit 1 + fi + mkdir -p "$BASE_DIR/scripts" cp -r "./scripts/"* "$BASE_DIR/scripts/" chmod -R +x "$BASE_DIR/scripts/" chmod +x "$BASE_DIR/install_proxmenux.sh" msg_ok "Necessary files created." - + chmod +x "$INSTALL_DIR/$MENU_SCRIPT" ((current_step++))