|
@@ -111,6 +111,17 @@ 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 (this guard must run before any other code so
|
|
|
|
|
+# the pipe hasn't been fully consumed yet)
|
|
|
|
|
+if [[ \$EUID -ne 0 && ! -f "\$0" ]]; then
|
|
|
|
|
+ _usm_tmp=\$(mktemp /tmp/usm-install.XXXXXX.sh)
|
|
|
|
|
+ cat > "\$_usm_tmp"
|
|
|
|
|
+ chmod +x "\$_usm_tmp"
|
|
|
|
|
+ exec sudo bash "\$_usm_tmp" "\$@"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
set -e
|
|
set -e
|
|
|
|
|
|
|
|
SCRIPT_HEADER
|
|
SCRIPT_HEADER
|