2023-03-03 10:52:29 -05:00
#!/bin/bash
2023-06-26 08:42:31 -04:00
# ptero.shop
# github.com/teamblueprint/main
# prpl.wtf
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.
2023-08-31 12:00:27 -04:00
FOLDER = "/var/www/pterodactyl" #;
2023-05-06 10:21:22 -04:00
2023-08-27 10:01:36 -04:00
# If the fallback version below does not match your downloaded version, please let us know.
2023-10-10 15:27:41 -04:00
VER_FALLBACK = "alpha-IPS"
2023-08-27 10:01:36 -04:00
# This will be automatically replaced by some marketplaces, if not, $VER_FALLBACK will be used as fallback.
PM_VERSION = "([(pterodactylmarket_version)])"
2023-08-31 12:13:44 -04:00
# Allow non-default Pterodactyl installation folders.
if [ [ $_FOLDER != "" ] ] ; then
2023-08-31 12:33:19 -04:00
if [ [ ( ! -f " $FOLDER /.blueprint/data/internal/db/version " ) && ( $FOLDER = = "/var/www/pterodactyl" ) ] ] ; then
2023-11-06 15:05:12 -05:00
sed -i -E " s|FOLDER=\"/var/www/pterodactyl\" #;|FOLDER=\" $_FOLDER \" #;|g " $_FOLDER /blueprint.sh
2023-08-31 12:19:27 -04:00
else
echo "Variable cannot be replaced right now."
2023-08-31 12:33:19 -04:00
exit 1
2023-08-31 12:19:27 -04:00
fi
2023-08-31 12:13:44 -04:00
fi
2023-07-09 01:47:40 -04:00
# Check for panels that are using Docker.
2023-05-06 10:21:22 -04:00
if [ [ -f ".dockerenv" ] ] ; then
2023-08-15 06:23:40 -04:00
DOCKER = "y"
2023-07-25 16:42:32 -04:00
FOLDER = "/var/www/html"
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
2023-08-15 06:23:40 -04:00
if [ [ -d " $FOLDER /blueprint " ] ] ; then mv $FOLDER /blueprint $FOLDER /.blueprint; fi
2023-04-25 13:33:21 -04:00
2023-06-02 09:00:08 -04:00
if [ [ $PM_VERSION = = "([(pterodactylmarket" "_version)])" ] ] ; then
2023-06-02 10:37:38 -04:00
# This runs when the placeholder has not changed, indicating an issue with PterodactylMarket
# or Blueprint being installed from other sources.
2023-07-25 16:42:32 -04:00
if [ [ ! -f " $FOLDER /.blueprint/data/internal/db/version " ] ] ; then
2023-09-07 10:32:29 -04:00
sed -E -i " s*&bp.version&* $VER_FALLBACK *g " app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php
2023-11-08 05:49:40 -05:00
sed -E -i " s*@version* $VER_FALLBACK *g " .blueprint/data/extensions/public/blueprint/index.html
2023-08-15 06:23:40 -04:00
touch $FOLDER /.blueprint/data/internal/db/version
fi
2023-06-02 10:37:38 -04:00
2023-08-15 06:23:40 -04:00
VERSION = $VER_FALLBACK
2023-04-24 10:43:31 -04:00
elif [ [ $PM_VERSION != "([(pterodactylmarket" "_version)])" ] ] ; then
2023-06-02 10:37:38 -04:00
# This runs in case it is possible to use the PterodactylMarket placeholder instead of the
# fallback version.
2023-07-25 16:42:32 -04:00
if [ [ ! -f " $FOLDER /.blueprint/data/internal/db/version " ] ] ; then
2023-09-07 10:32:29 -04:00
sed -E -i " s*&bp.version&* $PM_VERSION *g " app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php
2023-11-08 05:49:40 -05:00
sed -E -i " s*@version* $PM_VERSION *g " .blueprint/data/extensions/public/blueprint/index.html
2023-08-15 06:23:40 -04:00
touch $FOLDER /.blueprint/data/internal/db/version
fi
2023-06-02 10:37:38 -04:00
2023-08-15 06:23:40 -04:00
VERSION = $PM_VERSION
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-11-01 09:51:42 -04:00
export NODE_OPTIONS = --openssl-legacy-provider
2023-08-15 06:23:40 -04:00
# Automatically navigate to the Pterodactyl directory when running the core.
cd $FOLDER
2023-05-09 11:59:12 -04:00
2023-06-18 10:37:46 -04:00
# Import libraries.
2023-10-31 10:38:29 -04:00
source .blueprint/lib/bash_colors.sh
source .blueprint/lib/parse_yaml.sh
source .blueprint/lib/db.sh
source .blueprint/lib/telemetry.sh
source .blueprint/lib/updateAdminCacheReminder.sh
source .blueprint/lib/grabenv.sh
2023-10-25 13:18:43 -04:00
if [ [ ! -f ".blueprint/lib/bash_colors.sh" ] ] ; then LIB__bash_colors = "missing" ; fi
if [ [ ! -f ".blueprint/lib/parse_yaml.sh" ] ] ; then LIB__parse_yaml = "missing" ; fi
if [ [ ! -f ".blueprint/lib/db.sh" ] ] ; then LIB__db = "missing" ; fi
if [ [ ! -f ".blueprint/lib/telemetry.sh" ] ] ; then LIB__telemetry = "missing" ; fi
if [ [ ! -f ".blueprint/lib/updateAdminCacheReminder.sh" ] ] ; then LIB__updateAdminCacheReminder = "missing" ; fi
2023-11-01 10:32:11 -04:00
if [ [ ! -f ".blueprint/lib/grabenv.sh" ] ] ; then LIB__grabEnv = "missing" ; fi
2023-03-03 10:52:29 -05:00
2023-08-06 07:41:56 -04:00
# Fallback to these functions if "bash_colors.sh" is missing
if [ [ $LIB__bash_colors = = "missing" ] ] ; then
2023-08-15 06:23:40 -04:00
log_reset( ) { echo -e " $1 " ; }
log_reset_underline( ) { echo -e " $1 " ; }
log_reset_reverse( ) { echo -e " $1 " ; }
log_default( ) { echo -e " $1 " ; }
log_defaultb ( ) { echo -e " $1 " ; }
log_bold( ) { echo -e " $1 " ; }
log_bright( ) { echo -e " $1 " ; }
log_underscore( ) { echo -e " $1 " ; }
log_reverse( ) { echo -e " $1 " ; }
log_black( ) { echo -e " $1 " ; }
log_red( ) { echo -e " $1 " ; }
log_green( ) { echo -e " $1 " ; }
log_brown( ) { echo -e " $1 " ; }
log_blue( ) { echo -e " $1 " ; }
log_magenta( ) { echo -e " $1 " ; }
log_cyan( ) { echo -e " $1 " ; }
log_white( ) { echo -e " $1 " ; }
log_yellow( ) { echo -e " $1 " ; }
log_blackb( ) { echo -e " $1 " ; }
log_redb( ) { echo -e " $1 " ; }
log_greenb( ) { echo -e " $1 " ; }
log_brownb( ) { echo -e " $1 " ; }
log_blueb( ) { echo -e " $1 " ; }
log_magentab( ) { echo -e " $1 " ; }
log_cyanb( ) { echo -e " $1 " ; }
log_whiteb( ) { echo -e " $1 " ; }
log_yellowb( ) { echo -e " $1 " ; }
fi
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.
if [ [ $cTELEMETRY_ID != "" ] ] ; then
2023-08-15 06:23:40 -04:00
echo " $cTELEMETRY_ID " > .blueprint/data/internal/db/telemetry_id
fi
2023-06-27 15:49:11 -04:00
2023-08-07 09:50:54 -04:00
# cDEVELOPER
# Enable/Disable developer mode.
if [ [ $cDEVELOPER != "" ] ] ; then
2023-11-01 09:51:42 -04:00
if [ [ $cDEVELOPER = = "true" ] ] ; then
dbAdd "blueprint.developerEnabled"
else
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 .
exit 1
fi
2023-04-23 15:23:15 -04:00
2023-08-06 07:41:56 -04:00
2023-06-18 10:37:46 -04:00
# Function that exits the script after logging a "red" message.
2023-08-15 06:23:40 -04:00
quit_red( ) { log_red " $1 " ; 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( ) {
2023-09-11 10:29:38 -04:00
# Check for incorrect node version.
nodeVer = $( node -v)
if [ [ $nodeVer != "v17." * ] ] && [ [ $nodeVer != "v18." * ] ] && [ [ $nodeVer != "v19." * ] ] && [ [ $nodeVer != "v20." * ] ] && [ [ $nodeVer != "v21." * ] ] ; then DEPEND_MISSING = true; fi
2023-08-18 12:29:01 -04:00
# Check for required dependencies.
2023-10-15 07:09:40 -04:00
if ! [ -x " $( command -v unzip) " ] ; then DEPEND_MISSING = true; fi
if ! [ -x " $( command -v node) " ] ; then DEPEND_MISSING = true; fi
if ! [ -x " $( command -v yarn) " ] ; then DEPEND_MISSING = true; fi
if ! [ -x " $( command -v zip) " ] ; then DEPEND_MISSING = true; fi
if ! [ -x " $( command -v curl) " ] ; then DEPEND_MISSING = true; fi
if ! [ -x " $( command -v php) " ] ; then DEPEND_MISSING = true; fi
2023-10-23 17:19:23 -04:00
if ! [ -x " $( command -v git) " ] ; then DEPEND_MISSING = true; fi
2023-10-25 13:18:43 -04:00
if ! [ -x " $( command -v grep) " ] ; then DEPEND_MISSING = true; fi
if ! [ -x " $( command -v sed) " ] ; then DEPEND_MISSING = true; fi
if ! [ -x " $( command -v awk) " ] ; then DEPEND_MISSING = true; fi
2023-10-15 07:09:40 -04:00
if [ [ " $( npm ls | grep "cross-env" ) " = = "" ] ] ; then DEPEND_MISSING = true; fi
2023-08-18 12:29:01 -04:00
# Check for internal dependencies.
2023-09-11 10:23:49 -04:00
if [ [ $LIB__bash_colors ] ] ; then DEPEND_MISSING = true; fi
if [ [ $LIB__parse_yaml ] ] ; then DEPEND_MISSING = true; fi
if [ [ $LIB__db ] ] ; then DEPEND_MISSING = true; fi
if [ [ $LIB__telemetry ] ] ; then DEPEND_MISSING = true; fi
if [ [ $LIB__updateAdminCacheReminder ] ] ; then DEPEND_MISSING = true; fi
2023-10-31 10:35:14 -04:00
if [ [ $LIB__grabEnv ] ] ; then DEPEND_MISSING = true; fi
2023-08-18 12:29:01 -04:00
# Exit when missing dependencies.
2023-09-11 10:23:49 -04:00
if [ [ $DEPEND_MISSING = = true ] ] ; then
2023-11-01 08:23:25 -04:00
log_red log_bold "[FATAL] Blueprint found errors for the following dependencies:"
2023-09-11 10:23:49 -04:00
2023-10-31 10:35:14 -04:00
if [ [ $nodeVer != "v18." * ] ] && [ [ $nodeVer != "v19." * ] ] && [ [ $nodeVer != "v20." * ] ] && [ [ $nodeVer != "v21." * ] ] ; then log_red " - \"node\" ( $( node -v) ) is an unsupported version. " ; fi
2023-09-11 10:29:38 -04:00
2023-10-15 07:09:40 -04:00
if ! [ -x " $( command -v unzip) " ] ; then log_red " - \"unzip\" is not installed or detected." ; fi
if ! [ -x " $( command -v node) " ] ; then log_red " - \"node\" is not installed or detected." ; fi
if ! [ -x " $( command -v yarn) " ] ; then log_red " - \"yarn\" is not installed or detected." ; fi
if ! [ -x " $( command -v zip) " ] ; then log_red " - \"zip\" is not installed or detected." ; fi
if ! [ -x " $( command -v curl) " ] ; then log_red " - \"curl\" is not installed or detected." ; fi
if ! [ -x " $( command -v php) " ] ; then log_red " - \"php\" is not installed or detected." ; fi
2023-10-23 17:19:23 -04:00
if ! [ -x " $( command -v git) " ] ; then log_red " - \"git\" is not installed or detected." ; fi
2023-10-25 13:18:43 -04:00
if ! [ -x " $( command -v grep) " ] ; then log_red " - \"grep\" is not installed or detected." ; fi
if ! [ -x " $( command -v sed) " ] ; then log_red " - \"sed\" is not installed or detected." ; fi
if ! [ -x " $( command -v awk) " ] ; then log_red " - \"awk\" is not installed or detected." ; fi
2023-10-15 07:09:40 -04:00
if [ [ " $( npm ls | grep "cross-env" ) " = = "" ] ] ; then log_red " - \"cross-env\" is not installed or detected." ; fi
2023-09-11 10:29:38 -04:00
if [ [ $LIB__bash_colors ] ] ; then log_red " - \"internal:bash_colors\" is not installed or detected." ; fi
if [ [ $LIB__parse_yaml ] ] ; then log_red " - \"internal:parse_yaml\" is not installed or detected." ; fi
if [ [ $LIB__db ] ] ; then log_red " - \"internal:db\" is not installed or detected." ; fi
if [ [ $LIB__telemetry ] ] ; then log_red " - \"internal:telemetry\" is not installed or detected." ; fi
if [ [ $LIB__updateAdminCacheReminder ] ] ; then log_red " - \"internal:updateAdminCacheReminder\" is not installed or detected." ; fi
2023-10-31 10:35:14 -04:00
if [ [ $LIB__grabEnv ] ] ; then log_red " - \"internal:grabEnv\" 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-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.
2023-08-15 06:23:40 -04:00
touch /usr/local/bin/blueprint > /dev/null
echo -e " #!/bin/bash\nbash $FOLDER /blueprint.sh -bash \$@; " > /usr/local/bin/blueprint
chmod u+x $FOLDER /blueprint.sh > /dev/null
chmod u+x /usr/local/bin/blueprint > /dev/null
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
2023-08-15 06:23:40 -04:00
log_yellow "[WARNING] This command only works if you have yet to install Blueprint. Run 'blueprint (cmd) [arg]' instead."
exit 1
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
2023-08-20 04:46:52 -04:00
log " ██\n██ ██\n ████\n" ; # Blueprint "ascii" "logo".
2023-06-10 08:52:00 -04:00
if [ [ $DOCKER = = "y" ] ] ; then
2023-08-15 06:23:40 -04:00
log_yellow "[WARNING] While running Blueprint with docker is supported, you may run into some issues. Report problems you find at ptero.shop/issue."
fi
fi
2023-05-06 10:21:22 -04:00
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Checking dependencies.."
2023-07-30 06:13:53 -04:00
# Check if required programs are installed
2023-08-15 06:23:40 -04:00
depend
2023-07-30 06:13:53 -04:00
2023-11-08 05:35:18 -05:00
# Link directories.
log_bright "[INFO] Linking directories.."
2023-11-08 09:25:41 -05:00
cd $FOLDER /public; ln -s -T $FOLDER /.blueprint/data/extensions/public extensions 2> /dev/null; cd $FOLDER
2023-11-08 05:35:18 -05:00
2023-06-26 06:40:33 -04:00
# Update folder placeholder on PlaceholderService and admin layout.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Updating folder placeholders.."
2023-09-07 10:17:04 -04:00
sed -i " s!&bp.folder&! $FOLDER !g " $FOLDER /app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php
2023-08-15 06:23:40 -04:00
sed -i " s!&bp.folder&! $FOLDER !g " $FOLDER /resources/views/layouts/admin.blade.php
2023-05-06 10:21:22 -04:00
2023-07-04 04:37:31 -04:00
# Copy "Blueprint" extension page logo from assets.
2023-09-24 09:58:26 -04:00
log_bright "[INFO] Copying Blueprint logo from assets.."
2023-08-15 06:23:40 -04:00
cp $FOLDER /.blueprint/assets/logo.jpg $FOLDER /public/assets/extensions/blueprint/logo.jpg
2023-07-04 04:37:31 -04:00
2023-06-17 07:28:26 -04:00
# Put application into maintenance.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Enable maintenance."
php artisan down
2023-04-10 10:50:23 -04:00
2023-06-17 07:28:26 -04:00
# Inject custom Blueprint css into Pterodactyl's admin panel.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Modifying admin panel css."
sed -i "s!@import url(/assets/extensions/blueprint/blueprint.style.css);!!g" $FOLDER /public/themes/pterodactyl/css/pterodactyl.css
sed -i "s!/\* admin.css \*/!!g" $FOLDER /public/themes/pterodactyl/css/pterodactyl.css
sed -i '1i@import url(/assets/extensions/blueprint/blueprint.style.css);\n/* admin.css */' $FOLDER /public/themes/pterodactyl/css/pterodactyl.css
2023-03-06 13:11:53 -05:00
2023-06-26 06:40:33 -04:00
# Clear view cache.
2023-09-24 09:58:26 -04:00
log_bright "[INFO] Clearing view cache.."
2023-08-15 06:23:40 -04:00
php artisan view:clear
php artisan config:clear
2023-03-06 13:11:53 -05:00
2023-09-24 09:58:26 -04:00
# Link filesystems.
log_bright "[INFO] Linking filesystems.."
2023-10-01 09:40:32 -04:00
php artisan storage:link & > /dev/null
2023-09-24 09:58:26 -04:00
2023-08-11 15:50:34 -04:00
# Roll admin css refresh number.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Rolling admin cache refresh class name."
updateCacheReminder
2023-08-11 15:50:34 -04:00
2023-06-17 07:28:26 -04:00
# Run migrations if Blueprint is not upgrading.
2023-06-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
2023-08-17 05:44:09 -04:00
log_blue "[INPUT] Do you want to migrate your database? (Y/n)"
2023-10-10 15:28:42 -04:00
read -r YN
2023-09-24 09:58:26 -04:00
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] ; then
2023-08-17 05:44:09 -04:00
log_bright "[INFO] Running database migrations.."
php artisan migrate --force
else
log_bright "[INFO] Database migrations have been skipped."
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.
2023-09-24 09:58:26 -04:00
log_bright "[INFO] Changing file ownership to www-data.."
2023-10-25 14:37:38 -04:00
chown -R www-data:www-data $FOLDER /* &
chown -R www-data:www-data $FOLDER /.blueprint/* &
wait
2023-03-06 13:11:53 -05:00
2023-07-29 06:29:18 -04:00
# Rebuild panel assets.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Rebuilding panel assets.."
yarn run build:production
2023-07-29 06:29:18 -04:00
2023-09-12 13:55:48 -04:00
# Clear route cache.
2023-09-13 08:55:15 -04:00
log_bright "[INFO] Updating route cache to include recent changes.."
2023-09-24 09:58:26 -04:00
php artisan route:cache & > /dev/null
2023-09-12 13:55:48 -04:00
2023-11-01 09:51:42 -04:00
# Sync some database values.
log_bright "[INFO] Syncing database values.."
2023-11-01 10:24:00 -04:00
php artisan bp:sync
2023-11-01 09:51:42 -04:00
2023-06-17 07:28:26 -04:00
# Put application into production.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Disable maintenance."
php artisan up
2023-03-19 15:20:01 -04:00
2023-06-26 08:42:31 -04:00
# Only show donate + success message if Blueprint is not upgrading.
2023-06-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Blueprint is completely open source and free. Please consider supporting us on \"ptero.shop/donate\"."
sleep 2
log_green "\n\n[SUCCESS] Blueprint should now be installed. If something didn't work as expected, please let us know at ptero.shop/issue."
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.
2023-09-07 10:17:04 -04:00
sed -i "s!NOTINSTALLED!INSTALLED!g" $FOLDER /app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php
2023-08-15 06:23:40 -04:00
exit 1
fi
fi
2023-03-19 15:20:01 -04:00
2023-08-06 07:41:56 -04:00
2023-06-18 10:37:46 -04:00
# -i, -install
2023-08-15 06:23:40 -04:00
if [ [ ( $2 = = "-i" ) || ( $2 = = "-install" ) ] ] ; then VCMD = "y"
2023-10-11 10:52:01 -04:00
if [ [ $( expr $# - 2) != 1 ] ] ; then quit_red " [FATAL] Expected 1 argument but got $( expr $# - 2) . " ; fi
2023-08-15 06:23:40 -04:00
if [ [ ( $3 = = "./" * ) || ( $3 = = "../" * ) || ( $3 = = "/" * ) ] ] ; then quit_red " [FATAL] Installing extensions located in paths outside of ' $FOLDER ' is not possible. " ; fi
2023-08-10 05:40:26 -04:00
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Checking dependencies.."
2023-07-30 06:13:53 -04:00
# Check if required programs are installed
2023-08-15 06:23:40 -04:00
depend
2023-07-30 06:13:53 -04:00
2023-09-05 12:46:43 -04:00
# The following code does some magic to allow for extensions with a
# different root folder structure than expected by Blueprint.
2023-06-02 10:37:38 -04:00
if [ [ $3 = = "test␀" ] ] ; then
2023-08-15 06:23:40 -04:00
dev = true
n = "dev"
2023-10-31 05:38:52 -04:00
mkdir -p ".blueprint/tmp/dev"
cp -R ".blueprint/dev/" * ".blueprint/tmp/dev/"
2023-06-02 10:37:38 -04:00
else
2023-08-15 06:23:40 -04:00
dev = false
2023-10-31 05:38:52 -04:00
n = " $3 "
FILE = " ${ n } .blueprint "
2023-10-21 14:05:48 -04:00
if [ [ ( $FILE = = *".blueprint.blueprint" ) && ( $n = = *".blueprint" ) ] ] ; then quit_red "[FATAL] Argument one in '-install' must not end with '.blueprint'." ; fi
2023-08-15 06:23:40 -04:00
if [ [ ! -f " $FILE " ] ] ; then quit_red " [FATAL] $FILE could not be found. " ; fi
2023-10-31 05:38:52 -04:00
ZIP = " ${ n } .zip "
cp " $FILE " " .blueprint/tmp/ $ZIP "
cd ".blueprint/tmp"
unzip -o -qq " $ZIP "
rm " $ZIP "
2023-06-02 10:37:38 -04:00
if [ [ ! -f " $n /* " ] ] ; then
2023-10-31 05:38:52 -04:00
cd ".."
rm -R "tmp"
mkdir -p "tmp"
cd "tmp"
mkdir -p " ./ $n "
cp " ../../ $FILE " " ./ $n / $ZIP "
cd " $n "
unzip -o -qq " $ZIP "
rm " $ZIP "
cd ".."
2023-08-15 06:23:40 -04:00
fi
fi
2023-04-17 10:54:12 -04:00
2023-06-18 10:37:46 -04:00
# Return to the Pterodactyl installation folder.
2023-08-15 06:23:40 -04:00
cd $FOLDER
2023-03-22 05:20:59 -04:00
2023-06-17 07:28:26 -04:00
# Get all strings from the conf.yml file and make them accessible as variables.
2023-10-21 14:05:48 -04:00
if [ [ ! -f " .blueprint/tmp/ $n /conf.yml " ] ] ; then
# Quit if the extension doesn't have a conf.yml file.
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2023-10-21 14:05:48 -04:00
quit_red "[FATAL] Could not find a conf.yml file."
fi
2023-07-02 14:58:59 -04:00
eval $( parse_yaml .blueprint/tmp/$n /conf.yml conf_)
2023-06-17 07:28:26 -04:00
2023-07-09 01:47:40 -04:00
# Add aliases for config values to make working with them easier.
2023-08-15 06:23:40 -04:00
name = " $conf_info_name "
identifier = " $conf_info_identifier "
description = " $conf_info_description "
2023-10-01 08:25:10 -04:00
flags = " $conf_info_flags " #(optional)
2023-08-15 06:23:40 -04:00
version = " $conf_info_version "
target = " $conf_info_target "
2023-10-01 08:25:10 -04:00
author = " $conf_info_author " #(optional)
2023-08-31 11:19:50 -04:00
icon = " $conf_info_icon " #(optional)
2023-07-30 16:22:08 -04:00
website = " $conf_info_website " ; #(optional)
2023-08-15 06:23:40 -04:00
admin_view = " $conf_admin_view "
2023-07-30 16:22:08 -04:00
admin_controller = " $conf_admin_controller " ; #(optional)
admin_css = " $conf_admin_css " ; #(optional)
admin_wrapper = " $conf_admin_wrapper " ; #(optional)
dashboard_wrapper = " $conf_dashboard_wrapper " ; #(optional)
dashboard_css = " $conf_dashboard_css " ; #(optional)
data_directory = " $conf_data_directory " ; #(optional)
data_public = " $conf_data_public " ; #(optional)
2023-07-02 14:58:59 -04:00
2023-08-20 04:46:52 -04:00
database_migrations = " $conf_database_migrations " ; #(optional)
2023-07-02 14:58:59 -04:00
2023-09-06 11:54:23 -04:00
# "prevent" folder "escaping"
if [ [ ( $icon = = "/" * ) || ( $icon = = "." * ) || ( $icon = = *"\n" * ) ] ] ||
[ [ ( $admin_view = = "/" * ) || ( $admin_view = = "." * ) || ( $admin_view = = *"\n" * ) ] ] ||
[ [ ( $admin_controller = = "/" * ) || ( $admin_controller = = "." * ) || ( $admin_controller = = *"\n" * ) ] ] ||
2023-09-24 10:45:02 -04:00
[ [ ( $admin_css = = "/" * ) || ( $admin_css = = "." * ) || ( $admin_css = = *"\n" * ) ] ] ||
2023-09-06 11:54:23 -04:00
[ [ ( $data_directory = = "/" * ) || ( $data_directory = = "." * ) || ( $data_directory = = *"\n" * ) ] ] ||
[ [ ( $data_public = = "/" * ) || ( $data_public = = "." * ) || ( $data_public = = *"\n" * ) ] ] ||
2023-07-14 04:34:09 -04:00
[ [ ( $database_migrations = = "/" * ) || ( $database_migrations = = "." * ) || ( $database_migrations = = *"\n" * ) ] ] ; then
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2023-09-06 11:54:23 -04:00
quit_red "[FATAL] File paths in conf.yml should not start with a slash, dot or have a linebreak."
fi
# prevent potentional problems during installation due to wrongly defined folders
if [ [ ( $data_directory = = *"/" ) || ( $data_public = = *"/" ) || ( $database_migrations = = *"/" ) ] ] ; then
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2023-09-06 11:54:23 -04:00
quit_red "[FATAL] Folder paths in conf.yml should not end with a slash."
fi
# check if extension still has placeholder values
if [ [ ( $name = = "␀name␀" ) || ( $identifier = = "␀identifier␀" ) || ( $description = = "␀description␀" ) ] ] ||
[ [ ( $version = = "␀ver␀" ) || ( $target = = "␀version␀" ) || ( $author = = "␀author␀" ) ] ] ; then
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2023-09-06 11:54:23 -04:00
quit_red "[FATAL] Some conf.yml options should be replaced automatically by Blueprint when using \"-init\", but that did not happen. Please verify you have the correct information in your conf.yml and then try again."
2023-08-15 06:23:40 -04:00
fi
2023-06-19 15:04:06 -04:00
2023-07-22 07:13:00 -04:00
# Detect if extension is already installed and prepare the upgrading process.
2023-07-20 09:36:58 -04:00
if [ [ $( cat .blueprint/data/internal/db/installed_extensions) = = *" $identifier , " * ] ] ; then
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Extension appears to be installed already, reading variables.."
2023-11-08 05:49:40 -05:00
eval $( parse_yaml .blueprint/data/extensions/private/$identifier /.store/conf.yml old_)
2023-08-15 06:23:40 -04:00
DUPLICATE = "y"
2023-07-22 06:40:00 -04:00
2023-11-08 05:49:40 -05:00
if [ [ ! -f " .blueprint/data/extensions/private/ $identifier /.store/build/button.blade.php " ] ] ; then
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2023-08-15 06:23:40 -04:00
quit_red "[FATAL] Upgrading extension has failed due to missing essential .store files."
fi
2023-07-22 07:13:00 -04:00
2023-10-01 08:25:10 -04:00
# Clean up some old extension files.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Cleaning up old extension files.."
2023-07-22 07:13:00 -04:00
if [ [ $old_data_public != "" ] ] ; then
2023-10-01 08:25:10 -04:00
# Clean up old public folder.
2023-11-08 05:49:40 -05:00
rm -R " .blueprint/data/extensions/public/ $identifier "
mkdir " .blueprint/data/extensions/public/ $identifier "
2023-08-15 06:23:40 -04:00
fi
fi
2023-07-20 09:36:58 -04:00
2023-10-31 05:29:21 -04:00
# Force http/https url scheme for extension website urls.
if [ [ $website != "" ] ] ; then
if [ [ ( $website != "https://" * ) && ( $website != "http://" * ) ] ] ; then
website = " http:// $conf_info_website "
conf_info_website = $website
fi
2023-11-08 05:22:47 -05:00
# Change link icon depending on website url.
websiteiconclass = "bx-link-external"
if [ [ $website = = *"://github.com/" * ] ] || [ [ $website = = *"://www.github.com/" * ] ] ||
[ [ $website = = *"://github.com" ] ] || [ [ $website = = *"://www.github.com" ] ] ; then websiteiconclass = "bx-git-branch" ; fi
if [ [ $website = = *"://discord.com/" * ] ] || [ [ $website = = *"://www.discord.com/" * ] ] ||
[ [ $website = = *"://discord.com" ] ] || [ [ $website = = *"://www.discord.com" ] ] ||
[ [ $website = = *"://discord.gg/" * ] ] || [ [ $website = = *"://www.discord.gg/" * ] ] ||
[ [ $website = = *"://discord.gg" ] ] || [ [ $website = = *"://www.discord.gg" ] ] ; then websiteiconclass = "bx-discord-alt" ; fi
2023-10-31 05:29:21 -04:00
fi
2023-05-17 03:55:16 -04:00
2023-07-03 06:48:40 -04:00
if [ [ $dev = = true ] ] ; then
2023-10-31 05:38:52 -04:00
mv " .blueprint/tmp/ $n " " .blueprint/tmp/ $identifier "
2023-08-15 06:23:40 -04:00
n = $identifier
fi
2023-03-26 12:19:10 -04:00
2023-06-27 14:36:03 -04:00
if [ [ ( $flags != *"ignorePlaceholders," * ) && ( $flags != *"ignorePlaceholders" ) ] ] ; then
2023-10-20 09:09:48 -04:00
# Prepare variables for placeholders
2023-10-25 15:17:28 -04:00
DIR = " .blueprint/tmp/ $n "
INSTALLMODE = "normal"
2023-10-25 15:34:05 -04:00
CORES = $( nproc --all)
2023-10-20 13:42:03 -04:00
if [ [ $dev = = true ] ] ; then
INSTALLMODE = "developer"
fi
2023-03-26 09:19:39 -04:00
2023-06-27 14:36:03 -04:00
if [ [ ( $flags = = *"ignoreAlphabetPlaceholders," * ) || ( $flags = = *"ignoreAlphabetPlaceholders" ) ] ] ; then
2023-08-15 06:23:40 -04:00
SKIPAZPLACEHOLDERS = true
log_bright "[INFO] Alphabet placeholders will be skipped due to the 'ignoreAlphabetPlaceholders' flag."
2023-06-02 10:37:38 -04:00
else
2023-08-15 06:23:40 -04:00
SKIPAZPLACEHOLDERS = false
fi
2023-05-21 09:10:43 -04:00
2023-11-01 10:32:11 -04:00
log_bright log_bold "[INFO] Applying placeholders.."
2023-10-25 15:17:28 -04:00
PLACE_PLACEHOLDERS( ) {
local dir = " $1 "
for file in " $dir " /*; do
if [ -f " $file " ] ; then
file = $( echo " $file " | sed "s~ ~\ ~g" )
2023-10-25 15:34:05 -04:00
sed -i " s~\^#version#\^~ $version ~g " " $file "
sed -i " s~\^#author#\^~ $author ~g " " $file "
sed -i " s~\^#name#\^~ $name ~g " " $file "
sed -i " s~\^#identifier#\^~ $identifier ~g " " $file "
sed -i " s~\^#path#\^~ $FOLDER ~g " " $file "
2023-11-08 05:49:40 -05:00
sed -i " s~\^#datapath#\^~ $FOLDER /.blueprint/data/extensions/private/ $identifier ~g " " $file "
2023-10-25 15:34:05 -04:00
sed -i " s~\^#installmode#\^~ $INSTALLMODE ~g " " $file "
sed -i " s~\^#blueprintversion#\^~ $VERSION ~g " " $file "
2023-10-25 15:17:28 -04:00
if [ [ $SKIPAZPLACEHOLDERS != true ] ] ; then
2023-10-25 15:34:05 -04:00
sed -i " s~__version__~ $version ~g " " $file "
sed -i " s~__author__~ $author ~g " " $file "
sed -i " s~__identifier__~ $identifier ~g " " $file "
sed -i " s~__name__~ $name ~g " " $file "
sed -i " s~__path__~ $FOLDER ~g " " $file "
2023-11-08 05:49:40 -05:00
sed -i " s~__datapath__~ $FOLDER /.blueprint/data/extensions/private/ $identifier ~g " " $file "
2023-10-25 15:34:05 -04:00
sed -i " s~__installmode__~ $INSTALLMODE ~g " " $file "
sed -i " s~__blueprintversion__~ $VERSION ~g " " $file "
2023-10-25 15:17:28 -04:00
fi
2023-11-01 10:32:11 -04:00
log_bright " - ${ file } "
2023-10-25 15:17:28 -04:00
elif [ -d " $file " ] ; then
PLACE_PLACEHOLDERS " $file "
fi
done
}
PLACE_PLACEHOLDERS " $DIR "
2023-08-15 06:23:40 -04:00
else log_bright "[INFO] Placeholders will be skipped due to the 'ignorePlaceholders' flag." ; fi
2023-10-26 07:09:31 -04:00
if [ [ $name = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] 'info_name' is a required configuration option." ; fi
if [ [ $identifier = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] 'info_identifier' is a required configuration option." ; fi
if [ [ $description = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] 'info_description' is a required configuration option." ; fi
if [ [ $version = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] 'info_version' is a required configuration option." ; fi
if [ [ $target = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] 'info_target' is a required configuration option." ; fi
2023-08-15 06:23:40 -04:00
2023-10-26 07:09:31 -04:00
if [ [ $icon = = "" ] ] ; then log_yellow "[WARNING] This extension does not come with an icon, consider adding one." ; fi
if [ [ $admin_controller = = "" ] ] ; then log_bright "[INFO] Admin controller field left blank, using default controller instead.."
2023-08-15 06:23:40 -04:00
controller_type = "default" ; else controller_type = "custom" ; fi
2023-10-26 07:09:31 -04:00
if [ [ $admin_view = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] 'admin_view' is a required configuration option." ; fi
if [ [ $target != $VERSION ] ] ; then log_yellow " [WARNING] This extension is built for version $target , but your version is $VERSION . " ; fi
if [ [ $identifier != $n ] ] ; then rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] The extension file name must be the same as your identifier. (example: identifier.blueprint)" ; fi
if [ [ $identifier = = "blueprint" ] ] ; then rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] Extensions can not have the identifier 'blueprint'." ; fi
2023-08-15 06:23:40 -04:00
2023-10-26 07:09:31 -04:00
if [ [ $identifier = ~ [ a-z] ] ] ; then log_bright "[INFO] Identifier a-z checks passed."
2023-10-26 07:14:28 -04:00
else rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] The extension identifier should be lowercase and only contain characters a-z." ; fi
2023-10-01 08:39:28 -04:00
if [ [ ( ! -f " .blueprint/tmp/ $n / $icon " ) && ( $icon != "" ) ] ] ; then
2023-10-26 07:14:28 -04:00
rm -R " .blueprint/tmp/ $n " ; quit_red "[FATAL] The 'info_icon' path points to a file that does not exist."
2023-10-01 08:39:28 -04:00
fi
2023-04-01 06:58:23 -04:00
2023-06-11 14:58:20 -04:00
if [ [ $database_migrations != "" ] ] ; then
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Placing database migrations.."
2023-10-31 05:38:52 -04:00
cp -R " .blueprint/tmp/ $n / $database_migrations / " * "database/migrations/" 2> /dev/null
2023-08-15 06:23:40 -04:00
fi
2023-03-26 09:27:37 -04:00
2023-06-11 14:58:20 -04:00
if [ [ $data_public != "" ] ] ; then
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Creating public directory.."
2023-11-08 05:49:40 -05:00
mkdir -p " .blueprint/data/extensions/public/ $identifier "
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Placing public directory contents.."
2023-11-08 05:49:40 -05:00
cp -R " .blueprint/tmp/ $n / $data_public / " * " .blueprint/data/extensions/public/ $identifier / " 2> /dev/null
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2023-10-26 07:09:31 -04:00
cp ".blueprint/data/internal/build/extensions/admin.blade.php" ".blueprint/data/internal/build/extensions/admin.blade.php.bak" 2> /dev/null
2023-06-11 14:58:20 -04:00
if [ [ $admin_controller = = "" ] ] ; then # use default controller when admin_controller is left blank
2023-10-26 07:09:31 -04:00
cp ".blueprint/data/internal/build/extensions/controller.php" ".blueprint/data/internal/build/extensions/controller.php.bak" 2> /dev/null
2023-08-15 06:23:40 -04:00
fi
2023-10-26 07:09:31 -04:00
cp ".blueprint/data/internal/build/extensions/route.php" ".blueprint/data/internal/build/extensions/route.php.bak" 2> /dev/null
cp ".blueprint/data/internal/build/extensions/button.blade.php" ".blueprint/data/internal/build/extensions/button.blade.php.bak" 2> /dev/null
2023-06-02 10:37:38 -04:00
2023-07-12 08:18:43 -04:00
# Start creating data directory.
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Creating data directory.."
2023-11-08 05:49:40 -05:00
mkdir -p " .blueprint/data/extensions/private/ $identifier "
mkdir -p " .blueprint/data/extensions/private/ $identifier /.store "
2023-07-12 08:18:43 -04:00
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Caching extension config inside of data directory.."
2023-11-08 05:49:40 -05:00
cp " .blueprint/tmp/ $n /conf.yml " " .blueprint/data/extensions/private/ $identifier /.store/conf.yml " ; #backup conf.yml
2023-07-12 08:18:43 -04:00
2023-06-11 14:58:20 -04:00
if [ [ $data_directory != "" ] ] ; then
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Placing private directory contents.."
2023-11-08 05:49:40 -05:00
cp -R " .blueprint/tmp/ $n / $data_directory / " * " .blueprint/data/extensions/private/ $identifier / "
2023-08-15 06:23:40 -04:00
fi
2023-07-12 08:18:43 -04:00
# End creating data directory.
2023-06-02 10:37:38 -04:00
2023-10-25 16:28:52 -04:00
mkdir -p " public/assets/extensions/ $identifier "
2023-08-31 11:19:50 -04:00
if [ [ $icon = = "" ] ] ; then
# use random placeholder icon if extension does not
# come with an icon.
2023-10-01 09:13:54 -04:00
icnNUM = $( expr 1 + $RANDOM % 9)
2023-10-25 16:28:52 -04:00
cp " .blueprint/assets/defaultExtensionLogo $icnNUM .jpg " " public/assets/extensions/ $identifier /icon.jpg "
2023-08-31 11:19:50 -04:00
else
2023-10-25 16:28:52 -04:00
cp " .blueprint/tmp/ $n / $icon " " public/assets/extensions/ $identifier /icon.jpg "
2023-08-31 11:19:50 -04:00
fi ;
2023-08-15 06:23:40 -04:00
ICON = " /assets/extensions/ $identifier /icon.jpg "
CONTENT = $( cat .blueprint/tmp/$n /$admin_view )
2023-06-02 10:37:38 -04:00
2023-07-21 10:00:56 -04:00
if [ [ $admin_css != "" ] ] ; then
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Placing admin css.."
2023-08-15 06:23:40 -04:00
updateCacheReminder
2023-10-25 16:28:52 -04:00
sed -i " s~@import url(/assets/extensions/ $identifier /admin.style.css);~~g " "public/themes/pterodactyl/css/pterodactyl.css"
sed -i " s~/\* admin.css \*/~/\* admin.css \*/\n@import url(/assets/extensions/ $identifier /admin.style.css);~g " "public/themes/pterodactyl/css/pterodactyl.css"
cp " .blueprint/tmp/ $n / $admin_css " " public/assets/extensions/ $identifier /admin.style.css "
2023-08-15 06:23:40 -04:00
fi
2023-07-28 08:04:46 -04:00
if [ [ $dashboard_css != "" ] ] ; then
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Placing dashboard css.."
2023-08-15 06:23:40 -04:00
YARN = "y"
2023-10-25 16:28:52 -04:00
sed -i " s~@import url( $identifier .css);~~g " "resources/scripts/css/extensions.css"
sed -i " s~/\* client.css \*/~/\* client.css \*/\n@import url( $identifier .css);~g " "resources/scripts/css/extensions.css"
cp " .blueprint/tmp/ $n / $dashboard_css " " resources/scripts/css/ $identifier .css "
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
if [ [ $name = = *"~" * ] ] ; then log_yellow "[WARNING] 'name' contains '~' and may result in an error." ; fi
2023-08-15 06:23:40 -04:00
if [ [ $description = = *"~" * ] ] ; then log_yellow "[WARNING] 'description' contains '~' and may result in an error." ; fi
2023-10-01 08:25:10 -04:00
if [ [ $version = = *"~" * ] ] ; then log_yellow "[WARNING] 'version' contains '~' and may result in an error." ; fi
if [ [ $CONTENT = = *"~" * ] ] ; then log_yellow "[WARNING] 'CONTENT' contains '~' and may result in an error." ; fi
if [ [ $ICON = = *"~" * ] ] ; then log_yellow "[WARNING] 'ICON' contains '~' and may result in an error." ; fi
if [ [ $identifier = = *"~" * ] ] ; then log_yellow "[WARNING] 'identifier' contains '~' and may result in an error." ; fi
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Replace $name variables.
2023-10-25 16:28:52 -04:00
sed -i " s~␀title␀~ $name ~g " ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
sed -i " s~␀name␀~ $name ~g " ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
sed -i " s~␀name␀~ $name ~g " ".blueprint/data/internal/build/extensions/button.blade.php.bak"
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Replace $description variables.
2023-10-25 16:28:52 -04:00
sed -i " s~␀description␀~ $description ~g " ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Replace $version variables.
2023-10-25 16:28:52 -04:00
sed -i " s~␀version␀~ $version ~g " ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
sed -i " s~␀version␀~ $version ~g " ".blueprint/data/internal/build/extensions/button.blade.php.bak"
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Replace $ICON variables.
2023-10-25 16:28:52 -04:00
sed -i " s~␀icon␀~ $ICON ~g " ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Replace $website variables.
2023-06-19 15:04:06 -04:00
if [ [ $website != "" ] ] ; then
2023-10-25 16:28:52 -04:00
sed -i " s~␀website␀~ $website ~g " ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
sed -i "s~<!--websitecomment␀ ~~g" ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
sed -i "s~ ␀websitecomment-->~~g" ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
2023-11-08 05:22:47 -05:00
sed -i " s~␀weblinkicon␀~ $websiteiconclass ~g " ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
2023-08-15 06:23:40 -04:00
fi
2023-06-19 15:04:06 -04:00
2023-10-01 08:25:10 -04:00
# Replace $identifier variables.
2023-06-11 14:58:20 -04:00
if [ [ $admin_controller = = "" ] ] ; then
2023-10-25 16:28:52 -04:00
sed -i " s~␀id␀~ $identifier ~g " ".blueprint/data/internal/build/extensions/controller.php.bak"
2023-08-15 06:23:40 -04:00
fi
2023-10-25 16:28:52 -04:00
sed -i " s~␀id␀~ $identifier ~g " ".blueprint/data/internal/build/extensions/route.php.bak"
sed -i " s~␀id␀~ $identifier ~g " ".blueprint/data/internal/build/extensions/button.blade.php.bak"
2023-08-15 06:23:40 -04:00
2023-10-01 08:25:10 -04:00
# Place extension admin view content into template.
2023-10-25 16:28:52 -04:00
echo -e " $CONTENT \n@endsection " >> ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
2023-10-01 08:25:10 -04:00
# Read final results.
ADMINVIEW_RESULT = $( <.blueprint/data/internal/build/extensions/admin.blade.php.bak)
ADMINROUTE_RESULT = $( <.blueprint/data/internal/build/extensions/route.php.bak)
ADMINBUTTON_RESULT = $( <.blueprint/data/internal/build/extensions/button.blade.php.bak)
2023-06-11 14:58:20 -04:00
if [ [ $admin_controller = = "" ] ] ; then
2023-10-01 08:25:10 -04:00
ADMINCONTROLLER_RESULT = $( <.blueprint/data/internal/build/extensions/controller.php.bak)
2023-08-15 06:23:40 -04:00
fi
2023-10-25 16:28:52 -04:00
ADMINCONTROLLER_NAME = " ${ identifier } ExtensionController.php "
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Place admin extension view.
2023-10-25 16:28:52 -04:00
mkdir -p " resources/views/admin/extensions/ $identifier "
touch " resources/views/admin/extensions/ $identifier /index.blade.php "
echo $ADMINVIEW_RESULT > " resources/views/admin/extensions/ $identifier /index.blade.php "
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Place admin extension view controller.
2023-10-25 16:28:52 -04:00
mkdir -p " app/Http/Controllers/Admin/Extensions/ $identifier "
touch " app/Http/Controllers/Admin/Extensions/ $identifier / $ADMINCONTROLLER_NAME "
2023-06-11 14:58:20 -04:00
if [ [ $admin_controller = = "" ] ] ; then
2023-10-01 08:25:10 -04:00
# Use custom view controller.
2023-10-25 16:28:52 -04:00
touch " app/Http/Controllers/Admin/Extensions/ $identifier / $ADMINCONTROLLER_NAME "
echo $ADMINCONTROLLER_RESULT > " app/Http/Controllers/Admin/Extensions/ $identifier / $ADMINCONTROLLER_NAME "
2023-06-02 10:37:38 -04:00
else
2023-10-01 08:25:10 -04:00
# Use default extension controller.
2023-10-25 16:28:52 -04:00
cp .blueprint/tmp/$n /$admin_controller " app/Http/Controllers/Admin/Extensions/ $identifier / $ADMINCONTROLLER_NAME "
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2023-07-20 09:36:58 -04:00
if [ [ $DUPLICATE != "y" ] ] ; then
2023-10-01 08:25:10 -04:00
# Place admin route if extension is not updating.
2023-10-10 15:40:54 -04:00
{ echo "
// $identifier :start" ;
echo $ADMINROUTE_RESULT ;
2023-10-26 07:01:33 -04:00
echo // $identifier :stop; } >> "routes/admin.php"
2023-10-01 08:25:10 -04:00
else
# Replace old extensions page button if extension is updating.
2023-11-08 05:49:40 -05:00
OLDBUTTON_RESULT = $( <.blueprint/data/extensions/private/$identifier /.store/build/button.blade.php)
2023-10-26 07:01:33 -04:00
sed -i " s~ $OLDBUTTON_RESULT ~~g " "resources/views/admin/extensions.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-10-26 07:01:33 -04:00
sed -i " s~<!--␀replace␀-->~ $ADMINBUTTON_RESULT \n<!--␀replace␀-->~g " "resources/views/admin/extensions.blade.php"
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Place dashboard wrapper
2023-07-13 15:27:05 -04:00
if [ [ $dashboard_wrapper != "" ] ] ; then
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Placing dashboard wrapper.."
2023-07-22 07:13:00 -04:00
if [ [ $DUPLICATE = = "y" ] ] ; then
2023-10-26 07:01:33 -04:00
sed -n -i " /<!--␀ $identifier :start␀-->/{p; :a; N; /<!--␀ $identifier :stop␀-->/!ba; s/.*\n//}; p " "resources/views/templates/wrapper.blade.php"
sed -i " s~<!--␀ $identifier :start␀-->~~g " "resources/views/templates/wrapper.blade.php"
sed -i " s~<!--␀ $identifier :stop␀-->~~g " "resources/views/templates/wrapper.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-10-26 07:01:33 -04:00
touch " .blueprint/tmp/ $n / $dashboard_wrapper .BLUEPRINTBAK "
cat <( echo " <!--␀ $identifier :start␀--> " ) " .blueprint/tmp/ $n / $dashboard_wrapper " > " .blueprint/tmp/ $n / $dashboard_wrapper .BLUEPRINTBAK "
cp " .blueprint/tmp/ $n / $dashboard_wrapper .BLUEPRINTBAK " " .blueprint/tmp/ $n / $dashboard_wrapper "
rm " .blueprint/tmp/ $n / $dashboard_wrapper .BLUEPRINTBAK "
echo -e " \n<!--␀ $identifier :stop␀--> " >> " .blueprint/tmp/ $n / $dashboard_wrapper "
sed -i " /<\!-- wrapper:insert -->/r .blueprint/tmp/ $n / $dashboard_wrapper " "resources/views/templates/wrapper.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-07-13 04:41:44 -04:00
2023-10-01 08:25:10 -04:00
# Place admin wrapper
2023-07-21 11:32:22 -04:00
if [ [ $admin_wrapper != "" ] ] ; then
2023-10-24 09:13:09 -04:00
log_bright "[INFO] Placing admin wrapper.."
2023-07-22 07:13:00 -04:00
if [ [ $DUPLICATE = = "y" ] ] ; then
2023-10-26 07:01:33 -04:00
sed -n -i " /<!--␀ $identifier :start␀-->/{p; :a; N; /<!--␀ $identifier :stop␀-->/!ba; s/.*\n//}; p " "resources/views/layouts/admin.blade.php"
sed -i " s~<!--␀ $identifier :start␀-->~~g " "resources/views/layouts/admin.blade.php"
sed -i " s~<!--␀ $identifier :stop␀-->~~g " "resources/views/layouts/admin.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-10-26 07:01:33 -04:00
touch " .blueprint/tmp/ $n / $admin_wrapper .BLUEPRINTBAK "
cat <( echo " <!--␀ $identifier :start␀--> " ) " .blueprint/tmp/ $n / $admin_wrapper " > " .blueprint/tmp/ $n / $admin_wrapper .BLUEPRINTBAK "
cp " .blueprint/tmp/ $n / $admin_wrapper .BLUEPRINTBAK " " .blueprint/tmp/ $n / $admin_wrapper "
rm " .blueprint/tmp/ $n / $admin_wrapper .BLUEPRINTBAK "
echo -e " \n<!--␀ $identifier :stop␀--> " >> " .blueprint/tmp/ $n / $admin_wrapper "
sed -i " /<\!-- wrapper:insert -->/r .blueprint/tmp/ $n / $admin_wrapper " "resources/views/layouts/admin.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-07-20 11:26:09 -04:00
2023-07-22 06:40:00 -04:00
# Create backup of generated values.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Backing up (some) build files.."
2023-11-08 05:49:40 -05:00
mkdir -p " .blueprint/data/extensions/private/ $identifier /.store/build "
cp ".blueprint/data/internal/build/extensions/button.blade.php.bak" " .blueprint/data/extensions/private/ $identifier /.store/build/button.blade.php "
cp ".blueprint/data/internal/build/extensions/route.php.bak" " .blueprint/data/extensions/private/ $identifier /.store/build/route.php "
2023-07-22 06:40:00 -04:00
2023-10-01 08:25:10 -04:00
# Remove temporary built files.
log_bright "[INFO] Cleaning up temporary built files.."
2023-10-26 07:01:33 -04:00
rm ".blueprint/data/internal/build/extensions/admin.blade.php.bak"
2023-06-11 14:58:20 -04:00
if [ [ $admin_controller = = "" ] ] ; then
2023-10-26 07:01:33 -04:00
rm ".blueprint/data/internal/build/extensions/controller.php.bak"
2023-08-15 06:23:40 -04:00
fi
2023-10-26 07:01:33 -04:00
rm ".blueprint/data/internal/build/extensions/route.php.bak"
rm ".blueprint/data/internal/build/extensions/button.blade.php.bak"
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Cleaning up temp files.."
2023-10-26 07:01:33 -04:00
rm -R " .blueprint/tmp/ $n "
2023-06-02 10:37:38 -04:00
2023-06-11 14:58:20 -04:00
if [ [ $database_migrations != "" ] ] ; then
2023-08-23 15:42:34 -04:00
log_blue "[INPUT] Do you want to migrate your database? (Y/n)"
2023-10-10 15:28:42 -04:00
read -r YN
2023-09-24 09:58:26 -04:00
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] ; then
2023-08-23 15:42:34 -04:00
log_bright "[INFO] Running database migrations.."
php artisan migrate --force
else
log_bright "[INFO] Database migrations have been skipped."
fi
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2023-09-24 09:58:26 -04:00
if [ [ $YARN = = "y" ] ] ; then
log_bright "[INFO] Rebuilding panel.."
yarn run build:production
fi
log_bright "[INFO] Updating route cache to include recent changes.."
php artisan route:cache & > /dev/null
2023-11-08 05:49:40 -05:00
chown -R www-data:www-data " $FOLDER /.blueprint/data/extensions/private/ $identifier "
chmod --silent -R +x ".blueprint/data/extensions/private/" * 2> /dev/null
2023-06-02 10:37:38 -04:00
2023-10-16 14:20:25 -04:00
if [ [ ( ( $flags != *"developerIgnoreInstallScript," * ) && ( $flags != *"developerIgnoreInstallScript" ) ) || ( $dev != true ) ] ] ; then
if [ [ ( $flags = = *"hasInstallScript," * ) || ( $flags = = *"hasInstallScript" ) ] ] ; then
log_yellow "[WARNING] This extension uses a custom installation script, proceed with caution."
2023-11-08 05:49:40 -05:00
chmod +x " .blueprint/data/extensions/private/ $identifier /install.sh "
2023-10-16 14:20:25 -04:00
# Run script while also parsing some useful variable for the install script to use.
2023-11-08 05:49:40 -05:00
BLUEPRINT_DEVELOPER = " $dev " BLUEPRINT_VERSION = " $VERSION " bash " .blueprint/data/extensions/private/ $identifier /install.sh "
2023-10-16 14:20:25 -04:00
echo -e "\e[0m\x1b[0m\033[0m"
fi
else
log_bright "[INFO] Custom installation scripts will be skipped on developer commands due to the 'developerIgnoreInstallScript' flag."
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2023-07-20 09:36:58 -04:00
if [ [ $DUPLICATE != "y" ] ] ; then
2023-10-26 07:01:33 -04:00
echo " ${ identifier } , " >> ".blueprint/data/internal/db/installed_extensions"
2023-08-15 06:23:40 -04:00
log_bright " [INFO] Added ' $identifier ' to the list of installed extensions. "
fi
2023-07-20 09:36:58 -04:00
2023-07-28 08:04:46 -04:00
if [ [ $dev != true ] ] ; then
2023-09-24 09:58:26 -04:00
if [ [ $DUPLICATE = = "y" ] ] ; then
log_green " \n\n[SUCCESS] $identifier should now be updated. If something didn't work as expected, please let us know at ptero.shop/issue. "
else
log_green " \n\n[SUCCESS] $identifier should now be installed. If something didn't work as expected, please let us know at ptero.shop/issue. "
fi
2023-08-15 06:23:40 -04:00
sendTelemetry "FINISH_EXTENSION_INSTALLATION" > /dev/null
fi
fi
2023-03-22 05:20:59 -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"
2023-10-11 10:52:01 -04:00
if [ [ $( expr $# - 2) != 1 ] ] ; then quit_red " [FATAL] Expected 1 argument but got $( expr $# - 2) . " ; fi
2023-07-30 07:28:03 -04:00
# Check if the extension is installed.
2023-10-26 07:05:04 -04:00
if [ [ $( cat ".blueprint/data/internal/db/installed_extensions" ) != *" $identifier , " * ] ] ; then
2023-08-15 06:23:40 -04:00
quit_red " [FATAL] ' $3 ' is not installed. "
fi
2023-07-30 07:28:03 -04:00
2023-11-08 05:49:40 -05:00
if [ [ -f " .blueprint/data/extensions/private/ $3 /.store/conf.yml " ] ] ; then
eval $( parse_yaml " .blueprint/data/extensions/private/ $3 /.store/conf.yml " conf_)
2023-07-30 07:28:03 -04:00
# Add aliases for config values to make working with them easier.
2023-07-30 16:22:08 -04:00
name = " $conf_info_name " ;
2023-08-15 06:23:40 -04:00
identifier = " $conf_info_identifier "
description = " $conf_info_description "
2023-10-01 08:25:10 -04:00
flags = " $conf_info_flags " #(optional)
2023-08-15 06:23:40 -04:00
version = " $conf_info_version "
target = " $conf_info_target "
2023-10-01 08:25:10 -04:00
author = " $conf_info_author " #(optional)
icon = " $conf_info_icon " #(optional)
2023-07-30 16:22:08 -04:00
website = " $conf_info_website " ; #(optional)
2023-08-15 06:23:40 -04:00
admin_view = " $conf_admin_view "
2023-07-30 16:22:08 -04:00
admin_controller = " $conf_admin_controller " ; #(optional)
admin_css = " $conf_admin_css " ; #(optional)
admin_wrapper = " $conf_admin_wrapper " ; #(optional)
dashboard_wrapper = " $conf_dashboard_wrapper " ; #(optional)
dashboard_css = " $conf_dashboard_css " ; #(optional)
data_directory = " $conf_data_directory " ; #(optional)
data_public = " $conf_data_public " ; #(optional)
database_migrations = " $conf_database_migrations " ; #(optional)
2023-07-30 07:28:03 -04:00
else
2023-08-15 06:23:40 -04:00
quit_red "[FATAL] Backup conf.yml could not be found."
fi
2023-07-30 07:28:03 -04:00
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Checking dependencies.."
depend
2023-07-31 05:14:32 -04:00
2023-08-15 06:23:40 -04:00
log_blue "[INPUT] Are you sure you want to continue? Some extension files might not be removed as Blueprint does not keep track of them. (y/N)"
2023-10-10 15:28:42 -04:00
read -r YN
2023-08-16 12:45:50 -04:00
if [ [ ( $YN = = "n" * ) || ( $YN = = "N" * ) || ( $YN = = "" ) ] ] ; then log_bright "[INFO] Extension removal cancelled." ; exit 1; fi
2023-07-31 05:10:39 -04:00
2023-07-30 12:22:10 -04:00
# Remove admin button
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing admin button.."
2023-11-08 05:49:40 -05:00
OLDBUTTON_RESULT = $( cat " .blueprint/data/extensions/private/ $identifier /.store/build/button.blade.php " )
2023-10-26 07:05:04 -04:00
sed -i " s~ $OLDBUTTON_RESULT ~~g " "resources/views/admin/extensions.blade.php"
2023-07-30 12:22:10 -04:00
2023-10-01 08:25:10 -04:00
# Remove admin routes
2023-10-01 08:29:33 -04:00
log_bright "[INFO] Removing admin routes.."
2023-10-26 07:05:04 -04:00
sed -n -i " /\/\/ $identifier :start/{p; :a; N; /\/\/ $identifier :stop/!ba; s/.*\n//}; p " "routes/admin.php"
sed -i " s~// $identifier :start~~g " "routes/admin.php"
sed -i " s~// $identifier :stop~~g " "routes/admin.php"
2023-09-30 11:33:38 -04:00
2023-07-30 07:28:03 -04:00
# Remove admin view
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing admin view.."
2023-10-26 07:05:04 -04:00
rm -R " resources/views/admin/extensions/ $identifier "
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove admin controller
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing admin controller.."
2023-10-26 07:05:04 -04:00
rm -R " app/Http/Controllers/Admin/Extensions/ $identifier "
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove admin css
2023-07-30 12:22:10 -04:00
if [ [ $admin_css != "" ] ] ; then
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing admin css.."
updateCacheReminder
2023-10-26 07:05:04 -04:00
sed -i " s~@import url(/assets/extensions/ $identifier /admin.style.css);~~g " "public/themes/pterodactyl/css/pterodactyl.css"
sed -i " s~@import url(/assets/extensions/ $identifier / $identifier .style.css);~~g " "public/themes/pterodactyl/css/pterodactyl.css" ; #this removes changes made in older versions of blueprint
2023-08-15 06:23:40 -04:00
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove admin wrapper
2023-07-30 12:22:10 -04:00
if [ [ $admin_wrapper != "" ] ] ; then
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing admin wrapper.."
2023-10-26 07:05:04 -04:00
sed -n -i " /<!--␀ $identifier :start␀-->/{p; :a; N; /<!--␀ $identifier :stop␀-->/!ba; s/.*\n//}; p " "resources/views/layouts/admin.blade.php"
sed -i " s~<!--␀ $identifier :start␀-->~~g " "resources/views/layouts/admin.blade.php"
sed -i " s~<!--␀ $identifier :stop␀-->~~g " "resources/views/layouts/admin.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove dashboard wrapper
2023-07-30 12:22:10 -04:00
if [ [ $dashboard_wrapper != "" ] ] ; then
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing dashboard wrapper.."
2023-10-26 07:05:04 -04:00
sed -n -i " /<!--␀ $identifier :start␀-->/{p; :a; N; /<!--␀ $identifier :stop␀-->/!ba; s/.*\n//}; p " "resources/views/templates/wrapper.blade.php"
sed -i " s~<!--␀ $identifier :start␀-->~~g " "resources/views/templates/wrapper.blade.php"
sed -i " s~<!--␀ $identifier :stop␀-->~~g " "resources/views/templates/wrapper.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove dashboard css
2023-07-30 12:22:10 -04:00
if [ [ $dashboard_css != "" ] ] ; then
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing dashboard css.."
2023-10-26 07:05:04 -04:00
sed -i " s~@import url( $identifier .css);~~g " "resources/scripts/css/extensions.css"
2023-08-15 06:23:40 -04:00
YARN = "y"
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove public folder
2023-07-30 12:22:10 -04:00
if [ [ $data_public != "" ] ] ; then
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing public folder.."
2023-11-08 05:49:40 -05:00
rm -R " .blueprint/data/extensions/public/ $identifier "
2023-08-15 06:23:40 -04:00
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove assets folder
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing assets.."
2023-10-26 07:05:04 -04:00
rm -R " public/assets/extensions/ $identifier "
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove data folder
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Removing data folder.."
2023-11-08 05:49:40 -05:00
rm -R " .blueprint/data/extensions/private/ $identifier "
2023-07-30 12:22:10 -04:00
2023-07-30 15:02:48 -04:00
# Rebuild panel
if [ [ $YARN = = "y" ] ] ; then
log_bright "[INFO] Rebuilding panel assets.."
2023-08-15 06:23:40 -04:00
yarn run build:production
fi
2023-07-30 15:02:48 -04:00
2023-09-13 08:55:15 -04:00
log_bright "[INFO] Updating route cache to include recent changes.."
2023-09-24 09:58:26 -04:00
php artisan route:cache & > /dev/null
# Remove from installed list
log_bright "[INFO] Removing extension from installed extensions list.."
2023-10-26 07:05:04 -04:00
sed -i " s~ $identifier ,~~g " ".blueprint/data/internal/db/installed_extensions"
2023-09-12 13:55:48 -04:00
2023-09-19 13:30:46 -04:00
sendTelemetry "FINISH_EXTENSION_REMOVAL" > /dev/null
2023-08-15 06:23:40 -04:00
log_green " [SUCCESS] ' $identifier ' has been removed from your panel. Please note that some files might be left behind. "
fi
2023-07-30 07:28:03 -04:00
2023-08-06 07:41:56 -04:00
2023-10-24 07:23:09 -04:00
# help, -help, --help,
# h, -h, --h
if [ [ ( $2 = = "help" ) || ( $2 = = "-help" ) || ( $2 = = "--help" ) ||
( $2 = = "h" ) || ( $2 = = "-h" ) || ( $2 = = "--h" ) ] ] ; then VCMD = "y"
2023-08-11 10:11:53 -04:00
2023-11-01 09:51:42 -04:00
if dbValidate "blueprint.developerEnabled" ; then
2023-08-15 06:44:10 -04:00
help_dev_status = ""
2023-08-15 06:58:36 -04:00
help_dev_primary = "\e[34;1m"
help_dev_secondary = "\e[34m"
2023-08-15 06:44:10 -04:00
else
help_dev_status = " (disabled)"
2023-10-30 10:49:29 -04:00
help_dev_primary = "\x1b[2;1m"
help_dev_secondary = "\x1b[2m"
2023-08-16 12:45:50 -04:00
fi
2023-08-15 06:44:10 -04:00
echo -e "
\x 1b[ 34; 1mExtensions\x 1b[ 0m\x 1b[ 34m
-install [ name] -i install/update a blueprint extension
-remove [ name] -r remove a blueprint extension
\x 1b[ 0m
2023-10-24 08:53:17 -04:00
${ help_dev_primary } Developer${ help_dev_status } \x 1b[ 0m${ help_dev_secondary }
2023-09-23 11:14:04 -04:00
-init -I initialize development files
-build -b install/update your development files
2023-10-31 06:28:47 -04:00
-export ( expose) -e export your development files
2023-09-23 11:14:04 -04:00
-wipe -w remove your development files
2023-08-15 06:44:10 -04:00
\x 1b[ 0m
\x 1b[ 34; 1mMisc\x 1b[ 0m\x 1b[ 34m
-version -v returns the blueprint version
2023-11-02 14:14:06 -04:00
-info -f show neofetch-like information about blueprint
2023-08-15 06:44:10 -04:00
\x 1b[ 0m
\x 1b[ 34; 1mAdvanced\x 1b[ 0m\x 1b[ 34m
2023-10-31 06:28:47 -04:00
-upgrade ( dev) update/reset to a newer/development version
2023-08-15 06:44:10 -04:00
-rerun-install rerun the blueprint installation script
\x 1b[ 0m
"
2023-08-15 06:23:40 -04:00
fi
2023-03-27 15:17:57 -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
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-11-01 08:51:33 -04:00
if ! dbValidate "blueprint.developerEnabled" ; then quit_red "[FATAL] Developer mode is not enabled." ; 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
2023-08-15 06:23:40 -04:00
quit_red "[FATAL] Your development directory contains files. To protect you against accidental data loss, you are unable to initialize another extension unless you clear your .blueprint/dev folder."
fi
2023-07-28 16:12:59 -04:00
2023-09-23 09:36:32 -04:00
ask_template( ) {
log_blue "[INPUT] Initial Template:"
2023-10-13 14:13:35 -04:00
log_blue " $( curl 'https://raw.githubusercontent.com/teamblueprint/templates/main/repository' 2> /dev/null) "
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
if [ [ ${ ASKTEMPLATE } = = "" ] ] ; then
log_yellow "[WARNING] Template should not be empty."
2023-09-23 09:36:32 -04:00
REDO_TEMPLATE = true
fi
# Unknown template.
2023-10-24 08:53:17 -04:00
if [ [ $( echo -e " $( curl " https://raw.githubusercontent.com/teamblueprint/templates/main/ ${ ASKTEMPLATE } /TemplateConfiguration.yml " 2> /dev/null) " ) = = "404: Not Found" ] ] ; then
log_yellow "[WARNING] Unknown template, please choose a valid option."
2023-09-23 09:36:32 -04:00
REDO_TEMPLATE = true
fi
2023-10-24 08:53:17 -04:00
if [ [ ${ REDO_TEMPLATE } = = true ] ] ; then
2023-09-23 09:36:32 -04:00
# Ask again if response does not pass validation.
2023-09-23 10:07:49 -04:00
ASKTEMPLATE = ""
2023-09-23 09:36:32 -04:00
ask_template
fi
}
2023-07-03 08:42:01 -04:00
ask_name( ) {
2023-08-15 06:23:40 -04:00
log_blue "[INPUT] Name (Generic Extension):"
2023-10-10 15:28:42 -04:00
read -r ASKNAME
2023-07-03 08:42:01 -04:00
2023-08-15 06:23:40 -04:00
REDO_NAME = false
2023-07-03 08:42:01 -04:00
# Name should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKNAME } = = "" ] ] ; then
log_yellow "[WARNING] Name should not be empty."
2023-08-15 06:23:40 -04:00
REDO_NAME = true
fi
2023-07-03 08:42:01 -04:00
2023-10-24 08:53:17 -04:00
if [ [ ${ REDO_NAME } = = true ] ] ; then
2023-08-31 04:51:44 -04:00
# Ask again if response does not pass validation.
2023-09-23 10:07:49 -04:00
ASKNAME = ""
2023-08-15 06:23:40 -04:00
ask_name
fi
}
2023-07-03 08:42:01 -04:00
ask_identifier( ) {
2023-08-15 06:23:40 -04:00
log_blue "[INPUT] Identifier (genericextension):"
2023-10-10 15:28:42 -04:00
read -r ASKIDENTIFIER
2023-07-03 08:42:01 -04:00
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
log_yellow "[WARNING] Identifier should not be empty."
2023-08-15 06:23:40 -04:00
REDO_IDENTIFIER = true
fi
2023-07-03 08:42:01 -04:00
# Identifier should be a-z.
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKIDENTIFIER } = ~ [ a-z] ] ] ; then
2023-08-15 06:23:40 -04:00
echo ok > /dev/null
2023-07-03 08:46:49 -04:00
else
2023-10-24 08:53:17 -04:00
log_yellow "[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
2023-10-24 08:53:17 -04:00
if [ [ ${ REDO_IDENTIFIER } = = true ] ] ; then
2023-08-31 04:51:44 -04:00
# Ask again if response does not pass validation.
2023-09-23 10:07:49 -04:00
ASKIDENTIFIER = ""
2023-08-15 06:23:40 -04:00
ask_identifier
fi
}
2023-07-03 08:42:01 -04:00
ask_description( ) {
2023-10-01 08:55:17 -04:00
log_blue "[INPUT] Description (My awesome description):"
2023-10-10 15:28:42 -04:00
read -r ASKDESCRIPTION
2023-07-03 08:42:01 -04:00
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
log_yellow "[WARNING] Description should not be empty."
2023-08-15 06:23:40 -04:00
REDO_DESCRIPTION = true
fi
2023-07-03 08:42:01 -04:00
2023-10-24 08:53:17 -04:00
if [ [ ${ REDO_DESCRIPTION } = = true ] ] ; then
2023-08-31 04:51:44 -04:00
# Ask again if response does not pass validation.
2023-09-23 10:07:49 -04:00
ASKDESCRIPTION = ""
2023-08-15 06:23:40 -04:00
ask_description
fi
}
2023-07-03 08:42:01 -04:00
ask_version( ) {
2023-08-15 06:23:40 -04:00
log_blue "[INPUT] Version (indev):"
2023-10-10 15:28:42 -04:00
read -r ASKVERSION
2023-07-03 08:42:01 -04:00
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
log_yellow "[WARNING] Version should not be empty."
2023-08-15 06:23:40 -04:00
REDO_VERSION = true
fi
2023-07-03 08:42:01 -04:00
2023-10-24 08:53:17 -04:00
if [ [ ${ REDO_VERSION } = = true ] ] ; then
2023-08-31 04:51:44 -04:00
# Ask again if response does not pass validation.
2023-09-23 10:07:49 -04:00
ASKVERSION = ""
2023-08-15 06:23:40 -04:00
ask_version
fi
}
2023-07-03 08:42:01 -04:00
ask_author( ) {
2023-08-15 06:23:40 -04:00
log_blue "[INPUT] Author (prplwtf):"
2023-10-10 15:28:42 -04:00
read -r ASKAUTHOR
2023-07-03 08:42:01 -04:00
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
log_yellow "[WARNING] Author should not be empty."
2023-08-15 06:23:40 -04:00
REDO_AUTHOR = true
fi
2023-07-03 08:42:01 -04:00
2023-10-24 08:53:17 -04:00
if [ [ ${ REDO_AUTHOR } = = true ] ] ; then
2023-08-31 04:51:44 -04:00
# Ask again if response does not pass validation.
2023-09-23 10:07:49 -04:00
ASKAUTHOR = ""
2023-08-15 06:23:40 -04:00
ask_author
fi
}
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 }
2023-10-13 14:13:35 -04:00
log_bright "[INFO] Downloading templates from 'teamblueprint/templates'.."
cd .blueprint/tmp
git clone "https://github.com/teamblueprint/templates.git"
2023-10-24 09:00:28 -04:00
cd ${ FOLDER } /.blueprint
2023-10-13 14:25:35 -04:00
cp -R tmp/templates/* data/internal/build/templates/
rm -R tmp/templates
2023-10-24 09:00:28 -04:00
cd ${ FOLDER }
2023-10-13 14:13:35 -04:00
2023-10-24 09:00:28 -04:00
eval $( parse_yaml .blueprint/data/internal/build/templates/${ tnum } /TemplateConfiguration.yml t_) ;
2023-09-23 10:07:49 -04:00
log_bright "[INFO] Copying template contents to the tmp directory.."
2023-08-15 06:23:40 -04:00
mkdir -p .blueprint/tmp/init
2023-10-24 09:00:28 -04:00
cp -R .blueprint/data/internal/build/templates/${ tnum } /contents/* .blueprint/tmp/init/
2023-06-02 10:37:38 -04:00
2023-06-10 08:52:00 -04:00
log_bright "[INFO] Applying variables.."
2023-10-24 09:00:28 -04:00
sed -i " s~␀name␀~ ${ ASKNAME } ~g " .blueprint/tmp/init/conf.yml; #NAME
sed -i " s~␀identifier␀~ ${ ASKIDENTIFIER } ~g " .blueprint/tmp/init/conf.yml; #IDENTIFIER
sed -i " s~␀description␀~ ${ ASKDESCRIPTION } ~g " .blueprint/tmp/init/conf.yml; #DESCRIPTION
sed -i " s~␀ver␀~ ${ ASKVERSION } ~g " .blueprint/tmp/init/conf.yml; #VERSION
sed -i " s~␀author␀~ ${ ASKAUTHOR } ~g " .blueprint/tmp/init/conf.yml; #AUTHOR
2023-06-02 10:37:38 -04:00
2023-10-24 09:00:28 -04:00
if [ [ ${ t_template_files_icon } != "" ] ] ; then
2023-09-23 10:19:28 -04:00
log_bright "[INFO] Rolling (and applying) extension placeholder icon.."
2023-10-11 10:52:01 -04:00
icnNUM = $( expr 1 + $RANDOM % 9)
2023-10-24 09:00:28 -04:00
cp .blueprint/assets/defaultExtensionLogo${ icnNUM } .jpg .blueprint/tmp/init/${ t_template_files_icon }
sed -i " s~␀icon␀~ ${ t_template_files_icon } ~g " .blueprint/tmp/init/conf.yml; #ICON
2023-09-23 10:19:28 -04:00
fi ;
2023-09-23 10:07:49 -04:00
log_bright "[INFO] Applying core variables.."
2023-10-24 09:00:28 -04:00
sed -i " s~␀version␀~ ${ VERSION } ~g " .blueprint/tmp/init/conf.yml #BLUEPRINT-VERSION
2023-06-02 10:37:38 -04:00
# Return files to folder.
2023-09-23 10:07:49 -04:00
log_bright "[INFO] Copying output to extension development directory."
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.
2023-09-23 10:07:49 -04:00
log_bright "[INFO] Purging contents of tmp folder."
2023-08-15 06:23:40 -04:00
rm -R .blueprint/tmp
mkdir -p .blueprint/tmp
2023-06-02 10:37:38 -04:00
2023-10-13 14:13:35 -04:00
# Wipe templates from disk.
log_bright "[INFO] Wiping downloaded templates from disk.."
rm -R .blueprint/data/internal/build/templates/*
2023-09-19 13:30:46 -04:00
sendTelemetry "INITIALIZE_DEVELOPMENT_EXTENSION" > /dev/null
2023-08-15 06:23:40 -04:00
log_green "[SUCCESS] Your extension files have been generated and exported to '.blueprint/dev'."
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-11-01 08:51:33 -04:00
if ! dbValidate "blueprint.developerEnabled" ; then quit_red "[FATAL] Developer mode is not enabled." ; 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
2023-08-04 06:46:57 -04:00
quit_red "[FATAL] You do not have any development files."
2023-08-15 06:23:40 -04:00
fi
log_bright "[INFO] Installing development extension files.."
blueprint -i test␀
2023-09-24 09:58:26 -04:00
log_green "[SUCCESS] Your extension has been built."
2023-08-15 06:23:40 -04:00
sendTelemetry "BUILD_DEVELOPMENT_EXTENSION" > /dev/null
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-11-01 08:51:33 -04:00
if ! dbValidate "blueprint.developerEnabled" ; then quit_red "[FATAL] Developer mode is not enabled." ; 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
2023-08-04 06:47:25 -04:00
quit_red "[FATAL] You do not have any development files."
2023-08-15 06:23:40 -04:00
fi
2023-08-04 06:47:25 -04:00
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Exporting extension files located in '.blueprint/dev'."
2023-05-29 14:33:01 -04:00
2023-06-02 10:37:38 -04:00
cd .blueprint
2023-10-24 09:04:22 -04:00
eval $( parse_yaml dev/conf.yml conf_) ; identifier = " ${ conf_info_identifier } "
2023-08-15 06:23:40 -04:00
cp -R dev/* tmp/
cd tmp
zip -r extension.zip *
2023-10-24 09:04:22 -04:00
cd ${ FOLDER }
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
2023-10-31 06:28:47 -04:00
if [ [ $3 = = "expose" * ] ] ; then
log_bright "[INFO] Generating download url.."
2023-11-01 05:54:10 -04:00
randstr = ${ RANDOM } ${ RANDOM } ${ RANDOM } ${ RANDOM } ${ RANDOM }
mkdir public/assets/extensions/blueprint/exports/${ randstr }
cp ${ identifier } .blueprint public/assets/extensions/blueprint/exports/${ randstr } /${ identifier } .blueprint
2023-10-31 06:50:41 -04:00
log_bright "[INFO] Download url will expire after 2 minutes."
sendTelemetry "EXPOSE_DEVELOPMENT_EXTENSION" > /dev/null
log_green log_bold "\n[SUCCESS] Your extension has been exported successfully."
2023-11-01 08:43:23 -04:00
log_green " - $( grabAppUrl) /assets/extensions/blueprint/exports/ ${ randstr } / ${ identifier } .blueprint "
2023-10-31 06:50:41 -04:00
log_green " - ${ FOLDER } / ${ identifier } .blueprint "
2023-11-01 05:54:51 -04:00
eval $( sleep 120 && rm -R public/assets/extensions/blueprint/exports/${ randstr } 2> /dev/null) &
2023-10-31 06:28:47 -04:00
else
2023-10-31 06:50:41 -04:00
sendTelemetry "EXPORT_DEVELOPMENT_EXTENSION" > /dev/null
log_green log_bold "\n[SUCCESS] Your extension has been exported successfully."
log_green " - ${ FOLDER } / ${ identifier } .blueprint "
2023-10-31 06:28:47 -04:00
fi
2023-09-23 11:14:04 -04:00
fi
# -wipe
if [ [ ( $2 = = "-wipe" || $2 = = "-w" ) ] ] ; then VCMD = "y"
2023-11-01 08:51:33 -04:00
if ! dbValidate "blueprint.developerEnabled" ; then quit_red "[FATAL] Developer mode is not enabled." ; 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
2023-09-24 09:58:26 -04:00
quit_red "[FATAL] You do not have any development files."
fi
2023-09-23 11:14:04 -04:00
log_blue "[INPUT] You are about to wipe all of your extension 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
2023-10-24 09:04:22 -04:00
if [ [ ( ( ${ YN } != "y" * ) && ( ${ YN } != "Y" * ) ) || ( ( ${ YN } = = "" ) ) ] ] ; then log_bright "[INFO] Development files removal cancelled." ; exit 1; fi
2023-09-23 11:14:04 -04:00
log_bright "[INFO] Wiping development folder.."
2023-09-24 10:45:02 -04:00
rm -R .blueprint/dev/* 2> /dev/null
rm -R .blueprint/dev/.* 2> /dev/null
2023-09-23 11:14:04 -04:00
log_green "[SUCCESS] Your development files have been removed."
2023-08-15 06:23:40 -04:00
fi
2023-05-29 14:33:01 -04:00
2023-11-02 14:14:06 -04:00
# -info
if [ [ ( $2 = = "-info" || $2 = = "-f" ) ] ] ; then VCMD = "y"
fetchversion( ) { log_reset log_white $VERSION ; }
fetchfolder( ) { log_reset log_white $FOLDER ; }
fetchurl( ) { log_reset log_white $( grabAppUrl) ; }
fetchlocale( ) { log_reset log_white $( grabAppLocale) ; }
fetchtimezone( ) { log_reset log_white $( grabAppTimezone) ; }
2023-11-02 14:55:03 -04:00
fetchextensions( ) { log_reset log_white $( echo " $( <.blueprint/data/internal/db/installed_extensions) " | tr -cd ',' | wc -c | tr -d ' ' ) ; }
2023-11-02 14:14:06 -04:00
fetchdeveloper( ) { log_reset log_white $( if dbValidate "blueprint.developerEnabled" ; then echo "true" ; else echo "false" ; fi ; ) ; }
fetchtelemetry( ) { log_reset log_white $( telemetrykey = $( cat .blueprint/data/internal/db/telemetry_id) ; if [ [ $telemetrykey = = "KEY_NOT_UPDATED" ] ] ; then echo "false" ; else echo "true" ; fi ; ) ; }
fetchnode( ) { log_reset log_white $( node -v) ; }
fetchyarn( ) { log_reset log_white $( yarn -v) ; }
2023-11-02 14:55:03 -04:00
log_bright " "
log_blue log_bold " ⣿⣿ $( log_reset log_bold log_blue "Version:" ) $( fetchversion) "
log_blue log_bold " ⣿⣿ ⣿⣿ $( log_reset log_bold log_blue "Folder:" ) $( fetchfolder) "
log_blue log_bold " ⣿⣿⣿⣿ $( log_reset log_bold log_blue "URL:" ) $( fetchurl) "
log_blue " $( log_reset log_bold log_blue "Locale:" ) $( fetchlocale) "
log_blue " $( log_reset log_bold log_blue "Timezone:" ) $( fetchtimezone) "
log_blue " $( log_reset log_bold log_blue "Extensions:" ) $( fetchextensions) "
log_blue " $( log_reset log_bold log_blue "Developer:" ) $( fetchdeveloper) "
log_blue " $( log_reset log_bold log_blue "Telemetry:" ) $( fetchtelemetry) "
log_blue " $( log_reset log_bold log_blue "Node:" ) $( fetchnode) "
log_blue " $( log_reset log_bold log_blue "Yarn:" ) $( fetchyarn) "
2023-11-02 14:14:06 -04:00
log_bright " "
fi
2023-08-06 07:41:56 -04: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"
2023-06-15 05:56:11 -04:00
log_yellow "[WARNING] This is an advanced feature, only proceed if you know what you are doing.\n"
2023-08-15 06:23:40 -04:00
dbRemove "blueprint.setupFinished"
2023-10-24 09:04:22 -04:00
cd ${ FOLDER }
2023-08-15 06:23:40 -04:00
bash blueprint.sh
fi
2023-06-01 15:25:15 -04:00
2023-06-18 10:37:46 -04:00
# -upgrade
2023-08-15 06:23:40 -04:00
if [ [ $2 = = "-upgrade" ] ] ; then VCMD = "y"
log_yellow "[WARNING] This is an advanced feature, only proceed if you know what you are doing.\n"
2023-07-14 04:39:26 -04:00
2023-10-13 13:43:33 -04:00
if [ [ -n $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2023-08-15 06:23:40 -04:00
quit_red "[FATAL] Your development directory contains files. To protect you against accidental data loss, you are unable to upgrade unless you clear your .blueprint/dev folder."
fi
2023-07-14 04:39:26 -04:00
2023-07-28 16:12:59 -04:00
if [ [ $@ = = *"dev" * ] ] ; then
2023-08-15 06:23:40 -04:00
log_blue "[INPUT] Upgrading to the latest dev build will update Blueprint to an unstable work-in-progress preview of the next version. Continue? (y/N)"
2023-10-10 15:28:42 -04:00
read -r YN1
2023-10-24 09:04:22 -04:00
if [ [ ( ${ YN1 } != "y" * ) && ( ${ YN1 } != "Y" * ) ] ] ; then log_bright "[INFO] Upgrade cancelled." ; exit 1; fi
2023-08-15 06:23:40 -04:00
fi
log_blue "[INPUT] Upgrading will wipe your .blueprint folder and will overwrite your extensions. Continue? (y/N)"
2023-10-10 15:28:42 -04:00
read -r YN2
2023-10-24 09:04:22 -04:00
if [ [ ( ${ YN2 } != "y" * ) && ( ${ YN2 } != "Y" * ) ] ] ; then log_bright "[INFO] Upgrade cancelled." ; exit 1; fi
2023-08-15 06:23:40 -04:00
log_blue "[INPUT] This is the last warning before upgrading/wiping Blueprint. Type 'continue' to continue, all other input will be taken as 'no'."
2023-10-10 15:28:42 -04:00
read -r YN3
2023-10-24 09:04:22 -04:00
if [ [ ${ YN3 } != "continue" ] ] ; then log_bright "[INFO] Upgrade cancelled." ; exit 1; fi
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Blueprint is upgrading.. Please do not turn off your machine."
cp blueprint.sh .blueprint.sh.bak
2023-10-24 09:04:22 -04:00
if [ [ $@ = = *" dev" ] ] ; then
bash tools/update.sh ${ FOLDER } dev
2023-06-12 10:30:27 -04:00
else
2023-10-24 09:04:22 -04:00
bash tools/update.sh ${ FOLDER }
2023-08-15 06:23:40 -04:00
fi
chmod +x blueprint.sh
2023-10-24 09:04:22 -04:00
_FOLDER = " ${ FOLDER } " bash blueprint.sh --post-upgrade
log_bright "[INFO] Bash might spit out some errors from here on out. Unexpected end of file (eof), command not found and syntax errors are expected behaviour."
2023-08-17 05:44:09 -04:00
log_blue "[INPUT] Do you want to migrate your database? (Y/n)"
2023-10-10 15:28:42 -04:00
read -r YN4
2023-10-24 09:04:22 -04:00
if [ [ ( ${ YN4 } = = "y" ) || ( ${ YN4 } = = "Y" ) || ( ${ YN4 } = = "" ) ] ] ; then
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Running database migrations.."
2023-08-16 12:45:50 -04:00
php artisan migrate --force
2023-06-10 08:52:00 -04:00
else
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Database migrations have been skipped."
fi
2023-06-12 09:21:38 -04:00
2023-07-28 16:12:59 -04:00
# Post-upgrade checks.
2023-08-15 06:23:40 -04:00
log_bright "[INFO] Running post-upgrade checks.."
score = 0
2023-06-12 09:21:38 -04:00
2023-06-10 08:52:00 -04:00
if dbValidate "blueprint.setupFinished" ; then
2023-08-15 06:23:40 -04:00
score = $(( score+1))
2023-06-10 08:52:00 -04:00
else
2023-08-15 06:23:40 -04:00
log_yellow "[WARNING] 'blueprint.setupFinished' could not be 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
2023-08-15 06:23:40 -04:00
log_green "[SUCCESS] Blueprint has upgraded successfully."
rm .blueprint.sh.bak
exit 1
2023-10-24 09:04:22 -04:00
elif [ [ ${ score } = = 0 ] ] ; then
2023-08-15 06:23:40 -04:00
log_red "[FATAL] All checks have failed."
rm blueprint.sh
mv .blueprint.sh.bak blueprint.sh
exit 1
2023-06-10 08:52:00 -04:00
else
2023-08-15 06:23:40 -04:00
log_yellow "[WARNING] Some post-upgrade checks have failed."
rm blueprint.sh
mv .blueprint.sh.bak blueprint.sh
exit 1
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.
2023-08-15 06:23:40 -04:00
quit_red " [FATAL] ' $2 ' is not a valid command or argument. Use argument '-help' for a list of commands. "
2023-09-12 13:55:48 -04:00
fi