2023-03-03 10:52:29 -05:00
#!/bin/bash
2024-06-03 15:07:00 -04:00
# © 2023-2024 Ivy (prpl.wtf)
2023-03-03 10:52:29 -05:00
2024-06-03 15:07:00 -04:00
# Learn more @ blueprint.zip
# Source code available on github.com/blueprintframework/framework
2023-06-26 08:42:31 -04:00
2023-08-11 18:00:23 -04:00
# This should allow Blueprint to run in Docker. Please note that changing the $FOLDER variable after running
2023-05-06 10:31:31 -04:00
# the Blueprint installation script will not change anything in any files besides blueprint.sh.
2024-06-17 07:51:23 -04:00
FOLDER = $( realpath " $( dirname " $0 " ) " )
2023-05-06 10:21:22 -04:00
2024-02-24 09:11:01 -05:00
# This stores the webserver ownership user which Blueprint uses when applying webserver permissions.
OWNERSHIP = "www-data:www-data" #;
2024-05-15 08:51:42 -04:00
# This stores options for permissions related to running install scripts the webserver user.
2024-05-06 10:43:16 -04:00
WEBUSER = "www-data" #;
2024-05-15 08:51:42 -04:00
USERSHELL = "/bin/bash" #;
2024-02-24 09:11:01 -05:00
2024-05-31 03:56:24 -04:00
# Defines the version Blueprint will display as the active one.
2024-06-22 15:25:29 -04:00
VERSION = "beta-F248-1"
2023-08-27 10:01:36 -04:00
2024-06-08 17:44:55 -04:00
# Default GitHub repository to use when upgrading Blueprint.
REPOSITORY = "BlueprintFramework/framework"
2023-08-27 10:01:36 -04:00
2024-06-23 10:38:57 -04:00
# Check if the script is being sourced - and if so - load bash autocompletion.
if [ [ " ${ BASH_SOURCE [0] } " != " ${ 0 } " ] ] ; then
_blueprint_completions( ) {
local cur cmd opts
COMPREPLY = ( )
cur = " ${ COMP_WORDS [COMP_CWORD] } "
cmd = " ${ COMP_WORDS [1] } "
case " ${ cmd } " in
-install| -add| -i) opts = " $( find " $FOLDER " /*.blueprint | sed -e " s|^ $FOLDER /||g " -e " s|.blueprint $||g " ) " ; ;
-remove| -r) opts = " $( sed "s|,||g" " $FOLDER /.blueprint/extensions/blueprint/private/db/installed_extensions " ) " ; ;
-export) opts = "expose" ; ;
-debug) opts = "100 200" ; ;
-upgrade) opts = "remote" ; ;
*) opts = "-install -add -remove -init -build -export -wipe -version -help -info -debug -upgrade -rerun-install" ; ;
esac
if [ [ ${ cur } = = * ] ] ; then
# shellcheck disable=SC2207
COMPREPLY = ( $( compgen -W " ${ opts } " -- " ${ cur } " ) )
return 0
fi
}
complete -F _blueprint_completions blueprint
return 0
fi
2023-12-15 13:43:57 -05:00
# Check for panels that are using Docker, which should have better support in the future.
2023-11-28 11:40:08 -05:00
if [ [ -f "/.dockerenv" ] ] ; then
2023-08-15 06:23:40 -04:00
DOCKER = "y"
2024-06-17 07:31:31 -04:00
FOLDER = "/app"
2023-07-04 08:28:19 -04:00
else
2023-08-15 06:23:40 -04:00
DOCKER = "n"
fi
2023-05-06 10:21:22 -04:00
2024-06-08 17:41:18 -04:00
# This has caused a bunch of errors but is just here to make sure people actually upload the
# "blueprint" folder onto their panel when installing Blueprint. Pick your poison.
2024-06-17 07:54:15 -04:00
if [ [ -d " $FOLDER /blueprint " ] ] ; then mv " $FOLDER /blueprint " " $FOLDER /.blueprint " ; fi
2023-04-25 13:33:21 -04:00
2023-11-23 10:03:03 -05:00
if [ [ $VERSION != "" ] ] ; then
# This function makes sure some placeholders get replaced with the current Blueprint version.
2023-11-08 10:01:39 -05:00
if [ [ ! -f " $FOLDER /.blueprint/extensions/blueprint/private/db/version " ] ] ; then
2024-06-17 07:54:15 -04:00
sed -E -i " s*::v* $VERSION *g " " $FOLDER /app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php "
sed -E -i " s*::v* $VERSION *g " " $FOLDER /.blueprint/extensions/blueprint/public/index.html "
touch " $FOLDER /.blueprint/extensions/blueprint/private/db/version "
2023-08-15 06:23:40 -04:00
fi
fi
2023-04-24 10:43:31 -04:00
2023-10-31 10:35:14 -04:00
# Write environment variables.
export BLUEPRINT__FOLDER = $FOLDER
export BLUEPRINT__VERSION = $VERSION
2023-12-22 10:06:02 -05:00
export BLUEPRINT__DEBUG = " $FOLDER " /.blueprint/extensions/blueprint/private/debug/logs.txt
2023-11-01 09:51:42 -04:00
export NODE_OPTIONS = --openssl-legacy-provider
2024-02-27 16:09:33 -05:00
# Write internal variables.
__BuildDir = ".blueprint/extensions/blueprint/private/build"
2023-08-15 06:23:40 -04:00
# Automatically navigate to the Pterodactyl directory when running the core.
2024-06-17 07:54:15 -04:00
cd " $FOLDER " || return
2023-05-09 11:59:12 -04:00
2023-06-18 10:37:46 -04:00
# Import libraries.
2024-06-23 10:38:57 -04:00
source scripts/libraries/parse_yaml.sh || missinglibs += "[parse_yaml]"
source scripts/libraries/grabenv.sh || missinglibs += "[grabenv]"
source scripts/libraries/logFormat.sh || missinglibs += "[logFormat]"
source scripts/libraries/misc.sh || missinglibs += "[misc]"
2023-03-03 10:52:29 -05:00
2023-08-06 07:41:56 -04:00
2023-07-16 14:22:59 -04:00
# -config
# usage: "cITEM=VALUE bash blueprint.sh -config"
if [ [ " $1 " = = "-config" ] ] ; then
2023-06-27 15:49:11 -04:00
2023-07-16 14:22:59 -04:00
# cTELEMETRY_ID
# Update the telemetry id.
2023-12-17 06:51:06 -05:00
if [ [ " $cTELEMETRY_ID " != "" ] ] ; then
2023-11-08 10:01:39 -05:00
echo " $cTELEMETRY_ID " > .blueprint/extensions/blueprint/private/db/telemetry_id
2023-08-15 06:23:40 -04:00
fi
2023-06-27 15:49:11 -04:00
2023-08-07 09:50:54 -04:00
# cDEVELOPER
# Enable/Disable developer mode.
2023-12-17 06:51:06 -05:00
if [ [ " $cDEVELOPER " != "" ] ] ; then
2024-06-17 07:31:31 -04:00
if [ [ " $cDEVELOPER " = = "true" ] ] ; then
2023-11-01 09:51:42 -04:00
dbAdd "blueprint.developerEnabled"
2024-06-17 07:31:31 -04:00
else
2023-11-01 09:51:42 -04:00
dbRemove "blueprint.developerEnabled"
fi
2023-08-15 06:23:40 -04:00
fi
2023-08-07 09:50:54 -04:00
2023-08-15 06:23:40 -04:00
echo .
2024-01-15 11:40:12 -05:00
exit 0
2023-08-15 06:23:40 -04:00
fi
2023-04-23 15:23:15 -04:00
2024-01-15 17:59:30 -05:00
cdhalt( ) { PRINT FATAL "Attempted navigation into nonexistent directory, halting process." ; exit 1; }
2023-08-06 07:41:56 -04:00
2023-04-05 15:26:33 -04:00
2023-07-31 05:14:32 -04:00
depend( ) {
2024-06-08 17:41:57 -04:00
# Check for compatible node versions
2023-09-11 10:29:38 -04:00
nodeVer = $( node -v)
2024-01-15 16:09:31 -05:00
if [ [ $nodeVer != "v17." * ] ] \
&& [ [ $nodeVer != "v18." * ] ] \
&& [ [ $nodeVer != "v19." * ] ] \
&& [ [ $nodeVer != "v20." * ] ] \
2024-05-03 05:01:15 -04:00
&& [ [ $nodeVer != "v21." * ] ] \
2024-06-17 07:31:31 -04:00
&& [ [ $nodeVer != "v22." * ] ] ; then
2024-01-15 16:09:31 -05:00
DEPEND_MISSING = true
fi
2023-09-11 10:29:38 -04:00
2023-12-22 08:31:31 -05:00
# Check for required (both internal and external) dependencies.
if \
! [ -x " $( command -v unzip) " ] || # unzip
! [ -x " $( command -v node) " ] || # node
! [ -x " $( command -v yarn) " ] || # yarn
! [ -x " $( command -v zip) " ] || # zip
! [ -x " $( command -v curl) " ] || # curl
! [ -x " $( command -v php) " ] || # php
! [ -x " $( command -v git) " ] || # git
! [ -x " $( command -v grep) " ] || # grep
! [ -x " $( command -v sed) " ] || # sed
! [ -x " $( command -v awk) " ] || # awk
2024-04-18 12:03:38 -04:00
! [ -x " $( command -v tput) " ] || # tput
2023-12-22 08:31:31 -05:00
! [ " $( ls "node_modules/" *"cross-env" * 2> /dev/null) " ] || # cross-env
2024-01-09 05:27:13 -05:00
! [ " $( ls "node_modules/" *"webpack" * 2> /dev/null) " ] || # webpack
2024-01-09 05:29:02 -05:00
! [ " $( ls "node_modules/" *"react" * 2> /dev/null) " ] || # react
2023-12-22 08:31:31 -05:00
[ [ $missinglibs != "" ] ] ; then # internal
DEPEND_MISSING = true
fi
2023-08-18 12:29:01 -04:00
# Exit when missing dependencies.
2024-06-17 07:31:31 -04:00
if [ [ $DEPEND_MISSING = = true ] ] ; then
2024-01-14 18:43:11 -05:00
PRINT FATAL "Some framework dependencies are not installed or detected."
2023-09-11 10:23:49 -04:00
2024-01-15 16:09:31 -05:00
if [ [ $nodeVer != "v18." * ] ] \
&& [ [ $nodeVer != "v19." * ] ] \
&& [ [ $nodeVer != "v20." * ] ] \
2024-05-03 05:30:44 -04:00
&& [ [ $nodeVer != "v21." * ] ] \
2024-06-17 07:31:31 -04:00
&& [ [ $nodeVer != "v22." * ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Required dependency \"node\" is using an unsupported version."
fi
2023-12-22 08:31:31 -05:00
2024-01-14 18:43:11 -05:00
if ! [ -x " $( command -v unzip) " ] ; then PRINT FATAL "Required dependency \"unzip\" is not installed or detected." ; fi
if ! [ -x " $( command -v node) " ] ; then PRINT FATAL "Required dependency \"node\" is not installed or detected." ; fi
if ! [ -x " $( command -v yarn) " ] ; then PRINT FATAL "Required dependency \"yarn\" is not installed or detected." ; fi
if ! [ -x " $( command -v zip) " ] ; then PRINT FATAL "Required dependency \"zip\" is not installed or detected." ; fi
if ! [ -x " $( command -v curl) " ] ; then PRINT FATAL "Required dependency \"curl\" is not installed or detected." ; fi
if ! [ -x " $( command -v php) " ] ; then PRINT FATAL "Required dependency \"php\" is not installed or detected." ; fi
if ! [ -x " $( command -v git) " ] ; then PRINT FATAL "Required dependency \"git\" is not installed or detected." ; fi
if ! [ -x " $( command -v grep) " ] ; then PRINT FATAL "Required dependency \"grep\" is not installed or detected." ; fi
if ! [ -x " $( command -v sed) " ] ; then PRINT FATAL "Required dependency \"sed\" is not installed or detected." ; fi
if ! [ -x " $( command -v awk) " ] ; then PRINT FATAL "Required dependency \"awk\" is not installed or detected." ; fi
2024-04-18 12:02:16 -04:00
if ! [ -x " $( command -v tput) " ] ; then PRINT FATAL "Required dependency \"tput\" is not installed or detected." ; fi
2024-01-14 18:43:11 -05:00
if ! [ " $( ls "node_modules/" *"cross-env" * 2> /dev/null) " ] ; then PRINT FATAL "Required dependency \"cross-env\" is not installed or detected." ; fi
if ! [ " $( ls "node_modules/" *"webpack" * 2> /dev/null) " ] ; then PRINT FATAL "Required dependency \"webpack\" is not installed or detected." ; fi
if ! [ " $( ls "node_modules/" *"react" * 2> /dev/null) " ] ; then PRINT FATAL "Required dependency \"react\" is not installed or detected." ; fi
2024-06-23 10:38:57 -04:00
if [ [ $missinglibs = = *"[parse_yaml]" * ] ] ; then PRINT FATAL "Required internal dependency \"internal:parse_yaml\" is not installed or detected." ; fi
if [ [ $missinglibs = = *"[grabEnv]" * ] ] ; then PRINT FATAL "Required internal dependency \"internal:grabEnv\" is not installed or detected." ; fi
if [ [ $missinglibs = = *"[logFormat]" * ] ] ; then PRINT FATAL "Required internal dependency \"internal:logFormat\" is not installed or detected." ; fi
if [ [ $missinglibs = = *"[misc]" * ] ] ; then PRINT FATAL "Required internal dependency \"internal:misc\" is not installed or detected." ; fi
2023-09-11 10:29:38 -04:00
exit 1
2023-09-11 10:23:49 -04:00
fi
2023-07-31 05:14:32 -04:00
}
2023-12-11 09:33:33 -05:00
# Assign variables for extension flags.
assignflags( ) {
F_ignorePlaceholders = false
2024-04-09 15:59:43 -04:00
F_forceLegacyPlaceholders = false
2023-12-11 09:33:33 -05:00
F_hasInstallScript = false
F_hasRemovalScript = false
F_hasExportScript = false
F_developerIgnoreInstallScript = false
2023-12-11 09:56:05 -05:00
F_developerIgnoreRebuild = false
2024-03-02 16:14:05 -05:00
F_developerForceMigrate = false
2024-04-20 09:50:43 -04:00
F_developerKeepApplicationCache = false
2024-05-15 14:07:18 -04:00
F_developerEscalateExportScript = false
2024-04-20 09:50:43 -04:00
if [ [ ( $flags = = *"ignorePlaceholders," * ) || ( $flags = = *"ignorePlaceholders" ) ] ] ; then F_ignorePlaceholders = true ; fi
if [ [ ( $flags = = *"forceLegacyPlaceholders," * ) || ( $flags = = *"forceLegacyPlaceholders" ) ] ] ; then F_forceLegacyPlaceholders = true ; fi
if [ [ ( $flags = = *"hasInstallScript," * ) || ( $flags = = *"hasInstallScript" ) ] ] ; then F_hasInstallScript = true ; fi
if [ [ ( $flags = = *"hasRemovalScript," * ) || ( $flags = = *"hasRemovalScript" ) ] ] ; then F_hasRemovalScript = true ; fi
if [ [ ( $flags = = *"hasExportScript," * ) || ( $flags = = *"hasExportScript" ) ] ] ; then F_hasExportScript = true ; fi
if [ [ ( $flags = = *"developerIgnoreInstallScript," * ) || ( $flags = = *"developerIgnoreInstallScript" ) ] ] ; then F_developerIgnoreInstallScript = true ; fi
if [ [ ( $flags = = *"developerIgnoreRebuild," * ) || ( $flags = = *"developerIgnoreRebuild" ) ] ] ; then F_developerIgnoreRebuild = true ; fi
if [ [ ( $flags = = *"developerForceMigrate," * ) || ( $flags = = *"developerForceMigrate" ) ] ] ; then F_developerForceMigrate = true ; fi
if [ [ ( $flags = = *"developerKeepApplicationCache," * ) || ( $flags = = *"developerKeepApplicationCache" ) ] ] ; then F_developerKeepApplicationCache = true ; fi
2024-05-15 14:07:18 -04:00
if [ [ ( $flags = = *"developerEscalateExportScript," * ) || ( $flags = = *"developerEscalateExportScript" ) ] ] ; then F_developerEscalateExportScript = true ; fi
2023-12-11 09:33:33 -05:00
}
2023-08-06 07:41:56 -04:00
2023-06-18 10:37:46 -04:00
# Adds the "blueprint" command to the /usr/local/bin directory and configures the correct permissions for it.
2024-06-23 10:38:57 -04:00
placeshortcut( ) {
2024-03-29 08:53:39 -04:00
PRINT INFO "Placing Blueprint command shortcut.."
{
touch /usr/local/bin/blueprint
chmod u+x \
2024-06-17 07:54:15 -04:00
" $FOLDER /blueprint.sh " \
2024-03-29 08:53:39 -04:00
/usr/local/bin/blueprint
2024-06-17 07:54:15 -04:00
} >> " $BLUEPRINT__DEBUG "
2024-06-23 10:38:57 -04:00
echo -e \
"#!/bin/bash \n" \
" if [[ \"\${BASH_SOURCE[0]}\" != \"\${0}\" ]]; then source \" $FOLDER /blueprint.sh\"; return 0; fi; " \
" bash $FOLDER /blueprint.sh -bash \$@; " \
> /usr/local/bin/blueprint
}
if ! [ -x " $( command -v blueprint) " ] ; then placeshortcut; fi
2023-04-02 14:47:24 -04:00
2023-08-06 07:41:56 -04:00
2023-03-23 06:54:40 -04:00
if [ [ $1 != "-bash" ] ] ; then
2023-06-02 10:37:38 -04:00
if dbValidate "blueprint.setupFinished" ; then
2024-01-14 18:43:11 -05:00
PRINT FATAL "Installation process has already been finished before, consider using the 'blueprint' command."
2024-01-15 11:40:12 -05:00
exit 2
2023-06-02 10:37:38 -04:00
else
2023-06-26 06:40:33 -04:00
# Only run if Blueprint is not in the process of upgrading.
2023-06-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
2024-06-08 17:46:22 -04:00
# Print Blueprint icon with ascii characters.
echo -e " ██\n██ ██\n ████\n" ;
2023-08-15 06:23:40 -04:00
fi
2023-05-06 10:21:22 -04:00
2024-01-14 18:43:11 -05:00
PRINT INFO "Searching and validating framework dependencies.."
2024-04-18 12:04:15 -04:00
# Check if required dependencies are installed
2023-08-15 06:23:40 -04:00
depend
2023-07-30 06:13:53 -04:00
2024-06-23 10:38:57 -04:00
# Place Blueprint shortcut
placeshortcut
2023-11-08 05:35:18 -05:00
# Link directories.
2024-01-14 18:43:11 -05:00
PRINT INFO "Linking directories and filesystems.."
2024-03-02 15:17:47 -05:00
{
2024-06-17 07:54:15 -04:00
ln -s -r -T " $FOLDER /.blueprint/extensions/blueprint/public " " $FOLDER /public/extensions/blueprint "
ln -s -r -T " $FOLDER /.blueprint/extensions/blueprint/assets " " $FOLDER /public/assets/extensions/blueprint "
2024-06-23 10:38:57 -04:00
ln -s -r -T " $FOLDER /scripts/libraries " " $FOLDER /.blueprint/lib "
2024-06-17 07:54:15 -04:00
} 2>> " $BLUEPRINT__DEBUG "
php artisan storage:link & >> " $BLUEPRINT__DEBUG "
2023-11-08 05:35:18 -05:00
2024-01-14 18:43:11 -05:00
PRINT INFO "Replacing internal placeholders.."
2023-07-04 04:37:31 -04:00
# Copy "Blueprint" extension page logo from assets.
2024-06-17 07:54:15 -04:00
cp " $FOLDER /.blueprint/assets/logo.jpg " " $FOLDER /.blueprint/extensions/blueprint/assets/logo.jpg "
2023-07-04 04:37:31 -04:00
2023-06-17 07:28:26 -04:00
# Put application into maintenance.
2024-06-04 09:22:18 -04:00
PRINT INPUT "Would you like to put your application into maintenance while Blueprint is installing? (Y/n)"
2024-05-24 05:54:03 -04:00
read -r YN
2024-06-04 09:22:18 -04:00
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] ; then
2024-06-22 15:25:29 -04:00
MAINTENANCE = "true"
2024-05-24 05:54:03 -04:00
PRINT INFO "Put application into maintenance mode."
2024-06-17 07:54:15 -04:00
php artisan down & >> " $BLUEPRINT__DEBUG "
2024-05-24 05:54:03 -04:00
else
2024-06-22 15:25:29 -04:00
MAINTENANCE = "false"
2024-05-24 05:54:03 -04:00
PRINT INFO "Putting application into maintenance has been skipped."
fi
2023-04-10 10:50:23 -04:00
2024-01-15 12:34:11 -05:00
# Flush cache.
PRINT INFO "Flushing view, config and route cache.."
2024-01-14 18:43:11 -05:00
{
2024-02-27 16:09:33 -05:00
php artisan view:cache
php artisan config:cache
2024-04-10 07:27:07 -04:00
php artisan route:clear
2024-02-13 09:06:17 -05:00
php artisan cache:clear
2024-06-17 07:54:15 -04:00
} & >> " $BLUEPRINT__DEBUG "
2023-08-15 06:23:40 -04:00
updateCacheReminder
2023-08-11 15:50:34 -04:00
2023-06-17 07:28:26 -04:00
# Run migrations if Blueprint is not upgrading.
2024-03-29 08:53:39 -04:00
if [ [ ( $1 != "--post-upgrade" ) && ( $DOCKER != "y" ) ] ] ; then
2024-01-14 18:43:11 -05:00
PRINT INPUT "Would you like to migrate your database? (Y/n)"
2023-10-10 15:28:42 -04:00
read -r YN
2024-06-17 07:31:31 -04:00
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] ; then
2024-01-14 18:43:11 -05:00
PRINT INFO "Running database migrations.."
2023-08-17 05:44:09 -04:00
php artisan migrate --force
else
2024-01-14 18:43:11 -05:00
PRINT INFO "Database migrations have been skipped."
2023-08-17 05:44:09 -04:00
fi
2023-08-15 06:23:40 -04:00
fi
2023-04-08 10:14:36 -04:00
2023-06-26 06:40:33 -04:00
# Make sure all files have correct permissions.
2024-02-24 15:52:53 -05:00
PRINT INFO " Changing Pterodactyl file ownership to ' $OWNERSHIP '.. "
2024-03-04 15:23:07 -05:00
find " $FOLDER / " \
-path " $FOLDER /node_modules " -prune \
2024-06-17 07:56:51 -04:00
-o -exec chown " $OWNERSHIP " { } + & >> " $BLUEPRINT__DEBUG "
2023-03-06 13:11:53 -05:00
2023-07-29 06:29:18 -04:00
# Rebuild panel assets.
2024-01-14 18:43:11 -05:00
PRINT INFO "Rebuilding panel assets.."
2024-02-18 11:17:01 -05:00
yarn run build:production --progress
2023-07-29 06:29:18 -04:00
2024-06-04 09:22:18 -04:00
if [ [ $DOCKER != "y" ] ] ; then
2024-03-29 08:53:39 -04:00
# Sync some database values.
PRINT INFO "Syncing Blueprint-related database values.."
php artisan bp:sync
fi
2023-11-14 09:20:54 -05:00
2024-06-22 15:25:29 -04:00
if [ [ $DOCKER != "y" ] ] && [ [ $MAINTENANCE = = "true" ] ] ; then
# Put application into production.
PRINT INFO "Put application into production."
php artisan up & >> " $BLUEPRINT__DEBUG "
fi
2024-01-14 18:43:11 -05:00
# Finish installation
2023-06-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
2024-05-30 05:01:56 -04:00
PRINT SUCCESS "Blueprint has completed its installation process."
2023-08-15 06:23:40 -04:00
fi
2023-04-10 11:13:28 -04:00
2023-08-15 06:23:40 -04:00
dbAdd "blueprint.setupFinished"
2023-07-09 01:47:40 -04:00
# Let the panel know the user has finished installation.
2024-06-17 07:56:51 -04:00
sed -i "s/NOTINSTALLED/INSTALLED/g" " $FOLDER /app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php "
2024-04-20 13:55:33 -04:00
exit 0
2023-08-15 06:23:40 -04:00
fi
fi
2023-03-19 15:20:01 -04:00
2023-08-06 07:41:56 -04:00
2024-01-31 13:36:44 -05:00
# help, -help, --help,
# h, -h, --h
2024-06-17 07:31:31 -04:00
if [ [ ( $2 = = "help" ) || ( $2 = = "-help" ) || ( $2 = = "--help" ) ||
2024-01-31 13:36:44 -05:00
( $2 = = "h" ) || ( $2 = = "-h" ) || ( $2 = = "--h" ) || ( $2 = = "" ) ] ] ; then VCMD = "y"
2024-06-23 10:38:57 -04:00
source ./scripts/commands/misc/help.sh
2024-01-31 13:36:44 -05:00
2024-06-23 10:38:57 -04:00
HelpCommand
2024-01-31 13:36:44 -05:00
fi
2024-02-14 02:21:09 -05:00
# -i, -install, -add
if [ [ ( $2 = = "-i" ) || ( $2 = = "-install" ) || ( $2 = = "-add" ) ] ] ; then VCMD = "y"
2024-06-23 10:38:57 -04:00
if [ [ $3 = = "" ] ] ; then PRINT FATAL "Expected at least 1 argument but got 0." ; exit 2; fi
2024-01-15 11:40:12 -05:00
if [ [ ( $3 = = "./" * ) || ( $3 = = "../" * ) || ( $3 = = "/" * ) ] ] ; then PRINT FATAL "Cannot import extensions from external paths." ; exit 2; fi
2023-08-10 05:40:26 -04:00
2024-01-14 18:43:11 -05:00
PRINT INFO "Searching and validating framework dependencies.."
2024-02-27 07:03:04 -05:00
# Check if required programs and libraries are installed.
2023-08-15 06:23:40 -04:00
depend
2023-07-30 06:13:53 -04:00
2024-06-23 10:38:57 -04:00
source ./scripts/commands/extensions/install.sh
2024-01-30 14:42:05 -05:00
2024-06-23 10:38:57 -04:00
# Install selected extensions
current = 0
extensions = $( shiftArgs " $@ " )
total = $( echo " $extensions " | wc -w)
for extension in $extensions ; do
( ( current++ ) )
InstallCommand " $extension " " $current " " $total "
done
2024-01-15 15:39:39 -05:00
2024-06-23 11:53:05 -04:00
if [ [ $InstalledExtensions != "" ] ] ; then
# Finalize transaction
PRINT INFO "Finalizing transaction.."
if [ [ ( $YARN = = "y" ) && ( $IgnoreRebuild != "true" ) ] ] ; then
PRINT INFO "Rebuilding panel assets.."
yarn run build:production --progress
fi
2024-06-23 10:54:36 -04:00
2024-06-23 11:53:05 -04:00
# Link filesystems
PRINT INFO "Linking filesystems.."
php artisan storage:link & >> " $BLUEPRINT__DEBUG "
# Flush cache.
PRINT INFO "Flushing view, config and route cache.."
{
php artisan view:cache
php artisan config:cache
php artisan route:clear
if [ [ $KeepApplicationCache != "true" ] ] ; then php artisan cache:clear; fi
} & >> " $BLUEPRINT__DEBUG "
# Make sure all files have correct permissions.
PRINT INFO " Changing Pterodactyl file ownership to ' $OWNERSHIP '.. "
find " $FOLDER / " \
-path " $FOLDER /node_modules " -prune \
-o -exec chown " $OWNERSHIP " { } + & >> " $BLUEPRINT__DEBUG "
# Database migrations
if [ [ ( $database_migrations != "" ) && ( $DOCKER != "y" ) ] ] || [ [ $DeveloperForcedMigrate = = "true" ] ] ; then
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] || [ [ $DeveloperForcedMigrate = = "true" ] ] ; then
PRINT INFO "Running database migrations.."
php artisan migrate --force
else
PRINT INFO "Database migrations have been skipped."
fi
fi
2024-06-26 13:11:15 -04:00
if [ [ $BuiltExtensions = = "" ] ] ; then
sendTelemetry "FINISH_EXTENSION_INSTALLATION" >> " $BLUEPRINT__DEBUG "
CorrectPhrasing = "have"
if [ [ $total = 1 ] ] ; then CorrectPhrasing = "has" ; fi
PRINT SUCCESS " $InstalledExtensions $CorrectPhrasing been installed. "
else
sendTelemetry "BUILD_DEVELOPMENT_EXTENSION" >> " $BLUEPRINT__DEBUG "
PRINT SUCCESS " $BuiltExtensionbs has been built. "
fi
2024-06-23 11:53:05 -04:00
exit 0
else
exit 1
fi
2023-08-15 06:23:40 -04:00
fi
2023-03-22 05:20:59 -04:00
2024-06-23 11:53:05 -04:00
2023-07-30 07:28:03 -04:00
# -r, -remove
2023-08-15 06:23:40 -04:00
if [ [ ( $2 = = "-r" ) || ( $2 = = "-remove" ) ] ] ; then VCMD = "y"
2024-06-23 10:38:57 -04:00
if [ [ $3 = = "" ] ] ; then PRINT FATAL "Expected at least 1 argument but got 0." ; exit 2; fi
2023-07-30 07:28:03 -04:00
2024-06-23 10:38:57 -04:00
source ./scripts/commands/extensions/remove.sh
2023-07-30 07:28:03 -04:00
2024-06-23 10:38:57 -04:00
# Remove selected extensions
current = 0
extensions = $( shiftArgs " $@ " )
total = $( echo " $extensions " | wc -w)
for extension in $extensions ; do
( ( current++ ) )
RemoveCommand " $extension " " $current " " $total "
done
2024-01-15 15:39:39 -05:00
2024-06-26 13:11:15 -04:00
if [ [ $RemovedExtensions != "" ] ] ; then
# Finalize transaction
PRINT INFO "Finalizing transaction.."
# Rebuild panel
if [ [ $YARN = = "y" ] ] ; then
PRINT INFO "Rebuilding panel assets.."
yarn run build:production --progress
fi
# Link filesystems
PRINT INFO "Linking filesystems.."
php artisan storage:link & >> " $BLUEPRINT__DEBUG "
# Flush cache.
PRINT INFO "Flushing view, config and route cache.."
{
php artisan view:cache
php artisan config:cache
php artisan route:clear
php artisan cache:clear
} & >> " $BLUEPRINT__DEBUG "
# Make sure all files have correct permissions.
PRINT INFO " Changing Pterodactyl file ownership to ' $OWNERSHIP '.. "
find " $FOLDER / " \
-path " $FOLDER /node_modules " -prune \
-o -exec chown " $OWNERSHIP " { } + & >> " $BLUEPRINT__DEBUG "
sendTelemetry "FINISH_EXTENSION_REMOVAL" >> " $BLUEPRINT__DEBUG "
CorrectPhrasing = "have"
if [ [ $total = 1 ] ] ; then CorrectPhrasing = "has" ; fi
PRINT SUCCESS " $RemovedExtensions $CorrectPhrasing been removed. "
exit 0
else
exit 1
fi
2023-08-15 06:23:40 -04:00
fi
2023-07-30 07:28:03 -04:00
2023-08-06 07:41:56 -04:00
2023-06-18 10:37:46 -04:00
# -v, -version
2023-08-15 06:23:40 -04:00
if [ [ ( $2 = = "-v" ) || ( $2 = = "-version" ) ] ] ; then VCMD = "y"
2023-10-24 08:53:17 -04:00
echo -e ${ VERSION }
2023-08-15 06:23:40 -04:00
fi
2023-04-10 10:50:23 -04:00
2024-01-31 13:36:44 -05:00
2023-12-22 10:06:02 -05:00
# -debug
if [ [ $2 = = "-debug" ] ] ; then VCMD = "y"
2024-02-27 16:46:54 -05:00
if ! [ [ $3 = ~ [ 0-9] ] ] && [ [ $3 != "" ] ] ; then PRINT FATAL "Amount of debug lines must be a number." ; exit 2; fi
2024-01-15 15:39:39 -05:00
if [ [ $3 -lt 1 ] ] ; then PRINT FATAL "Provide the amount of debug lines to print as an argument, which must be greater than one (1)." ; exit 2; fi
2023-12-22 10:06:02 -05:00
echo -e "\x1b[30;47;1m --- DEBUG START --- \x1b[0m"
2023-12-22 11:51:20 -05:00
echo -e " $( v = " $( <.blueprint/extensions/blueprint/private/debug/logs.txt) " ; printf -- "%s" " $v " | tail -" $3 " ) "
2023-12-22 10:06:02 -05:00
echo -e "\x1b[30;47;1m --- DEBUG END --- \x1b[0m"
fi
2023-08-06 07:41:56 -04:00
2023-06-18 10:37:46 -04:00
# -init
2023-09-23 11:14:04 -04:00
if [ [ ( $2 = = "-init" || $2 = = "-I" ) ] ] ; then VCMD = "y"
2023-12-30 18:16:40 -05:00
# Check for developer mode through the database library.
2024-01-15 11:40:12 -05:00
if ! dbValidate "blueprint.developerEnabled" ; then PRINT FATAL "Developer mode is not enabled." ; exit 2; fi
2023-07-03 08:42:01 -04:00
2023-08-31 04:51:44 -04:00
# To prevent accidental wiping of your dev directory, you are unable to initialize another extension
# until you wipe the contents of the .blueprint/dev directory.
2023-10-13 13:43:33 -04:00
if [ [ -n $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory contains files. To protect you against accidental data loss, you are unable to initialize another extension unless you clear the '.blueprint/dev' folder."
exit 2
2023-08-15 06:23:40 -04:00
fi
2023-07-28 16:12:59 -04:00
2023-09-23 09:36:32 -04:00
ask_template( ) {
2024-01-16 13:19:49 -05:00
PRINT INPUT "Choose an extension template:"
2024-06-17 08:02:25 -04:00
echo -e " $( curl 'https://raw.githubusercontent.com/BlueprintFramework/templates/main/repository' 2>> " $BLUEPRINT__DEBUG " ) "
2023-10-10 15:28:42 -04:00
read -r ASKTEMPLATE
2023-09-23 09:36:32 -04:00
REDO_TEMPLATE = false
2023-10-24 08:53:17 -04:00
# Template should not be empty
2024-06-17 07:31:31 -04:00
if [ [ ${ ASKTEMPLATE } = = "" ] ] ; then
2024-01-15 17:59:30 -05:00
PRINT WARNING "Template should not be empty."
2023-09-23 09:36:32 -04:00
REDO_TEMPLATE = true
fi
# Unknown template.
2024-06-17 08:02:25 -04:00
if [ [ $( echo -e " $( curl " https://raw.githubusercontent.com/BlueprintFramework/templates/main/ ${ ASKTEMPLATE } /TemplateConfiguration.yml " 2>> " $BLUEPRINT__DEBUG " ) " ) = = "404: Not Found" ] ] ; then
2024-01-15 17:59:30 -05:00
PRINT WARNING "Unknown template, please choose a valid option."
2023-09-23 09:36:32 -04:00
REDO_TEMPLATE = true
fi
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_TEMPLATE } = = true ] ] ; then ASKTEMPLATE = "" ; ask_template; fi
2023-09-23 09:36:32 -04:00
}
2023-07-03 08:42:01 -04:00
ask_name( ) {
2024-02-24 15:52:53 -05:00
INPUT_DEFAULT = "SpaceInvaders"
PRINT INPUT " Name [ $INPUT_DEFAULT ]: "
2023-10-10 15:28:42 -04:00
read -r ASKNAME
2023-08-15 06:23:40 -04:00
REDO_NAME = false
2023-07-03 08:42:01 -04:00
# Name should not be empty
2024-06-17 07:31:31 -04:00
if [ [ ${ ASKNAME } = = "" ] ] ; then
2024-02-24 15:52:53 -05:00
ASKNAME = " $INPUT_DEFAULT "
2023-08-15 06:23:40 -04:00
fi
2023-07-03 08:42:01 -04:00
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_NAME } = = true ] ] ; then ASKNAME = "" ; ask_name; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
ask_identifier( ) {
2024-02-24 15:52:53 -05:00
INPUT_DEFAULT = "spaceinvaders"
PRINT INPUT " Identifier [ $INPUT_DEFAULT ]: "
2023-10-10 15:28:42 -04:00
read -r ASKIDENTIFIER
2023-08-15 06:23:40 -04:00
REDO_IDENTIFIER = false
2023-07-03 08:42:01 -04:00
# Identifier should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKIDENTIFIER } = = "" ] ] ; then
2024-02-24 15:52:53 -05:00
ASKIDENTIFIER = " $INPUT_DEFAULT "
2023-08-15 06:23:40 -04:00
fi
2023-07-03 08:42:01 -04:00
# Identifier should be a-z.
2024-01-15 17:59:30 -05:00
if ! [ [ ${ ASKIDENTIFIER } = ~ [ a-z] ] ] ; then
PRINT WARNING "Identifier should only contain a-z characters."
2023-08-15 06:23:40 -04:00
REDO_IDENTIFIER = true
fi
2023-07-03 08:42:01 -04:00
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_IDENTIFIER } = = true ] ] ; then ASKIDENTIFIER = "" ; ask_identifier; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
ask_description( ) {
2024-02-24 15:52:53 -05:00
INPUT_DEFAULT = "Shoot down space aliens!"
PRINT INPUT " Description [ $INPUT_DEFAULT ]: "
2023-10-10 15:28:42 -04:00
read -r ASKDESCRIPTION
2023-08-15 06:23:40 -04:00
REDO_DESCRIPTION = false
2023-07-03 08:42:01 -04:00
# Description should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKDESCRIPTION } = = "" ] ] ; then
2024-02-24 15:52:53 -05:00
ASKDESCRIPTION = " $INPUT_DEFAULT "
2023-08-15 06:23:40 -04:00
fi
2024-06-17 07:31:31 -04:00
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_DESCRIPTION } = = true ] ] ; then ASKDESCRIPTION = "" ; ask_description; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
ask_version( ) {
2024-02-24 15:52:53 -05:00
INPUT_DEFAULT = "1.0"
PRINT INPUT " Version [ $INPUT_DEFAULT ]: "
2023-10-10 15:28:42 -04:00
read -r ASKVERSION
2023-08-15 06:23:40 -04:00
REDO_VERSION = false
2023-07-03 08:42:01 -04:00
# Version should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKVERSION } = = "" ] ] ; then
2024-02-24 15:52:53 -05:00
ASKVERSION = " $INPUT_DEFAULT "
2023-08-15 06:23:40 -04:00
fi
2023-07-03 08:42:01 -04:00
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_VERSION } = = true ] ] ; then ASKVERSION = "" ; ask_version; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
ask_author( ) {
2024-02-24 15:52:53 -05:00
INPUT_DEFAULT = "byte"
PRINT INPUT " Author [ $INPUT_DEFAULT ]: "
2023-10-10 15:28:42 -04:00
read -r ASKAUTHOR
2023-08-15 06:23:40 -04:00
REDO_AUTHOR = false
2023-07-03 08:42:01 -04:00
# Author should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKAUTHOR } = = "" ] ] ; then
2024-02-24 15:52:53 -05:00
ASKAUTHOR = " $INPUT_DEFAULT "
2023-08-15 06:23:40 -04:00
fi
2024-06-17 07:31:31 -04:00
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_AUTHOR } = = true ] ] ; then ASKAUTHOR = "" ; ask_author; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
2023-09-23 10:07:49 -04:00
ask_template
2023-08-15 06:23:40 -04:00
ask_name
ask_identifier
ask_description
ask_version
ask_author
2023-06-02 10:37:38 -04:00
2023-10-24 09:00:28 -04:00
tnum = ${ ASKTEMPLATE }
2024-01-15 17:59:30 -05:00
PRINT INFO "Fetching templates.."
2024-02-14 02:21:09 -05:00
if [ [ $( php artisan bp:latest) != " $VERSION " ] ] ; then PRINT WARNING "Active Blueprint version is not latest, you might run into compatibility issues." ; fi
2024-01-15 17:59:30 -05:00
cd .blueprint/tmp || cdhalt
2024-03-11 12:49:47 -04:00
git clone "https://github.com/BlueprintFramework/templates.git"
2024-06-17 08:06:25 -04:00
cd " ${ FOLDER } " /.blueprint || cdhalt
2023-11-08 10:01:39 -05:00
cp -R tmp/templates/* extensions/blueprint/private/build/templates/
2023-10-13 14:25:35 -04:00
rm -R tmp/templates
2024-06-17 08:06:25 -04:00
cd " ${ FOLDER } " || cdhalt
2023-10-13 14:13:35 -04:00
2024-02-27 16:09:33 -05:00
eval " $( parse_yaml $__BuildDir /templates/" ${ tnum } " /TemplateConfiguration.yml t_) "
2023-09-23 10:07:49 -04:00
2024-01-15 17:59:30 -05:00
PRINT INFO "Building template.."
2023-08-15 06:23:40 -04:00
mkdir -p .blueprint/tmp/init
2024-02-27 16:09:33 -05:00
cp -R $__BuildDir /templates/" ${ tnum } " /contents/* .blueprint/tmp/init/
2023-06-02 10:37:38 -04:00
2024-01-31 13:36:44 -05:00
sed -i \
-e " s~␀name␀~ ${ ASKNAME } ~g " \
-e " s~␀identifier␀~ ${ ASKIDENTIFIER } ~g " \
-e " s~␀description␀~ ${ ASKDESCRIPTION } ~g " \
-e " s~␀ver␀~ ${ ASKVERSION } ~g " \
-e " s~␀author␀~ ${ ASKAUTHOR } ~g " \
-e " s~␀version␀~ ${ VERSION } ~g " \
2024-02-09 07:04:47 -05:00
-e " s~\[name\]~ ${ ASKNAME } ~g " \
-e " s~\[identifier\]~ ${ ASKIDENTIFIER } ~g " \
-e " s~\[description\]~ ${ ASKDESCRIPTION } ~g " \
-e " s~\[ver\]~ ${ ASKVERSION } ~g " \
-e " s~\[author\]~ ${ ASKAUTHOR } ~g " \
-e " s~\[version\]~ ${ VERSION } ~g " \
2024-01-31 13:36:44 -05:00
".blueprint/tmp/init/conf.yml"
2023-06-02 10:37:38 -04:00
# Return files to folder.
2023-08-15 06:23:40 -04:00
cp -R .blueprint/tmp/init/* .blueprint/dev/
2023-06-02 10:37:38 -04:00
2023-06-10 08:52:00 -04:00
# Remove tmp files.
2024-01-15 17:59:30 -05:00
PRINT INFO "Cleaning up build files.."
2024-01-31 13:36:44 -05:00
rm -R \
".blueprint/tmp" \
2024-02-27 16:09:33 -05:00
" $__BuildDir /templates/ " *
2023-08-15 06:23:40 -04:00
mkdir -p .blueprint/tmp
2023-06-02 10:37:38 -04:00
2024-01-31 13:36:44 -05:00
PRINT SUCCESS "Extension files initialized and imported to '.blueprint/dev'."
2024-06-17 08:06:25 -04:00
sendTelemetry "INITIALIZE_DEVELOPMENT_EXTENSION" >> " $BLUEPRINT__DEBUG "
2023-08-15 06:23:40 -04:00
fi
2023-05-17 03:55:16 -04:00
2023-08-06 07:41:56 -04:00
2023-06-28 15:31:22 -04:00
# -build
2023-09-23 11:14:04 -04:00
if [ [ ( $2 = = "-build" || $2 = = "-b" ) ] ] ; then VCMD = "y"
2023-12-30 18:16:40 -05:00
# Check for developer mode through the database library.
2024-01-15 11:40:12 -05:00
if ! dbValidate "blueprint.developerEnabled" ; then PRINT FATAL "Developer mode is not enabled." ; exit 2; fi
2023-08-07 09:53:49 -04:00
2023-10-13 13:43:33 -04:00
if [ [ -z $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory is empty."
2024-01-15 11:40:12 -05:00
exit 2
2023-08-15 06:23:40 -04:00
fi
2024-01-15 11:40:12 -05:00
PRINT INFO "Starting developer extension installation.."
2024-02-08 12:45:14 -05:00
blueprint -i "[developer-build]"
2023-08-15 06:23:40 -04:00
fi
2023-05-04 16:01:35 -04:00
2023-08-06 07:41:56 -04:00
2023-06-24 04:55:21 -04:00
# -export
2023-09-23 11:14:04 -04:00
if [ [ ( $2 = = "-export" || $2 = = "-e" ) ] ] ; then VCMD = "y"
2023-12-30 18:16:40 -05:00
# Check for developer mode through the database library.
2024-01-15 11:40:12 -05:00
if ! dbValidate "blueprint.developerEnabled" ; then PRINT FATAL "Developer mode is not enabled." ; exit 2; fi
2023-08-15 06:05:59 -04:00
2023-10-13 13:43:33 -04:00
if [ [ -z $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory is empty."
2024-01-15 11:40:12 -05:00
exit 2
2023-08-15 06:23:40 -04:00
fi
2023-08-04 06:47:25 -04:00
2024-01-15 11:40:12 -05:00
PRINT INFO "Start packaging extension.."
2023-05-29 14:33:01 -04:00
2024-01-15 17:59:30 -05:00
cd .blueprint || cdhalt
2024-06-17 08:06:25 -04:00
rm dev/.gitkeep 2>> " $BLUEPRINT__DEBUG "
2023-11-23 13:02:33 -05:00
2023-11-23 09:52:16 -05:00
eval " $( parse_yaml dev/conf.yml conf_) " ; identifier = " ${ conf_info_identifier } "
2023-11-23 13:02:33 -05:00
2024-01-31 13:36:44 -05:00
cp -r dev/* tmp/
2024-01-15 17:59:30 -05:00
cd tmp || cdhalt
2023-11-23 13:02:33 -05:00
2023-12-11 09:50:54 -05:00
# Assign variables to extension flags.
flags = " $conf_info_flags "
2024-01-15 11:40:12 -05:00
PRINT INFO "Reading and assigning extension flags.."
2023-12-11 09:50:54 -05:00
assignflags
if $F_hasExportScript ; then
2023-11-23 13:12:53 -05:00
chmod +x " ${ conf_data_directory } " "/export.sh"
2023-11-25 07:38:37 -05:00
2023-11-23 13:12:53 -05:00
# Run script while also parsing some useful variables for the export script to use.
2024-05-15 14:07:18 -04:00
if $F_developerEscalateExportScript ; then
EXTENSION_IDENTIFIER = " $conf_info_identifier " \
EXTENSION_TARGET = " $conf_info_target " \
EXTENSION_VERSION = " $conf_info_version " \
PTERODACTYL_DIRECTORY = " $FOLDER " \
BLUEPRINT_EXPORT_DIRECTORY = " $FOLDER /.blueprint/tmp " \
BLUEPRINT_VERSION = " $VERSION " \
bash " ${ conf_data_directory } " /export.sh
else
su " $WEBUSER " -s " $USERSHELL " -c "
cd \" $FOLDER \" /.blueprint/tmp;
EXTENSION_IDENTIFIER = \" $conf_info_identifier \" \
EXTENSION_TARGET = \" $conf_info_target \" \
EXTENSION_VERSION = \" $conf_info_version \" \
PTERODACTYL_DIRECTORY = \" $FOLDER \" \
BLUEPRINT_EXPORT_DIRECTORY = \" $FOLDER /.blueprint/tmp\" \
BLUEPRINT_VERSION = \" $VERSION \" \
bash \" ${ conf_data_directory } \" /export.sh
"
fi
2023-11-23 13:12:53 -05:00
echo -e "\e[0m\x1b[0m\033[0m"
fi
2023-11-23 13:02:33 -05:00
2023-12-22 11:51:20 -05:00
zip -r extension.zip ./*
2024-06-17 08:06:25 -04:00
cd " ${ FOLDER } " || cdhalt
2023-12-17 06:40:57 -05:00
cp .blueprint/tmp/extension.zip " ${ identifier } .blueprint "
2023-08-15 06:23:40 -04:00
rm -R .blueprint/tmp
mkdir -p .blueprint/tmp
2023-06-26 08:42:31 -04:00
2024-06-17 07:31:31 -04:00
if [ [ $3 = = "expose" * ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT INFO "Generating download url.. (expires after 2 minutes)"
2023-11-01 05:54:10 -04:00
randstr = ${ RANDOM } ${ RANDOM } ${ RANDOM } ${ RANDOM } ${ RANDOM }
2023-11-08 10:01:39 -05:00
mkdir .blueprint/extensions/blueprint/assets/exports/${ randstr }
2023-12-17 06:57:26 -05:00
cp " ${ identifier } " .blueprint .blueprint/extensions/blueprint/assets/exports/${ randstr } /" ${ identifier } " .blueprint
2023-10-31 06:50:41 -04:00
2024-01-15 16:09:31 -05:00
PRINT SUCCESS " Extension has been exported to ' $( grabAppUrl) /assets/extensions/blueprint/exports/ ${ randstr } / ${ identifier } .blueprint' and ' ${ FOLDER } / ${ identifier } .blueprint'. "
2024-06-22 15:25:29 -04:00
sleep 120 && rm -R .blueprint/extensions/blueprint/assets/exports/${ randstr } 2>> " $BLUEPRINT__DEBUG " &
2023-10-31 06:28:47 -04:00
else
2024-01-15 16:09:31 -05:00
PRINT SUCCESS " Extension has been exported to ' ${ FOLDER } / ${ identifier } .blueprint'. "
2023-10-31 06:28:47 -04:00
fi
2024-06-17 08:06:25 -04:00
sendTelemetry "EXPORT_DEVELOPMENT_EXTENSION" >> " $BLUEPRINT__DEBUG "
2023-09-23 11:14:04 -04:00
fi
# -wipe
if [ [ ( $2 = = "-wipe" || $2 = = "-w" ) ] ] ; then VCMD = "y"
2023-12-30 18:16:40 -05:00
# Check for developer mode through the database library.
2024-01-15 11:40:12 -05:00
if ! dbValidate "blueprint.developerEnabled" ; then PRINT FATAL "Developer mode is not enabled." ; exit 2; fi
2023-10-25 13:02:33 -04:00
2023-10-13 13:43:33 -04:00
if [ [ -z $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory is empty."
2024-01-16 15:33:37 -05:00
exit 2
2023-09-24 09:58:26 -04:00
fi
2024-01-15 16:09:31 -05:00
PRINT INPUT "You are about to wipe all of your development files, are you sure you want to continue? This cannot be undone. (y/N)"
2023-10-10 15:28:42 -04:00
read -r YN
2024-01-15 16:09:31 -05:00
if [ [ ( ( ${ YN } != "y" * ) && ( ${ YN } != "Y" * ) ) || ( ( ${ YN } = = "" ) ) ] ] ; then PRINT INFO "Development files removal cancelled." ; exit 1; fi
2023-09-23 11:14:04 -04:00
2024-01-15 16:09:31 -05:00
PRINT INFO "Clearing development folder.."
2024-01-31 13:36:44 -05:00
rm -R \
.blueprint/dev/* \
.blueprint/dev/.* \
2024-06-17 08:06:25 -04:00
2>> " $BLUEPRINT__DEBUG "
2023-09-23 11:14:04 -04:00
2024-01-15 16:09:31 -05:00
PRINT SUCCESS "Development folder has been cleared."
2023-08-15 06:23:40 -04:00
fi
2023-05-29 14:33:01 -04:00
2024-01-31 13:36:44 -05:00
2023-11-02 14:14:06 -04:00
# -info
if [ [ ( $2 = = "-info" || $2 = = "-f" ) ] ] ; then VCMD = "y"
2024-01-20 08:19:51 -05:00
fetchversion( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $VERSION != "" ] ] ; then echo $VERSION ; else echo "none" ; fi }
2024-06-17 08:06:25 -04:00
fetchfolder( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $FOLDER != "" ] ] ; then echo " $FOLDER " ; else echo "none" ; fi }
2024-01-20 08:19:51 -05:00
fetchurl( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( grabAppUrl) != "" ] ] ; then grabAppUrl; else echo "none" ; fi }
fetchlocale( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( grabAppLocale) != "" ] ] ; then grabAppLocale; else echo "none" ; fi }
fetchtimezone( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( grabAppTimezone) != "" ] ] ; then grabAppTimezone; else echo "none" ; fi }
2024-06-04 08:13:20 -04:00
fetchextensions( ) { printf "\x1b[0m\x1b[37m" ; tr -cd ',' <.blueprint/extensions/blueprint/private/db/installed_extensions | wc -c | tr -d ' ' ; }
2024-05-21 05:09:39 -04:00
fetchdeveloper( ) { printf "\x1b[0m\x1b[37m" ; if dbValidate "blueprint.developerEnabled" ; then echo "true" ; else echo "false" ; fi }
fetchtelemetry( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( cat .blueprint/extensions/blueprint/private/db/telemetry_id) = = "KEY_NOT_UPDATED" ] ] ; then echo "false" ; else echo "true" ; fi }
2024-01-20 08:19:51 -05:00
fetchnode( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( node -v) != "" ] ] ; then node -v; else echo "none" ; fi }
fetchyarn( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( yarn -v) != "" ] ] ; then yarn -v; else echo "none" ; fi }
echo " "
echo -e " \x1b[34;1m ⣿⣿ Version: $( fetchversion) "
echo -e " \x1b[34;1m ⣿⣿ ⣿⣿ Folder: $( fetchfolder) "
echo -e " \x1b[34;1m ⣿⣿⣿⣿ URL: $( fetchurl) "
echo -e " \x1b[34;1m Locale: $( fetchlocale) "
echo -e " \x1b[34;1m Timezone: $( fetchtimezone) "
echo -e " \x1b[34;1m Extensions: $( fetchextensions) "
echo -e " \x1b[34;1m Developer: $( fetchdeveloper) "
echo -e " \x1b[34;1m Telemetry: $( fetchtelemetry) "
echo -e " \x1b[34;1m Node: $( fetchnode) "
echo -e " \x1b[34;1m Yarn: $( fetchyarn) "
echo -e "\x1b[0m"
2023-11-02 14:14:06 -04:00
fi
2023-08-06 07:41:56 -04:00
2024-01-31 13:36:44 -05:00
2023-08-14 07:28:15 -04:00
# -rerun-install
2023-11-02 14:14:06 -04:00
if [ [ $2 = = "-rerun-install" ] ] ; then VCMD = "y"
2024-01-15 16:09:31 -05:00
PRINT WARNING "This is an advanced feature, only proceed if you know what you are doing."
2023-08-15 06:23:40 -04:00
dbRemove "blueprint.setupFinished"
2024-06-17 08:06:25 -04:00
cd " ${ FOLDER } " || cdhalt
2023-08-15 06:23:40 -04:00
bash blueprint.sh
fi
2023-06-01 15:25:15 -04:00
2024-01-31 13:36:44 -05:00
2023-06-18 10:37:46 -04:00
# -upgrade
2023-08-15 06:23:40 -04:00
if [ [ $2 = = "-upgrade" ] ] ; then VCMD = "y"
2024-01-15 16:09:31 -05:00
PRINT WARNING "This is an advanced feature, only proceed if you know what you are doing."
2023-07-14 04:39:26 -04:00
2023-12-22 07:31:44 -05:00
# Confirmation question for developer upgrade.
2024-03-20 06:26:30 -04:00
if [ [ $3 = = "remote" ] ] ; then
PRINT INPUT "Upgrading to the latest development build will update Blueprint to a remote version which might differ from the latest release. Continue? (y/N)"
2023-12-22 07:31:44 -05:00
read -r YN
2024-01-15 16:09:31 -05:00
if [ [ ( ${ YN } != "y" * ) && ( ${ YN } != "Y" * ) ] ] ; then PRINT INFO "Upgrade cancelled." ; exit 1; fi
2023-12-22 07:31:44 -05:00
YN = ""
2023-08-15 06:23:40 -04:00
fi
2023-12-22 07:31:44 -05:00
# Confirmation question for both developer and stable upgrade.
2024-01-15 16:09:31 -05:00
PRINT INPUT "Upgrading will wipe your .blueprint folder and will deactivate all active extensions. Continue? (y/N)"
2023-12-22 07:31:44 -05:00
read -r YN
2024-01-15 16:09:31 -05:00
if [ [ ( ${ YN } != "y" * ) && ( ${ YN } != "Y" * ) ] ] ; then PRINT INFO "Upgrade cancelled." ; exit 1; fi
2023-12-22 07:31:44 -05:00
YN = ""
# Last confirmation question for both developer and stable upgrade.
2024-01-15 16:09:31 -05:00
PRINT INPUT "This is the last warning before upgrading/wiping Blueprint. Type 'continue' to continue, all other input will be taken as 'no'."
2023-12-22 07:31:44 -05:00
read -r YN
2024-01-15 16:09:31 -05:00
if [ [ ${ YN } != "continue" ] ] ; then PRINT INFO "Upgrade cancelled." ; exit 1; fi
2023-12-22 07:31:44 -05:00
YN = ""
2024-06-17 07:31:31 -04:00
2023-08-15 06:23:40 -04:00
2024-03-20 06:23:27 -04:00
if [ [ $3 = = "remote" ] ] ; then PRINT INFO "Fetching and pulling latest commit.."
else PRINT INFO "Fetching and pulling latest release.." ; fi
2024-01-15 16:09:31 -05:00
2024-06-17 08:06:25 -04:00
mkdir " $FOLDER /.tmp "
2023-08-15 06:23:40 -04:00
cp blueprint.sh .blueprint.sh.bak
2024-01-18 05:03:13 -05:00
2024-03-03 06:51:18 -05:00
HAS_DEV = false
if [ [ -n $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
PRINT INFO "Backing up extension development files.."
2024-06-17 08:06:25 -04:00
mkdir -p " $FOLDER /.tmp/dev "
cp .blueprint/dev/* " $FOLDER /.tmp/dev/ " -Rf
2024-03-03 06:51:18 -05:00
HAS_DEV = true
fi
2024-06-17 08:06:25 -04:00
mkdir -p " $FOLDER /.tmp/files "
cd " $FOLDER /.tmp/files " || cdhalt
2024-03-20 06:23:27 -04:00
if [ [ $3 = = "remote" ] ] ; then
2024-06-08 17:44:55 -04:00
if [ [ $4 = = "" ] ] ; then REMOTE_REPOSITORY = " $REPOSITORY "
2024-03-20 06:23:27 -04:00
else REMOTE_REPOSITORY = " $4 " ; fi
2024-01-18 05:03:13 -05:00
# download latest commit
2024-03-20 06:23:27 -04:00
git clone https://github.com/" $REMOTE_REPOSITORY " .git main
2024-01-18 05:03:13 -05:00
else
# download latest release
2024-06-08 17:44:55 -04:00
LOCATION = $( curl -s https://api.github.com/repos/" $REPOSITORY " /releases/latest \
2024-01-18 05:03:13 -05:00
| grep "zipball_url" \
| awk '{ print $2 }' \
| sed 's/,$//' \
| sed 's/"//g' ) \
; curl -L -o main.zip " $LOCATION "
unzip main.zip
rm main.zip
mv ./* main
fi
2024-03-20 06:23:27 -04:00
if [ [ ! -d "main" ] ] ; then
2024-06-17 08:06:25 -04:00
cd " $FOLDER " || cdhalt
rm -r " $FOLDER /.tmp " & >> " $BLUEPRINT__DEBUG "
rm " $FOLDER /.blueprint.sh.bak " & >> " $BLUEPRINT__DEBUG "
2024-03-20 06:23:27 -04:00
PRINT FATAL "Remote does not exist or encountered an error, try again later."
2024-03-20 06:27:44 -04:00
exit 1
2024-03-20 06:23:27 -04:00
fi
2024-03-24 15:02:10 -04:00
# Remove some files/directories that don't have to be moved to the Pterodactyl folder.
rm -r \
2024-03-24 15:05:04 -04:00
"main/.github" \
"main/.git" \
2024-03-29 09:32:33 -04:00
"main/.gitignore" \
"main/README.md" \
2024-06-17 08:06:25 -04:00
& >> " $BLUEPRINT__DEBUG "
2024-03-24 15:02:10 -04:00
# Copy fetched release files to the Pterodactyl directory and remove temp files.
2024-01-18 05:03:13 -05:00
cp -r main/* " $FOLDER " /
2024-03-24 15:02:10 -04:00
rm -r \
2024-01-31 13:36:44 -05:00
"main" \
" $FOLDER " /.blueprint \
2024-03-03 06:51:18 -05:00
" $FOLDER " /.tmp/files
2024-06-17 08:06:25 -04:00
cd " $FOLDER " || cdhalt
2023-12-22 07:31:44 -05:00
2024-04-09 07:41:41 -04:00
# Clean up folders with potentially broken symlinks.
rm \
"resources/views/blueprint/admin/wrappers/" * \
"resources/views/blueprint/dashboard/wrappers/" * \
"routes/blueprint/application/" * \
"routes/blueprint/client/" * \
2024-04-10 04:22:02 -04:00
"routes/blueprint/web/" * \
2024-04-10 04:57:11 -04:00
& >> /dev/null # cannot forward to debug dir because it does not exist
2024-04-09 07:41:41 -04:00
2023-08-15 06:23:40 -04:00
chmod +x blueprint.sh
2024-05-06 10:43:16 -04:00
sed -i -E \
-e " s|OWNERSHIP=\"www-data:www-data\" #;|OWNERSHIP=\" $OWNERSHIP \" #;|g " \
-e " s|WEBUSER=\"www-data\" #;|WEBUSER=\" $WEBUSER \" #;|g " \
2024-05-15 08:51:42 -04:00
-e " s|USERSHELL=\"/bin/bash\" #;|USERSHELL=\" $USERSHELL \" #;|g " \
2024-06-17 08:06:25 -04:00
" $FOLDER /blueprint.sh "
mv " $FOLDER /blueprint " " $FOLDER /.blueprint "
2023-11-28 11:40:08 -05:00
bash blueprint.sh --post-upgrade
2023-12-22 07:31:44 -05:00
# Ask user if they'd like to migrate their database.
2024-01-15 12:34:11 -05:00
PRINT INPUT "Would you like to migrate your database? (Y/n)"
2023-12-22 07:31:44 -05:00
read -r YN
2024-06-17 07:31:31 -04:00
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT INFO "Running database migrations.."
2023-08-16 12:45:50 -04:00
php artisan migrate --force
2024-06-17 08:06:25 -04:00
php artisan up & >> " $BLUEPRINT__DEBUG "
2023-06-10 08:52:00 -04:00
else
2024-01-15 12:34:11 -05:00
PRINT INFO "Database migrations have been skipped."
2023-08-15 06:23:40 -04:00
fi
2023-12-22 07:31:44 -05:00
YN = ""
2023-06-12 09:21:38 -04:00
2024-03-03 06:51:18 -05:00
if [ [ ${ HAS_DEV } = = true ] ] ; then
PRINT INFO "Restoring extension development files.."
mkdir -p .blueprint/dev
2024-06-17 08:06:25 -04:00
cp " $FOLDER /.tmp/dev/ " * .blueprint/dev -r
rm " $FOLDER /.tmp/dev " -rf
2024-03-03 06:51:18 -05:00
fi
2024-06-17 08:06:25 -04:00
rm -r " $FOLDER /.tmp "
2024-03-03 06:51:18 -05:00
2023-07-28 16:12:59 -04:00
# Post-upgrade checks.
2024-01-15 16:09:31 -05:00
PRINT INFO "Validating update.."
2023-08-15 06:23:40 -04:00
score = 0
2023-06-12 09:21:38 -04:00
2024-01-31 13:36:44 -05:00
if dbValidate "blueprint.setupFinished" ; then score = $(( score+1))
else PRINT WARNING "'blueprint.setupFinished' could not be detected or found." ; fi
2023-06-12 09:21:38 -04:00
2023-07-28 16:12:59 -04:00
# Finalize upgrade.
2023-10-24 09:04:22 -04:00
if [ [ ${ score } = = 1 ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT SUCCESS "Upgrade finished."
2023-08-15 06:23:40 -04:00
rm .blueprint.sh.bak
2024-01-15 16:09:31 -05:00
exit 0 # success
2023-10-24 09:04:22 -04:00
elif [ [ ${ score } = = 0 ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "All checks have failed. The 'blueprint.sh' file has been reverted."
2023-08-15 06:23:40 -04:00
rm blueprint.sh
mv .blueprint.sh.bak blueprint.sh
2024-01-15 16:09:31 -05:00
exit 1 # error
2023-06-10 08:52:00 -04:00
else
2024-01-15 16:09:31 -05:00
PRINT FATAL "Some checks have failed. The 'blueprint.sh' file has been reverted."
2023-08-15 06:23:40 -04:00
rm blueprint.sh
mv .blueprint.sh.bak blueprint.sh
2024-01-15 16:09:31 -05:00
exit 1 # error
2023-08-15 06:23:40 -04:00
fi
fi
2023-08-09 06:57:18 -04:00
# When the users attempts to run an invalid command.
2023-10-24 09:04:22 -04:00
if [ [ ${ VCMD } != "y" && $1 = = "-bash" ] ] ; then
2023-08-15 06:10:30 -04:00
# This is logged as a "fatal" error since it's something that is making Blueprint run unsuccessfully.
2024-01-15 17:59:30 -05:00
PRINT FATAL " ' $2 ' is not a valid command or argument. Use argument '-help' for a list of commands. "
2024-05-31 03:58:57 -04:00
exit 2
2024-06-23 10:38:57 -04:00
fi