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-05-06 10:31:31 -04:00
# This should allow Blueprint to run in docker. Please note that changing the $FOLDER variable after running
# the Blueprint installation script will not change anything in any files besides blueprint.sh.
2023-05-06 10:21:22 -04:00
FOLDER = "pterodactyl"
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-06-02 10:37:38 -04:00
DOCKER = "y" ;
FOLDER = "html"
2023-07-04 08:28:19 -04:00
else
DOCKER = "n" ;
2023-05-06 10:21:22 -04:00
fi ;
2023-04-24 10:43:31 -04:00
# If the fallback version below does not match your downloaded version, please let us know.
2023-07-14 05:53:59 -04:00
VER_FALLBACK = "alpha-4TK" ;
2023-04-24 10:43:31 -04:00
2023-05-06 10:21:22 -04:00
# This will be automatically replaced by some marketplaces, if not, $VER_FALLBACK will be used as fallback.
2023-04-24 10:43:31 -04:00
PM_VERSION = "([(pterodactylmarket_version)])" ;
2023-05-09 11:45:02 -04:00
if [ [ -d " /var/www/ $FOLDER /blueprint " ] ] ; then mv /var/www/$FOLDER /blueprint /var/www/$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-06-27 15:08:01 -04:00
if [ [ ! -f " /var/www/ $FOLDER /.blueprint/data/internal/db/version " ] ] ; then
2023-06-02 10:37:38 -04:00
sed -E -i " s*&bp.version&* $VER_FALLBACK *g " app/Services/Helpers/BlueprintPlaceholderService.php;
sed -E -i " s*@version* $VER_FALLBACK *g " public/extensions/blueprint/index.html;
2023-06-27 15:08:01 -04:00
touch /var/www/$FOLDER /.blueprint/data/internal/db/version;
2023-06-02 10:37:38 -04:00
fi ;
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-06-27 15:08:01 -04:00
if [ [ ! -f " /var/www/ $FOLDER /.blueprint/data/internal/db/version " ] ] ; then
2023-06-02 10:37:38 -04:00
sed -E -i " s*&bp.version&* $PM_VERSION *g " app/Services/Helpers/BlueprintPlaceholderService.php;
sed -E -i " s*@version* $PM_VERSION *g " public/extensions/blueprint/index.html;
2023-06-27 15:08:01 -04:00
touch /var/www/$FOLDER /.blueprint/data/internal/db/version;
2023-06-02 10:37:38 -04:00
fi ;
VERSION = $PM_VERSION ;
2023-04-24 10:43:31 -04:00
fi ;
2023-05-09 11:59:12 -04:00
# Fix for Blueprint's bash database to work with docker and custom folder installations.
sed -i " s!&bp.folder&! $FOLDER !g " /var/www/$FOLDER /.blueprint/lib/db.sh;
2023-06-18 10:37:46 -04:00
cd /var/www/$FOLDER ; # Automatically navigate to the Pterodactyl directory when running the script.
# Import libraries.
2023-03-19 16:02:29 -04:00
source .blueprint/lib/bash_colors.sh;
2023-03-22 05:47:43 -04:00
source .blueprint/lib/parse_yaml.sh;
2023-03-22 04:28:14 -04:00
source .blueprint/lib/db.sh;
2023-06-18 12:32:02 -04:00
source .blueprint/lib/telemetry.sh;
2023-03-03 10:52:29 -05: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
echo " $cTELEMETRY " > .blueprint/data/internal/db/telemetry_id;
2023-06-18 12:32:02 -04:00
fi ;
2023-06-27 15:49:11 -04:00
2023-07-16 14:22:59 -04:00
echo BP_100;
2023-06-28 10:57:05 -04:00
exit 1;
2023-04-23 15:23:15 -04:00
fi ;
2023-06-18 10:37:46 -04:00
# Function that exits the script after logging a "red" message.
2023-06-10 09:46:36 -04:00
quit_red( ) {
2023-07-14 05:02:59 -04:00
log_red " $1 " ;
2023-06-02 10:37:38 -04:00
exit 1;
2023-04-05 15:26:33 -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-04-02 14:47:24 -04:00
touch /usr/local/bin/blueprint > /dev/null;
2023-05-06 10:21:22 -04:00
echo -e " #!/bin/bash\nbash /var/www/ $FOLDER /blueprint.sh -bash \$@; " > /usr/local/bin/blueprint;
chmod u+x /var/www/$FOLDER /blueprint.sh > /dev/null;
2023-04-02 14:47:24 -04:00
chmod u+x /usr/local/bin/blueprint > /dev/null;
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-06-15 05:44:33 -04:00
log_yellow "[WARNING] This command only works if you have yet to install Blueprint. Run 'blueprint (cmd) [arg]' instead." ;
2023-06-02 10:37:38 -04:00
exit 1;
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-07-09 01:47:40 -04:00
log " ██\n██ ██\n ████\n" ; # Blueprint logo made out of unicode icons.
2023-06-10 08:52:00 -04:00
if [ [ $DOCKER = = "y" ] ] ; then
2023-06-15 05:56:11 -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." ;
2023-06-10 08:52:00 -04:00
fi ;
2023-06-02 10:37:38 -04:00
fi ;
2023-05-06 10:21:22 -04:00
2023-06-26 06:40:33 -04:00
# Update folder placeholder on PlaceholderService and admin layout.
2023-07-04 04:37:31 -04:00
log_bright " [INFO] /var/www/ $FOLDER /app/Services/Helpers/BlueprintPlaceholderService.php " ;
2023-06-02 10:37:38 -04:00
sed -i " s!&bp.folder&! $FOLDER !g " /var/www/$FOLDER /app/Services/Helpers/BlueprintPlaceholderService.php;
2023-07-04 04:37:31 -04:00
log_bright " [INFO] /var/www/ $FOLDER /app/Services/Helpers/BlueprintPlaceholderService.php " ;
2023-06-02 10:37:38 -04:00
sed -i " s!&bp.folder&! $FOLDER !g " /var/www/$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.
log_bright " [INFO] cp /var/www/ $FOLDER /.blueprint/assets/logo.jpg /var/www/ $FOLDER /public/assets/extensions/blueprint/logo.jpg; " ;
cp /var/www/$FOLDER /.blueprint/assets/logo.jpg /var/www/$FOLDER /public/assets/extensions/blueprint/logo.jpg;
2023-06-17 07:28:26 -04:00
# Put application into maintenance.
2023-06-10 08:52:00 -04:00
log_bright "[INFO] php artisan down" ;
2023-06-02 10:37:38 -04:00
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-06-10 08:52:00 -04:00
log_bright " [INFO] /var/www/ $FOLDER /public/themes/pterodactyl/css/pterodactyl.css " ;
2023-06-02 10:37:38 -04:00
sed -i "s!@import 'checkbox.css';!@import 'checkbox.css';\n@import url(/assets/extensions/blueprint/blueprint.style.css);\n/* blueprint reserved line */!g" /var/www/$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-06-10 08:52:00 -04:00
log_bright "[INFO] php artisan view:clear" ;
2023-06-02 10:37:38 -04:00
php artisan view:clear;
2023-03-08 12:35:54 -05:00
2023-06-26 06:40:33 -04:00
# Clear PHP config. Not sure what this does yet, but I know it fixes some strange problems.
2023-06-10 08:52:00 -04:00
log_bright "[INFO] php artisan config:clear" ;
2023-06-02 10:37:38 -04:00
php artisan config:clear;
2023-03-06 13:11:53 -05:00
2023-03-08 12:35:54 -05: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
log_bright "[INFO] php artisan migrate" ;
2023-06-26 08:42:31 -04:00
log_yellow "[WARNING] Answering 'no' or 'n' to the following prompt may result into problems with Blueprint."
2023-06-10 08:52:00 -04:00
php artisan migrate;
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-06-10 08:52:00 -04:00
log_bright " [INFO] chown -R www-data:www-data /var/www/ $FOLDER /* " ;
2023-06-02 10:37:38 -04:00
chown -R www-data:www-data /var/www/$FOLDER /*;
2023-03-06 13:11:53 -05:00
2023-06-26 06:40:33 -04:00
# Make sure all .files have the correct permissions as well.
2023-06-10 08:52:00 -04:00
log_bright " [INFO] chown -R www-data:www-data /var/www/ $FOLDER /.* " ;
2023-06-02 10:37:38 -04:00
chown -R www-data:www-data /var/www/$FOLDER /.*;
2023-04-10 10:50:23 -04:00
2023-07-06 06:27:27 -04:00
# Remove placeholder README.md files.
2023-07-12 08:32:44 -04:00
log_bright " [INFO] rm -R /var/www/ $FOLDER /.blueprint/dev/* " ;
rm -R /var/www/$FOLDER /.blueprint/dev/*;
log_bright " [INFO] rm -R /var/www/ $FOLDER /.blueprint/data/extensions/* " ;
rm -R /var/www/$FOLDER /.blueprint/data/extensions/*;
log_bright " [INFO] rm /var/www/ $FOLDER /tools/tmp/README.md " ;
rm /var/www/$FOLDER /tools/tmp/README.md > /dev/null;
2023-05-30 05:27:02 -04:00
2023-06-17 07:28:26 -04:00
# Put application into production.
2023-06-10 08:52:00 -04:00
log_bright "[INFO] php artisan up" ;
2023-06-02 10:37:38 -04:00
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-06-26 08:42:31 -04:00
log_bright "[INFO] Blueprint is completely open source and free. Please consider supporting us on \"ptero.shop/donate\"." ;
sleep 2;
2023-06-15 05:56:11 -04:00
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." ;
2023-06-10 08:52:00 -04:00
fi ;
2023-04-10 11:13:28 -04:00
2023-06-02 10:37:38 -04:00
dbAdd "blueprint.setupFinished" ;
2023-07-09 01:47:40 -04:00
# Let the panel know the user has finished installation.
2023-06-20 12:08:25 -04:00
sed -i "s!NOTINSTALLED!INSTALLED!g" /var/www/$FOLDER /app/Services/Helpers/BlueprintPlaceholderService.php;
2023-06-02 10:37:38 -04:00
exit 1;
fi ;
2023-03-19 15:20:01 -04:00
fi ;
2023-06-18 10:37:46 -04:00
# -i, -install
2023-04-02 15:12:21 -04:00
if [ [ ( $2 = = "-i" ) || ( $2 = = "-install" ) ] ] ; then
2023-06-10 09:46:36 -04:00
if [ [ $( expr $# - 2) != 1 ] ] ; then quit_red " [FATAL] Expected 1 argument but got $( expr $# - 2) . " ; fi ;
2023-06-02 10:37:38 -04:00
if [ [ $3 = = "test␀" ] ] ; then
dev = true;
n = "dev" ;
2023-06-27 15:08:01 -04:00
mkdir .blueprint/tmp/dev;
cp -R .blueprint/dev/* .blueprint/tmp/dev/;
2023-06-02 10:37:38 -04:00
else
dev = false;
n = $3 ;
2023-07-04 08:19:48 -04:00
FILE = $n ".blueprint" ;
2023-06-10 09:46:36 -04:00
if [ [ ! -f " $FILE " ] ] ; then quit_red " [FATAL] $FILE could not be found. " ; fi ;
2023-06-02 10:37:38 -04:00
ZIP = $n ".zip" ;
2023-06-27 15:08:01 -04:00
cp $FILE .blueprint/tmp/$ZIP ;
cd .blueprint/tmp;
2023-06-02 10:37:38 -04:00
unzip $ZIP ;
rm $ZIP ;
if [ [ ! -f " $n /* " ] ] ; then
cd ..;
rm -R tmp;
mkdir tmp;
cd tmp;
mkdir ./$n ;
2023-06-27 15:08:01 -04:00
cp ../../$FILE ./$n /$ZIP ;
2023-06-02 10:37:38 -04:00
cd $n ;
unzip $ZIP ;
rm $ZIP ;
cd ..;
2023-04-12 12:10:45 -04:00
fi ;
2023-06-02 10:37:38 -04:00
fi ;
2023-04-17 10:54:12 -04:00
2023-06-18 10:37:46 -04:00
# Return to the Pterodactyl installation folder.
2023-06-02 10:37:38 -04:00
cd /var/www/$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-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-07-02 14:58:59 -04:00
name = $conf_info_name ;
identifier = $conf_info_identifier ;
description = $conf_info_description ;
flags = $conf_info_flags ;
version = $conf_info_version ;
target = $conf_info_target ;
author = $conf_info_author ;
icon = $conf_info_icon ;
website = $conf_info_website ; #(optional)
admin_view = $conf_admin_view ;
admin_controller = $conf_admin_controller ; #(optional)
admin_css = $conf_admin_css ; #(optional)
2023-07-13 15:27:05 -04:00
dashboard_wrapper = $conf_dashboard_wrapper ; #(optional)
2023-07-02 14:58:59 -04:00
data_directory = $conf_data_directory ; #(optional)
data_public = $conf_data_public ; #(optional)
database_migrations = $conf_database_migrations ; #(optional)
2023-07-14 04:34:09 -04:00
if [ [ ( $icon = = "/" * ) || ( $icon = = "." * ) || ( $icon = = *"\n" * ) ] ] ||
[ [ ( $admin_view = = "/" * ) || ( $admin_view = = "." * ) || ( $admin_view = = *"\n" * ) ] ] ||
[ [ ( $admin_controller = = "/" * ) || ( $admin_controller = = "." * ) || ( $admin_controller = = *"\n" * ) ] ] ||
[ [ ( $admin_css = = "/" * ) || ( $admin_css = = "." * ) || ( $admin_css = = *"\n" * ) ] ] ||
[ [ ( $data_directory = = "/" * ) || ( $data_directory = = "." * ) || ( $data_directory = = *"\n" * ) ] ] ||
[ [ ( $data_public = = "/" * ) || ( $data_public = = "." * ) || ( $data_public = = *"\n" * ) ] ] ||
[ [ ( $database_migrations = = "/" * ) || ( $database_migrations = = "." * ) || ( $database_migrations = = *"\n" * ) ] ] ; then
2023-07-02 08:42:30 -04:00
rm -R .blueprint/tmp/$n ;
quit_red "[FATAL] Extension has failed security checks, halting installation." ;
fi ;
2023-06-19 15:04:06 -04:00
2023-07-20 09:36:58 -04:00
if [ [ $( cat .blueprint/data/internal/db/installed_extensions) = = *" $identifier , " * ] ] ; then
log_bright "[INFO] Extension appears to be installed already, skipping some tasks." ;
DUPLICATE = "y" ;
fi ;
2023-06-19 15:04:06 -04:00
if [ [ $website != "" ] ] ; then
if [ [ $website != "https://" * ] ] ; then
if [ [ $website != "http://" * ] ] ; then
website = "http://" $info_website ;
fi ;
fi ;
fi ;
2023-05-17 03:55:16 -04:00
2023-07-03 06:48:40 -04:00
if [ [ $dev = = true ] ] ; then
2023-06-27 15:08:01 -04:00
mv .blueprint/tmp/$n .blueprint/tmp/$identifier ;
2023-06-02 10:37:38 -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-06-27 15:08:01 -04:00
DIR = .blueprint/tmp/$n /*;
2023-03-26 09:19:39 -04:00
2023-06-27 14:36:03 -04:00
if [ [ ( $flags = = *"ignoreAlphabetPlaceholders," * ) || ( $flags = = *"ignoreAlphabetPlaceholders" ) ] ] ; then
2023-06-02 10:37:38 -04:00
SKIPAZPLACEHOLDERS = true;
2023-06-27 14:36:03 -04:00
log_bright "[INFO] Alphabet placeholders will be skipped due to the 'ignoreAlphabetPlaceholders' flag." ;
2023-06-02 10:37:38 -04:00
else
SKIPAZPLACEHOLDERS = false;
2023-05-21 09:10:43 -04:00
fi ;
2023-06-02 10:37:38 -04:00
for f in $( find $DIR -type f -exec echo { } \; ) ; do
sed -i " s~\^#version#\^~ $version ~g " $f ;
sed -i " s~\^#author#\^~ $author ~g " $f ;
2023-07-20 06:26:00 -04:00
sed -i " s~\^#name#\^~ $name ~g " $f ;
2023-06-02 10:37:38 -04:00
sed -i " s~\^#identifier#\^~ $identifier ~g " $f ;
sed -i " s~\^#path#\^~/var/www/ $FOLDER ~g " $f ;
2023-06-27 15:08:01 -04:00
sed -i " s~\^#datapath#\^~/var/www/ $FOLDER /.blueprint/data/extensions/ $identifier ~g " $f ;
2023-04-17 10:11:33 -04:00
2023-06-02 10:37:38 -04:00
if [ [ $SKIPAZPLACEHOLDERS != true ] ] ; then
2023-06-28 09:16:29 -04:00
sed -i " s~__version__~ $version ~g " $f ;
sed -i " s~__author__~ $author ~g " $f ;
sed -i " s~__identifier__~ $identifier ~g " $f ;
2023-07-20 06:26:00 -04:00
sed -i " s~__name__~ $name ~g " $f ;
2023-06-28 09:16:29 -04:00
sed -i " s~__path__~/var/www/ $FOLDER ~g " $f ;
sed -i " s~__datapath__~/var/www/ $FOLDER /.blueprint/data/extensions/ $identifier ~g " $f ;
2023-06-02 10:37:38 -04:00
fi ;
2023-04-14 11:19:15 -04:00
2023-06-10 08:52:00 -04:00
log_bright " [INFO] Done placeholders in ' $f '. " ;
2023-06-02 10:37:38 -04:00
done ;
2023-03-26 11:24:30 -04:00
2023-06-27 14:36:03 -04:00
else log_bright "[INFO] Placeholders will be skipped due to the 'ignorePlaceholders' flag." ; fi ;
2023-03-22 05:20:59 -04:00
2023-06-27 15:08:01 -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 ;
if [ [ $icon = = "" ] ] ; then rm -R .blueprint/tmp/$n ; quit_red "[FATAL] 'info_icon' is a required configuration option." ; fi ;
2023-06-11 15:03:15 -04:00
2023-07-12 08:18:43 -04:00
if [ [ $admin_controller = = "" ] ] ; then log_bright "[INFO] Admin controller field left blank, using default controller instead.." ;
2023-06-11 14:58:20 -04:00
controller_type = "default" ; else controller_type = "custom" ; fi ;
2023-06-27 15:08:01 -04:00
if [ [ $admin_view = = "" ] ] ; then rm -R .blueprint/tmp/$n ; quit_red "[FATAL] 'admin_view' is a required configuration option." ; fi ;
2023-07-12 08:18:43 -04:00
if [ [ $target != $VERSION ] ] ; then log_yellow " [WARNING] This extension is built for version $target , but your version is $VERSION . " ; fi ;
2023-06-27 15:08:01 -04:00
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-03-22 05:20:59 -04:00
2023-07-12 08:18:43 -04:00
if [ [ $identifier = ~ [ a-z] ] ] ; then log_bright "[INFO] Identifier a-z checks passed." ;
2023-06-27 15:08:01 -04:00
else rm -R .blueprint/tmp/$n ; quit_red "[FATAL] The extension identifier should be lowercase and only contain characters a-z." ; fi ;
if [ [ ! -f " .blueprint/tmp/ $n / $icon " ] ] ; then
rm -R .blueprint/tmp/$n ; quit_red "[FATAL] The 'info_icon' path points to a file that does not exist." ; fi ;
2023-04-01 06:58:23 -04:00
2023-06-11 14:58:20 -04:00
if [ [ $database_migrations != "" ] ] ; then
2023-06-27 15:08:01 -04:00
cp -R .blueprint/tmp/$n /$database_migrations /* database/migrations/ 2> /dev/null;
2023-06-02 10:37:38 -04:00
fi ;
2023-03-26 09:27:37 -04:00
2023-06-11 14:58:20 -04:00
if [ [ $css != "" ] ] ; then
INJECTCSS = "y" ;
2023-06-02 10:37:38 -04:00
fi ;
2023-06-11 14:58:20 -04:00
if [ [ $admin_requests != "" ] ] ; then
2023-07-12 08:18:43 -04:00
log_yellow "[WARNING] Admin requests are deprecated. Use them in your controller instead." ;
2023-06-02 10:37:38 -04:00
fi ;
2023-06-11 14:58:20 -04:00
if [ [ $data_public != "" ] ] ; then
mkdir public/extensions/$identifier ;
2023-06-27 15:08:01 -04:00
cp -R .blueprint/tmp/$n /$data_public /* public/extensions/$identifier / 2> /dev/null;
2023-06-02 10:37:38 -04:00
fi ;
2023-06-29 14:32:00 -04:00
cp -R .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-07-03 07:06:57 -04:00
cp -R .blueprint/data/internal/build/extensions/controller.php .blueprint/data/internal/build/extensions/controller.php.bak 2> /dev/null;
2023-06-02 10:37:38 -04:00
fi ;
2023-06-29 14:32:00 -04:00
cp -R .blueprint/data/internal/build/extensions/route.php .blueprint/data/internal/build/extensions/route.php.bak 2> /dev/null;
2023-07-03 06:48:40 -04:00
cp -R .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-06-27 15:08:01 -04:00
mkdir .blueprint/data/extensions/$identifier ;
2023-07-12 08:18:43 -04:00
mkdir .blueprint/data/extensions/$identifier /.store;
2023-07-13 15:15:13 -04:00
cp .blueprint/tmp/$n /conf.yml .blueprint/data/extensions/$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-06-27 15:08:01 -04:00
cp -R .blueprint/tmp/$n /$data_directory /* .blueprint/data/extensions/$identifier /;
2023-06-02 10:37:38 -04:00
fi ;
2023-07-12 08:18:43 -04:00
# End creating data directory.
2023-06-02 10:37:38 -04:00
mkdir public/assets/extensions/$identifier ;
2023-06-27 15:08:01 -04:00
cp .blueprint/tmp/$n /$icon public/assets/extensions/$identifier /icon.jpg;
2023-06-02 10:37:38 -04:00
ICON = " /assets/extensions/ $identifier /icon.jpg " ;
2023-06-27 15:08:01 -04:00
CONTENT = $( cat .blueprint/tmp/$n /$admin_view ) ;
2023-06-02 10:37:38 -04:00
if [ [ $INJECTCSS = = "y" ] ] ; then
sed -i " s!/* blueprint reserved line */!/* blueprint reserved line */\n@import url(/assets/extensions/ $identifier / $identifier .style.css);!g " public/themes/pterodactyl/css/pterodactyl.css;
2023-06-27 15:08:01 -04:00
cp -R .blueprint/tmp/$n /$css /* public/assets/extensions/$identifier /$identifier .style.css 2> /dev/null;
2023-06-02 10:37:38 -04:00
fi ;
2023-06-10 08:52:00 -04:00
if [ [ $name = = *"~" * ] ] ; then log_yellow "[WARNING] 'name' contains '~' and may result in an error." ; fi ;
if [ [ $description = = *"~" * ] ] ; then log_yellow "[WARNING] 'description' contains '~' and may result in an error." ; fi ;
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-06-29 14:32:00 -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;
2023-07-03 06:48:40 -04:00
sed -i " s~␀name␀~ $name ~g " .blueprint/data/internal/build/extensions/button.blade.php.bak;
2023-06-02 10:37:38 -04:00
2023-06-29 14:32:00 -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-06-29 14:32:00 -04:00
sed -i " s~␀version␀~ $version ~g " .blueprint/data/internal/build/extensions/admin.blade.php.bak;
2023-07-03 06:48:40 -04:00
sed -i " s~␀version␀~ $version ~g " .blueprint/data/internal/build/extensions/button.blade.php.bak;
2023-06-02 10:37:38 -04:00
2023-06-29 14:32:00 -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-06-19 15:04:06 -04:00
if [ [ $website != "" ] ] ; then
2023-06-29 14:32:00 -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-06-19 15:04:06 -04:00
fi ;
2023-06-29 14:32:00 -04:00
echo -e " $CONTENT \n@endsection " >> .blueprint/data/internal/build/extensions/admin.blade.php.bak;
2023-06-02 10:37:38 -04:00
2023-06-19 15:04:06 -04:00
2023-06-11 14:58:20 -04:00
if [ [ $admin_controller = = "" ] ] ; then
2023-06-29 14:32:00 -04:00
sed -i " s~␀id␀~ $identifier ~g " .blueprint/data/internal/build/extensions/controller.php.bak;
2023-06-02 10:37:38 -04:00
fi ;
2023-06-29 14:32:00 -04:00
sed -i " s~␀id␀~ $identifier ~g " .blueprint/data/internal/build/extensions/route.php.bak;
2023-07-03 06:48:40 -04:00
sed -i " s~␀id␀~ $identifier ~g " .blueprint/data/internal/build/extensions/button.blade.php.bak;
2023-06-02 10:37:38 -04:00
2023-06-29 14:32:00 -04:00
ADMINVIEW_RESULT = $( cat .blueprint/data/internal/build/extensions/admin.blade.php.bak) ;
ADMINROUTE_RESULT = $( cat .blueprint/data/internal/build/extensions/route.php.bak) ;
2023-07-03 06:48:40 -04:00
ADMINBUTTON_RESULT = $( cat .blueprint/data/internal/build/extensions/button.blade.php.bak) ;
2023-06-11 14:58:20 -04:00
if [ [ $admin_controller = = "" ] ] ; then
2023-06-29 14:32:00 -04:00
ADMINCONTROLLER_RESULT = $( cat .blueprint/data/internal/build/extensions/controller.php.bak) ;
2023-06-02 10:37:38 -04:00
fi ;
ADMINCONTROLLER_NAME = $identifier "ExtensionController.php" ;
mkdir 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;
mkdir 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-07-03 07:48:09 -04:00
touch app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
2023-06-02 10:37:38 -04:00
echo $ADMINCONTROLLER_RESULT > app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
else
2023-06-27 15:08:01 -04:00
cp .blueprint/tmp/$n /$admin_controller app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
2023-06-02 10:37:38 -04:00
fi ;
2023-07-20 09:36:58 -04:00
if [ [ $DUPLICATE != "y" ] ] ; then
echo $ADMINROUTE_RESULT >> routes/admin.php;
fi ;
2023-06-02 10:37:38 -04:00
2023-07-20 09:36:58 -04:00
if [ [ $DUPLICATE != "y" ] ] ; then
sed -i " s~<!--␀replace␀-->~ $ADMINBUTTON_RESULT \n<!--␀replace␀-->~g " resources/views/admin/extensions.blade.php;
else
log_yellow "[INFO] Changes to the '/admin/extensions' page have been skipped."
fi ;
2023-06-02 10:37:38 -04:00
2023-07-13 04:41:44 -04:00
# insert "dashboard_wrapper" into wrapper.blade.php
2023-07-13 15:27:05 -04:00
if [ [ $dashboard_wrapper != "" ] ] ; then
2023-07-20 05:46:42 -04:00
sed -i " /<\!-- wrapper:insert -->/r .blueprint/tmp/ $n / $dashboard_wrapper " resources/views/templates/wrapper.blade.php;
2023-07-13 04:41:44 -04:00
fi ;
2023-06-29 14:32:00 -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-06-29 14:32:00 -04:00
rm .blueprint/data/internal/build/extensions/controller.php.bak;
2023-06-02 10:37:38 -04:00
fi ;
2023-06-29 14:32:00 -04:00
rm .blueprint/data/internal/build/extensions/route.php.bak;
2023-07-03 06:48:40 -04:00
rm .blueprint/data/internal/build/extensions/button.blade.php.bak;
2023-06-27 15:08:01 -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-06-10 08:52:00 -04:00
log_bright "[INFO] This extension comes with migrations. If you get prompted, answer 'yes'.\n" ;
2023-06-02 10:37:38 -04:00
php artisan migrate;
fi ;
2023-06-27 15:08:01 -04:00
chmod -R +x .blueprint/data/extensions/$identifier /*;
2023-06-02 10:37:38 -04:00
2023-06-27 14:36:03 -04:00
if [ [ ( $flags = = *"hasInstallScript," * ) || ( $flags = = *"hasInstallScript" ) ] ] ; then
2023-07-04 08:19:48 -04:00
log_yellow "[WARNING] This extension uses a custom installation script, proceed with caution." ;
2023-07-20 07:07:22 -04:00
chmod +x .blueprint/data/extensions/$identifier /install.sh;
2023-06-27 15:08:01 -04:00
bash .blueprint/data/extensions/$identifier /install.sh;
2023-06-02 10:37:38 -04:00
fi ;
2023-07-20 09:36:58 -04:00
if [ [ $DUPLICATE != "y" ] ] ; then
echo $identifier "," >> .blueprint/data/internal/db/installed_extensions;
log_bright " [INFO] Added ' $identifier ' to the list of installed extensions. " ;
fi ;
2023-06-15 05:56:11 -04:00
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. " ;
2023-07-03 08:42:01 -04:00
if [ [ $dev = = false ] ] ; then
2023-06-23 14:38:52 -04:00
sendTelemetry "FINISH_EXTENSION_INSTALLATION" > /dev/null;
2023-06-19 15:49:25 -04:00
fi ;
2023-03-22 05:20:59 -04:00
fi ;
2023-06-18 10:37:46 -04:00
# help, -help, --help
2023-05-04 16:01:35 -04:00
if [ [ ( $2 = = "help" ) || ( $2 = = "-help" ) || ( $2 = = "--help" ) ] ] ; then
2023-06-12 09:49:55 -04:00
echo -e " -install [name] install a blueprint extension" "
" " -version get the current blueprint version""
2023-06-10 10:09:12 -04:00
" " -init initialize extension development files""
" " -build run an installation on your extension development files""
2023-06-26 08:42:31 -04:00
" " -export export your extension development files""
2023-06-15 05:56:11 -04:00
" " -runinstall rerun the blueprint installation script ( advanced) ""
" " -upgrade ( dev) update/reset to a newer pre-release version ( advanced) " ;
2023-03-27 15:17:57 -04:00
fi ;
2023-06-18 10:37:46 -04:00
# -v, -version
2023-04-02 15:12:21 -04:00
if [ [ ( $2 = = "-v" ) || ( $2 = = "-version" ) ] ] ; then
2023-06-02 10:37:38 -04:00
echo -e $VERSION ;
2023-04-10 10:50:23 -04:00
fi ;
2023-06-18 10:37:46 -04:00
# -init
2023-05-04 16:01:35 -04:00
if [ [ $2 = = "-init" ] ] ; then
2023-07-03 08:42:01 -04:00
ask_name( ) {
2023-07-04 07:25:16 -04:00
log_blue "[INPUT] Name (Generic Extension):" ;
read ASKNAME;
2023-07-03 08:42:01 -04:00
REDO_NAME = false;
# Name should not be empty
2023-07-03 08:46:49 -04:00
if [ [ $ASKNAME = = "" ] ] ; then
log_red "[FATAL] Name should not be empty." ;
REDO_NAME = true;
fi ;
2023-07-03 08:42:01 -04:00
if [ [ $REDO_NAME = = true ] ] ; then
ask_name;
fi ;
} ;
ask_identifier( ) {
2023-07-04 07:25:16 -04:00
log_blue "[INPUT] Identifier (genericextension):" ;
read ASKIDENTIFIER;
2023-07-03 08:42:01 -04:00
REDO_IDENTIFIER = false;
# Identifier should not be empty
2023-07-03 08:46:49 -04:00
if [ [ $ASKIDENTIFIER = = "" ] ] ; then
log_red "[FATAL] Identifier should not be empty." ;
REDO_IDENTIFIER = true;
fi ;
2023-07-03 08:42:01 -04:00
# Identifier should be a-z.
2023-07-03 08:46:49 -04:00
if [ [ $ASKIDENTIFIER = ~ [ a-z] ] ] ; then
echo ok > /dev/null;
else
log_red "[FATAL] Identifier should only contain a-z characters." ;
REDO_IDENTIFIER = true;
fi ;
2023-07-03 08:42:01 -04:00
if [ [ $REDO_IDENTIFIER = = true ] ] ; then
ask_identifier;
fi ;
} ;
ask_description( ) {
2023-07-04 07:25:16 -04:00
log_blue "[INFO] Description (My awesome description):" ;
read ASKDESCRIPTION;
2023-07-03 08:42:01 -04:00
REDO_DESCRIPTION = false;
# Description should not be empty
2023-07-03 08:46:49 -04:00
if [ [ $ASKDESCRIPTION = = "" ] ] ; then
log_red "[FATAL] Description should not be empty." ;
REDO_DESCRIPTION = true;
fi ;
2023-07-03 08:42:01 -04:00
if [ [ $REDO_DESCRIPTION = = true ] ] ; then
ask_description;
fi ;
} ;
ask_version( ) {
2023-07-04 07:25:16 -04:00
log_blue "[INPUT] Version (indev):" ;
read ASKVERSION;
2023-07-03 08:42:01 -04:00
REDO_VERSION = false;
# Version should not be empty
2023-07-03 08:46:49 -04:00
if [ [ $ASKVERSION = = "" ] ] ; then
log_red "[FATAL] Version should not be empty." ;
REDO_VERSION = true;
fi ;
2023-07-03 08:42:01 -04:00
if [ [ $REDO_VERSION = = true ] ] ; then
ask_version;
fi ;
} ;
ask_author( ) {
2023-07-04 07:25:16 -04:00
log_blue "[INPUT] Author (prplwtf):" ;
read ASKAUTHOR;
2023-07-03 08:42:01 -04:00
REDO_AUTHOR = false;
# Author should not be empty
2023-07-03 08:46:49 -04:00
if [ [ $ASKAUTHOR = = "" ] ] ; then
log_red "[FATAL] Author should not be empty." ;
REDO_AUTHOR = true;
fi ;
2023-07-03 08:42:01 -04:00
if [ [ $REDO_AUTHOR = = true ] ] ; then
ask_author;
fi ;
} ;
ask_name;
ask_identifier;
ask_description;
ask_version;
ask_author;
2023-06-02 10:37:38 -04:00
2023-06-10 08:52:00 -04:00
log_bright "[INFO] Copying init defaults to tmp directory.." ;
2023-06-27 15:08:01 -04:00
mkdir .blueprint/tmp/init;
cp -R .blueprint/data/internal/build/init/* .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-06-27 15:08:01 -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-06-12 11:45:03 -04:00
icnNUM = $( expr 1 + $RANDOM % 4) ;
2023-06-27 15:08:01 -04:00
sed -i " s~␀num␀~ $icnNUM ~g " .blueprint/tmp/init/conf.yml;
sed -i " s~␀version␀~ $VERSION ~g " .blueprint/tmp/init/conf.yml;
2023-06-02 10:37:38 -04:00
# Return files to folder.
2023-06-27 15:08:01 -04:00
log_bright "[INFO] Copying output to dev directory."
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.
log_bright "[INFO] Purging tmp files."
2023-06-27 15:08:01 -04:00
rm -R .blueprint/tmp;
mkdir .blueprint/tmp;
2023-06-02 10:37:38 -04:00
2023-06-27 15:08:01 -04:00
log_green "[SUCCESS] Your extension files have been generated and exported to '.blueprint/dev'." ;
2023-05-17 03:55:16 -04:00
fi ;
2023-06-28 15:31:22 -04:00
# -build
if [ [ $2 = = "-build" ] ] ; then
2023-06-10 09:46:36 -04:00
log_bright "[INFO] Installing development extension files.." ;
2023-06-02 10:37:38 -04:00
blueprint -i test␀;
2023-06-10 09:46:36 -04:00
log_bright "[INFO] Extension installation ends here, if there are any errors during installation, fix them and try again." ;
2023-06-23 14:38:52 -04:00
sendTelemetry "BUILD_DEVELOPMENT_EXTENSION" > /dev/null;
2023-05-04 16:01:35 -04:00
fi ;
2023-06-24 04:55:21 -04:00
# -export
2023-05-29 14:33:01 -04:00
if [ [ $2 = = "-export" ] ] ; then
2023-06-27 15:08:01 -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-07-02 14:58:59 -04:00
eval $( parse_yaml dev/conf.yml conf_) ; identifier = $conf_info_identifier ;
2023-06-27 15:08:01 -04:00
cp -R dev/* tmp/;
cd tmp;
2023-06-24 04:55:21 -04:00
zip -r extension.zip *;
cd /var/www/$FOLDER ;
2023-06-27 15:08:01 -04:00
cp .blueprint/tmp/extension.zip $identifier .blueprint;
rm -R .blueprint/tmp;
mkdir .blueprint/tmp;
2023-06-26 08:42:31 -04:00
# This will be replaced with a success/fail check in the future.
log_bright "[INFO] Export finished." ;
2023-05-29 14:33:01 -04:00
fi ;
2023-06-18 10:37:46 -04:00
# -runinstall
2023-06-15 05:56:11 -04:00
if [ [ $2 = = "-runinstall" ] ] ; then
log_yellow "[WARNING] This is an advanced feature, only proceed if you know what you are doing.\n"
2023-06-02 10:37:38 -04:00
dbRemove "blueprint.setupFinished" ;
cd /var/www/$FOLDER ;
bash blueprint.sh;
2023-05-20 03:01:26 -04:00
fi ;
2023-06-01 15:25:15 -04:00
2023-06-18 10:37:46 -04:00
# -upgrade
2023-06-01 15:25:15 -04:00
if [ [ $2 = = "-upgrade" ] ] ; then
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-07-14 04:39:26 -04:00
if [ [ -n $( find .blueprint/dev -maxdepth 1 -type f -not -name "README.md" -print -quit) ] ] ; then
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-06-12 10:30:27 -04:00
if [ [ $3 = = "dev" ] ] ; then
2023-07-04 07:25:16 -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-06-12 10:30:27 -04:00
read YN1;
if [ [ ( $YN1 != "y" ) && ( $YN1 != "Y" ) ] ] ; then log_bright "[INFO] Upgrade cancelled." ; exit 1; fi ;
fi ;
2023-07-04 07:25:16 -04:00
log_blue "[INPUT] Upgrading will wipe your .blueprint folder and will overwrite your extensions. Continue? (y/N)" ;
2023-06-10 08:52:00 -04:00
read YN2;
if [ [ ( $YN2 != "y" ) && ( $YN2 != "Y" ) ] ] ; then log_bright "[INFO] Upgrade cancelled." ; exit 1; fi ;
2023-07-04 07:25:16 -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-06-10 08:52:00 -04:00
read YN3;
if [ [ $YN3 != "continue" ] ] ; then log_bright "[INFO] Upgrade cancelled." ; exit 1; fi ;
log_bright "[INFO] Blueprint is upgrading.. Please do not turn off your machine." ;
2023-07-13 04:41:44 -04:00
cp blueprint.sh .blueprint.sh.bak;
2023-06-12 10:30:27 -04:00
if [ [ $3 = = "dev" ] ] ; then
bash tools/update.sh /var/www/$FOLDER dev
else
bash tools/update.sh /var/www/$FOLDER
fi ;
2023-06-24 04:55:21 -04:00
rm -R tools/tmp/*;
2023-06-10 08:52:00 -04:00
log_bright "[INFO] Files have been upgraded, running installation script.." ;
chmod +x blueprint.sh;
bash blueprint.sh --post-upgrade;
2023-06-19 15:11:27 -04:00
log_bright "[INFO] Bash might spit out some errors from here on out. EOF, command not found and syntax errors are expected behaviour." ;
2023-07-04 07:25:16 -04:00
log_blue "[INPUT] Database migrations are skipped when upgrading, run them anyways? (Y/n)" ;
2023-06-10 08:52:00 -04:00
read YN4;
if [ [ ( $YN4 = = "y" ) || ( $YN4 = = "Y" ) ] ] ; then
log_bright "[INFO] Running database migrations.." ;
php artisan migrate;
else
log_bright "[INFO] Database migrations have been skipped." ;
fi ;
2023-06-12 09:21:38 -04:00
2023-06-10 08:52:00 -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
score = $(( score+1)) ;
else
log_yellow "[WARNING] 'blueprint.setupFinished' could not be found." ;
fi ;
2023-06-12 09:21:38 -04:00
2023-06-10 08:52:00 -04:00
if [ [ $score = = 1 ] ] ; then
log_green "[SUCCESS] Blueprint has upgraded successfully." ;
2023-07-13 04:41:44 -04:00
rm .blueprint.sh.bak;
exit 1;
2023-06-10 08:52:00 -04:00
elif [ [ $score = = 0 ] ] ; then
2023-07-04 07:38:13 -04:00
log_red "[FATAL] All checks have failed." ;
2023-07-13 04:41:44 -04:00
rm blueprint.sh;
mv .blueprint.sh.bak;
exit 1;
2023-06-10 08:52:00 -04:00
else
2023-07-04 07:38:13 -04:00
log_yellow "[WARNING] Some post-upgrade checks have failed." ;
2023-07-13 04:41:44 -04:00
rm blueprint.sh;
mv .blueprint.sh.bak;
exit 1;
2023-06-02 10:37:38 -04:00
fi ;
2023-06-02 16:01:47 -04:00
fi ;