From 7ca8f2eb0d10c55f842a3c906888736090ded3eb Mon Sep 17 00:00:00 2001 From: Cam Date: Fri, 1 Aug 2025 21:38:37 -0600 Subject: [PATCH 1/3] autonomous files --- scripts/commands/extensions/install.sh | 36 ++++++++++++++++++++++++-- scripts/commands/extensions/remove.sh | 26 +++++++++++++++++-- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/scripts/commands/extensions/install.sh b/scripts/commands/extensions/install.sh index e7c8fec1..71139fbc 100644 --- a/scripts/commands/extensions/install.sh +++ b/scripts/commands/extensions/install.sh @@ -1294,8 +1294,40 @@ InstallExtension() { ((PROGRESS_NOW++)) if [[ ( $F_developerIgnoreInstallScript == false ) || ( $dev != true ) ]]; then - if [[ -f ".blueprint/extensions/$identifier/private/install.sh" ]]; then - PRINT WARNING "Extension uses a custom installation script, proceed with caution." + if [[ $2 == "-script" && -f ".blueprint/extensions/$identifier/private/autonomous_install.sh" ]]; then + PRINT WARNING "Extension has a autonomous installation script, proceed with caution." + hide_progress + chmod --silent +x ".blueprint/extensions/$identifier/private/autonomous_install.sh" 2>> "$BLUEPRINT__DEBUG" + + # Run script while also parsing some useful variables for the install script to use. + if $F_developerEscalateInstallScript; then + ENGINE="$BLUEPRINT_ENGINE" \ + EXTENSION_IDENTIFIER="$identifier" \ + EXTENSION_TARGET="$target" \ + EXTENSION_VERSION="$version" \ + PTERODACTYL_DIRECTORY="$FOLDER" \ + BLUEPRINT_VERSION="$VERSION" \ + BLUEPRINT_DEVELOPER="$dev" \ + bash .blueprint/extensions/"$identifier"/private/autonomous_install.sh + else + su "$WEBUSER" -s "$USERSHELL" -c " + cd \"$FOLDER\"; + ENGINE=\"$BLUEPRINT_ENGINE\" \ + EXTENSION_IDENTIFIER=\"$identifier\" \ + EXTENSION_TARGET=\"$target\" \ + EXTENSION_VERSION=\"$version\" \ + PTERODACTYL_DIRECTORY=\"$FOLDER\" \ + BLUEPRINT_VERSION=\"$VERSION\" \ + BLUEPRINT_DEVELOPER=\"$dev\" \ + bash .blueprint/extensions/$identifier/private/autonomous_install.sh + " + fi + elif [[ -f ".blueprint/extensions/$identifier/private/install.sh" ]]; then + if [[ $2 == "-script" ]]; then + PRINT WARNING "No autonomous installation script found, but extension has a custom installation script. Falling back to basic install." + else + PRINT INFO "Extension has a custom installation script, proceed with caution." + fi hide_progress chmod --silent +x ".blueprint/extensions/$identifier/private/install.sh" 2>> "$BLUEPRINT__DEBUG" diff --git a/scripts/commands/extensions/remove.sh b/scripts/commands/extensions/remove.sh index 149bfeb7..b9c8087c 100644 --- a/scripts/commands/extensions/remove.sh +++ b/scripts/commands/extensions/remove.sh @@ -89,8 +89,30 @@ RemoveExtension() { ((PROGRESS_NOW++)) - if [[ -f ".blueprint/extensions/$identifier/private/remove.sh" ]]; then - PRINT WARNING "Extension uses a custom removal script, proceed with caution." + if [[ $2 == "-script" && -f ".blueprint/extensions/$identifier/private/autonomous_remove.sh" ]]; then + PRINT WARNING "Extension has a custom removal script, proceed with caution." + hide_progress + chmod +x ".blueprint/extensions/$identifier/private/autonomous_remove.sh" + + # Run script while also parsing some useful variables for the uninstall script to use. + su "$WEBUSER" -s "$USERSHELL" -c " + cd \"$FOLDER\"; + ENGINE=\"$BLUEPRINT_ENGINE\" \ + EXTENSION_IDENTIFIER=\"$identifier\" \ + EXTENSION_TARGET=\"$target\" \ + EXTENSION_VERSION=\"$version\" \ + PTERODACTYL_DIRECTORY=\"$FOLDER\" \ + BLUEPRINT_VERSION=\"$VERSION\" \ + bash .blueprint/extensions/$identifier/private/autonomous_remove.sh + " + + echo -e "\e[0m\x1b[0m\033[0m" + elif [[ -f ".blueprint/extensions/$identifier/private/remove.sh" ]]; then + if [[ $2 == "-script" ]]; then + PRINT WARNING "No autonomous removal script found, but extension has a custom removal script. Falling back to basic uninstall." + else + PRINT WARNING "Extension has a custom removal script, proceed with caution." + fi hide_progress chmod +x ".blueprint/extensions/$identifier/private/remove.sh" From d08a9ced6dcfd6093f35217880163afa5a23d738 Mon Sep 17 00:00:00 2001 From: Cam Date: Fri, 1 Aug 2025 22:03:57 -0600 Subject: [PATCH 2/3] possible fix --- scripts/commands/extensions/install.sh | 14 +++++++++++--- scripts/commands/extensions/remove.sh | 11 +++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/scripts/commands/extensions/install.sh b/scripts/commands/extensions/install.sh index 71139fbc..9e7c3462 100644 --- a/scripts/commands/extensions/install.sh +++ b/scripts/commands/extensions/install.sh @@ -1294,7 +1294,7 @@ InstallExtension() { ((PROGRESS_NOW++)) if [[ ( $F_developerIgnoreInstallScript == false ) || ( $dev != true ) ]]; then - if [[ $2 == "-script" && -f ".blueprint/extensions/$identifier/private/autonomous_install.sh" ]]; then + if [[ $script == true && -f ".blueprint/extensions/$identifier/private/autonomous_install.sh" ]]; then PRINT WARNING "Extension has a autonomous installation script, proceed with caution." hide_progress chmod --silent +x ".blueprint/extensions/$identifier/private/autonomous_install.sh" 2>> "$BLUEPRINT__DEBUG" @@ -1323,7 +1323,7 @@ InstallExtension() { " fi elif [[ -f ".blueprint/extensions/$identifier/private/install.sh" ]]; then - if [[ $2 == "-script" ]]; then + if [[ $script == true ]]; then PRINT WARNING "No autonomous installation script found, but extension has a custom installation script. Falling back to basic install." else PRINT INFO "Extension has a custom installation script, proceed with caution." @@ -1382,6 +1382,7 @@ Command() { if [[ $1 == "" ]]; then PRINT FATAL "Expected at least 1 argument but got 0.";exit 2;fi if [[ ( $1 == "./"* ) || ( $1 == "../"* ) || ( $1 == "/"* ) ]]; then PRINT FATAL "Cannot import extensions from external paths.";exit 2;fi + if [[ $DeveloperWatch == "" ]]; then export DeveloperWatch=false @@ -1403,6 +1404,13 @@ Command() { extensions="$*" total=$(echo "$extensions" | wc -w) + script=false + last_arg="${!#}" + if [[ "$last_arg" == "-script" ]]; then + script=true + extensions="${extensions%" $last_arg"}" + fi + local EXTENSIONS_STEPS=34 #Total amount of steps per extension local FINISH_STEPS=6 #Total amount of finalization steps @@ -1415,7 +1423,7 @@ Command() { for extension in $extensions; do (( current++ )) - InstallExtension "$extension" "$current" "$total" + InstallExtension "$extension" "$current" "$total" "$script" export PROGRESS_NOW="$(("$EXTENSIONS_STEPS" * "$current"))" done diff --git a/scripts/commands/extensions/remove.sh b/scripts/commands/extensions/remove.sh index b9c8087c..d9816bf5 100644 --- a/scripts/commands/extensions/remove.sh +++ b/scripts/commands/extensions/remove.sh @@ -89,7 +89,7 @@ RemoveExtension() { ((PROGRESS_NOW++)) - if [[ $2 == "-script" && -f ".blueprint/extensions/$identifier/private/autonomous_remove.sh" ]]; then + if [[ $script == true && -f ".blueprint/extensions/$identifier/private/autonomous_remove.sh" ]]; then PRINT WARNING "Extension has a custom removal script, proceed with caution." hide_progress chmod +x ".blueprint/extensions/$identifier/private/autonomous_remove.sh" @@ -108,7 +108,7 @@ RemoveExtension() { echo -e "\e[0m\x1b[0m\033[0m" elif [[ -f ".blueprint/extensions/$identifier/private/remove.sh" ]]; then - if [[ $2 == "-script" ]]; then + if [[ $script == true ]]; then PRINT WARNING "No autonomous removal script found, but extension has a custom removal script. Falling back to basic uninstall." else PRINT WARNING "Extension has a custom removal script, proceed with caution." @@ -425,6 +425,13 @@ Command() { extensions="$*" total=$(echo "$extensions" | wc -w) + script=false + last_arg="${!#}" + if [[ "$last_arg" == "-script" ]]; then + script=true + extensions="${extensions%" $last_arg"}" + fi + local EXTENSIONS_STEPS=22 #Total amount of steps per extension local FINISH_STEPS=5 #Total amount of finalization From 9fbda8cbcd8ddc35b0504370d06057d455d5235c Mon Sep 17 00:00:00 2001 From: Cam Date: Fri, 1 Aug 2025 22:13:40 -0600 Subject: [PATCH 3/3] add blocking ability --- scripts/commands/extensions/install.sh | 9 +++++++++ scripts/commands/extensions/remove.sh | 10 +++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/commands/extensions/install.sh b/scripts/commands/extensions/install.sh index 9e7c3462..2e7ad1d0 100644 --- a/scripts/commands/extensions/install.sh +++ b/scripts/commands/extensions/install.sh @@ -73,6 +73,15 @@ InstallExtension() { local author="${conf_info_author//&/\\&}" #(optional) local icon="${conf_info_icon//&/\\&}" #(optional) local website="${conf_info_website//&/\\&}"; #(optional) + local canRunAutonomous="${conf_info_canRunAutonomous//&/\\&}" #(optional, default: true) + if [[ -z "$canRunAutonomous" ]]; then canRunAutonomous="true"; fi + + if [[ $script == true && $canRunAutonomous == false ]]; then + # just in case the dev has a script that REQUIRES human input. + PRINT WARNING "Extension has a custom install script, but autonomous installation is disabled. Cannot continue with installation. Please install via CLI." + hide_progress + return 1 + fi local admin_view="$conf_admin_view" local admin_controller="$conf_admin_controller"; #(optional) diff --git a/scripts/commands/extensions/remove.sh b/scripts/commands/extensions/remove.sh index d9816bf5..ad2333d9 100644 --- a/scripts/commands/extensions/remove.sh +++ b/scripts/commands/extensions/remove.sh @@ -39,6 +39,15 @@ RemoveExtension() { local author="${conf_info_author//&/\\&}" #(optional) local icon="${conf_info_icon//&/\\&}" #(optional) local website="${conf_info_website//&/\\&}"; #(optional) + local canRunAutonomous="${conf_info_canRunAutonomous//&/\\&}" #(optional, default: true) + if [[ -z "$canRunAutonomous" ]]; then canRunAutonomous="true"; fi + + if [[ $script == true && $canRunAutonomous == false ]]; then + # just in case the dev has a script that REQUIRES human input. + PRINT WARNING "Extension has a custom removal script, but autonomous removal is disabled. Cannot continue with removal. Please remove via CLI." + hide_progress + return 1 + fi local admin_view="$conf_admin_view" local admin_controller="$conf_admin_controller"; #(optional) @@ -88,7 +97,6 @@ RemoveExtension() { assignflags ((PROGRESS_NOW++)) - if [[ $script == true && -f ".blueprint/extensions/$identifier/private/autonomous_remove.sh" ]]; then PRINT WARNING "Extension has a custom removal script, proceed with caution." hide_progress