Merge pull request #102 from outis1one/claude/gifted-bohr-dfzdig

Detect pipe execution; show clear upgrade error instead of cryptic pa…
This commit is contained in:
Outis
2026-06-16 12:50:00 -04:00
committed by GitHub
+27 -10
View File
@@ -69,6 +69,16 @@ set -euo pipefail
################################################################################ ################################################################################
SCRIPT_VERSION="1.0.3" SCRIPT_VERSION="1.0.3"
# Resolve the real path to this script file.
# When piped (curl|bash or wget|bash), BASH_SOURCE[0] is a pipe descriptor,
# not a real file. The upgrade function needs to read heredocs from a file,
# so we detect the pipe case here and set SCRIPT_FILE accordingly.
SCRIPT_FILE="$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || true)"
if [[ ! -f "$SCRIPT_FILE" ]]; then
SCRIPT_FILE="" # running from a pipe — upgrade will warn the user
fi
KIOSK_USER="kiosk" KIOSK_USER="kiosk"
BUILD_USER="${SUDO_USER:-$(whoami)}" BUILD_USER="${SUDO_USER:-$(whoami)}"
KIOSK_HOME="/home/${KIOSK_USER}" KIOSK_HOME="/home/${KIOSK_USER}"
@@ -11167,20 +11177,27 @@ upgrade_kiosk() {
echo echo
echo "NO user input is required - upgrade runs automatically." echo "NO user input is required - upgrade runs automatically."
echo echo
read -r -p "Continue with upgrade? (yes/no): " confirm # Upgrade requires the script to be a real file on disk (not a pipe).
[[ "$confirm" != "yes" ]] && return # The extract_file() helper greps the script for heredoc markers.
if [[ -z "$SCRIPT_FILE" ]]; then
# Get the path of this script for extracting heredocs echo
local script_path log_error "Upgrade cannot run when the script was piped (curl|bash / wget|bash)."
script_path="$(readlink -f "${BASH_SOURCE[0]}")" echo
echo " Download the script to a file first, then run it:"
# Verify the script exists and is readable echo
if [[ ! -f "$script_path" ]]; then echo " wget -O kiosk.sh <url-from-github>"
log_error "Cannot find script at: $script_path" echo " sudo bash kiosk.sh"
echo
pause pause
return return
fi fi
read -r -p "Continue with upgrade? (yes/no): " confirm
[[ "$confirm" != "yes" ]] && return
# Use the pre-resolved path (set at startup)
local script_path="$SCRIPT_FILE"
echo echo
echo "[1/6] Stopping kiosk (LightDM)..." echo "[1/6] Stopping kiosk (LightDM)..."
# Kill any running electron process first # Kill any running electron process first