|
@@ -111,15 +111,18 @@ cat > "$HEADER_FILE" << SCRIPT_HEADER
|
|
|
# Version: $VERSION
|
|
# Version: $VERSION
|
|
|
# Generated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
|
# Generated: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
|
|
|
|
|
|
|
-# Handle curl | sh with sudo re-exec: when piped, \$0 isn't a re-readable
|
|
|
|
|
-# file, so capture the remaining script from stdin into a temp file and
|
|
|
|
|
-# re-exec that with sudo; stdin must be reattached to the terminal so
|
|
|
|
|
-# interactive prompts work (the pipe is exhausted after cat)
|
|
|
|
|
-if [[ \$EUID -ne 0 && ! -f "\$0" ]]; then
|
|
|
|
|
|
|
+# Materialise to a temp file when piped (curl | sh), then re-exec WITHOUT
|
|
|
|
|
+# sudo so the guided install flow (banner → summary → confirm → sudo prompt)
|
|
|
|
|
+# runs exactly as if the user had downloaded and run the script directly
|
|
|
|
|
+if [[ ! -f "\$0" ]]; then
|
|
|
|
|
+ echo "Downloading USM installer..."
|
|
|
_usm_tmp=\$(mktemp /tmp/usm-install.XXXXXX.sh)
|
|
_usm_tmp=\$(mktemp /tmp/usm-install.XXXXXX.sh)
|
|
|
- cat > "\$_usm_tmp"
|
|
|
|
|
|
|
+ _usm_bytes=\$(tee "\$_usm_tmp" | wc -c)
|
|
|
|
|
+ _usm_kb=\$((_usm_bytes / 1024))
|
|
|
chmod +x "\$_usm_tmp"
|
|
chmod +x "\$_usm_tmp"
|
|
|
- exec sudo bash "\$_usm_tmp" "\$@" < /dev/tty
|
|
|
|
|
|
|
+ echo " Downloaded \${_usm_kb}KB"
|
|
|
|
|
+ echo ""
|
|
|
|
|
+ exec bash "\$_usm_tmp" "\$@" < /dev/tty
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
set -e
|