2023-03-03 10:52:29 -05:00
#!/bin/bash
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"
if [ [ -f ".dockerenv" ] ] ; then
2023-06-02 10:37:38 -04:00
DOCKER = "y" ;
FOLDER = "html"
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-06-06 14:04:27 -04:00
VER_FALLBACK = "alpha-T0R" ;
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-05-04 16:01:35 -04:00
# BUILT_FROM_SOURCE="y"; # If you downloaded Blueprint from a release instead of building it, this should be "n".
2023-06-01 16:00:02 -04:00
# if [[ $BUILT_FROM_SOURCE == "y" ]]; then if [[ ! -f "/var/www/$FOLDER/.blueprint/.storage/versionschemefix.flag" ]]; then sed -E -i "s*&bp.version&*source*g" app/Services/Helpers/BlueprintPlaceholderService.php;touch /var/www/$FOLDER/.blueprint/.storage/versionschemefix.flag;fi;VERSION="source";
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.
if [ [ ! -f " /var/www/ $FOLDER /.blueprint/.storage/versionschemefix.flag " ] ] ; then
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;
touch /var/www/$FOLDER /.blueprint/.storage/versionschemefix.flag;
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.
if [ [ ! -f " /var/www/ $FOLDER /.blueprint/.storage/versionschemefix.flag " ] ] ; then
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;
touch /var/www/$FOLDER /.blueprint/.storage/versionschemefix.flag;
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-05 14:41:13 -04:00
cd /var/www/$FOLDER ;
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-03-03 10:52:29 -05:00
2023-04-23 15:23:15 -04:00
if [ [ " $@ " = = *"-php" * ] ] ; then
2023-06-02 10:37:38 -04:00
exit 1;
2023-04-23 15:23:15 -04:00
fi ;
2023-04-05 15:26:33 -04:00
export NEWT_COLORS = '
2023-06-02 10:37:38 -04:00
root = ,black
2023-06-05 12:20:01 -04:00
window = black,red
title = white,red
border = red,red
textbox = white,red
2023-06-02 10:37:38 -04:00
listbox = white,black
2023-06-05 12:20:01 -04:00
button = white,red
2023-04-05 15:26:33 -04:00
' ;
error( ) {
2023-06-05 12:20:01 -04:00
whiptail --title " Blueprint " --ok-button "ok" --msgbox " Sorry, this operation could not be completed. For troubleshooting, please go to ptero.shop/error.\n\n\" ${ 1 } \" " 15 60;
2023-06-02 10:37:38 -04:00
log_red " ${ 1 } " ;
exit 1;
2023-04-05 15:26:33 -04:00
} ;
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-10 08:52:00 -04:00
log_yellow "[WARNING] This command only works if you have yet to install Blueprint. You can run 'blueprint (cmd) [arg]' instead." ;
2023-06-02 10:37:38 -04:00
exit 1;
else
2023-06-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
log " ██\n██ ██\n ████\n" ;
if [ [ $DOCKER = = "y" ] ] ; then
log_yellow "[WARNING] Running Blueprint with Docker may result in issues." ;
fi ;
2023-06-02 10:37:38 -04:00
fi ;
2023-05-06 10:21:22 -04:00
2023-06-02 10:37:38 -04:00
sed -i " s!&bp.folder&! $FOLDER !g " /var/www/$FOLDER /app/Services/Helpers/BlueprintPlaceholderService.php;
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-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-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-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-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-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
log_bright "[INFO] php artisan migrate" ;
php artisan migrate;
fi ;
2023-04-08 10:14:36 -04:00
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-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-06-10 08:52:00 -04:00
log_bright "[INFO] rm .blueprint/.development/.hello.txt" ;
2023-06-02 10:37:38 -04:00
rm .blueprint/.development/.hello.txt;
2023-05-30 05:27:02 -04:00
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-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
log_green "\n\n[SUCCESS] Blueprint should now be installed. If something didn't work as expected, please let us know at discord.gg/CUwHwv6xRe." ;
fi ;
2023-04-10 11:13:28 -04:00
2023-06-02 10:37:38 -04:00
dbAdd "blueprint.setupFinished" ;
exit 1;
fi ;
2023-03-19 15:20:01 -04:00
fi ;
2023-04-02 15:12:21 -04:00
if [ [ ( $2 = = "-i" ) || ( $2 = = "-install" ) ] ] ; then
2023-06-10 08:52:00 -04:00
log_bright "[INFO] Always make sure you place your extensions in the Pterodactyl directory, else Blueprint won't be able to find them!" ;
2023-06-05 14:45:31 -04:00
2023-06-10 08:52:00 -04:00
if [ [ $( expr $# - 2) != 1 ] ] ; then log_red " [FATAL] Expected 1 argument but got $( expr $# - 2) . " ; exit 1; fi ;
2023-06-02 10:37:38 -04:00
if [ [ $3 = = "test␀" ] ] ; then
dev = true;
n = "dev" ;
mkdir .blueprint/.storage/tmp/dev;
cp -R .blueprint/.development/* .blueprint/.storage/tmp/dev/;
else
dev = false;
n = $3 ;
FILE = $n ".blueprint"
2023-06-10 08:52:00 -04:00
if [ [ ! -f " $FILE " ] ] ; then log_red " [FATAL] $FILE could not be found. " ; fi ;
2023-06-02 10:37:38 -04:00
ZIP = $n ".zip" ;
cp $FILE .blueprint/.storage/tmp/$ZIP ;
cd .blueprint/.storage/tmp;
unzip $ZIP ;
rm $ZIP ;
if [ [ ! -f " $n /* " ] ] ; then
cd ..;
rm -R tmp;
mkdir tmp;
cd tmp;
mkdir ./$n ;
2023-06-05 14:34:20 -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-02 10:37:38 -04:00
cd /var/www/$FOLDER ;
2023-03-22 05:20:59 -04:00
2023-06-02 10:37:38 -04:00
eval $( parse_yaml .blueprint/.storage/tmp/$n /conf.yml)
2023-05-17 03:55:16 -04:00
2023-06-02 10:37:38 -04:00
if [ [ $dev ] ] ; then
mv .blueprint/.storage/tmp/$n .blueprint/.storage/tmp/$identifier ;
n = $identifier ;
fi ;
2023-03-26 12:19:10 -04:00
2023-06-02 10:37:38 -04:00
if [ [ $flags != *"-placeholders.skip;" * ] ] ; then
DIR = .blueprint/.storage/tmp/$n /*;
2023-03-26 09:19:39 -04:00
2023-06-02 10:37:38 -04:00
if [ [ $flags = = *"-disable_az_placeholders;" * ] ] ; then
SKIPAZPLACEHOLDERS = true;
2023-06-10 08:52:00 -04:00
log_bright "[INFO] A-Z placeholders will be skipped due to the '-disable_az_placeholders;' 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 ;
sed -i " s~\^#identifier#\^~ $identifier ~g " $f ;
sed -i " s~\^#path#\^~/var/www/ $FOLDER ~g " $f ;
sed -i " s~\^#datapath#\^~/var/www/ $FOLDER /.blueprint/.storage/extensiondata/ $identifier ~g " $f ;
2023-04-17 10:11:33 -04:00
2023-06-02 10:37:38 -04:00
if [ [ $SKIPAZPLACEHOLDERS != true ] ] ; then
sed -i " s~bpversionreplace~ $version ~g " $f ;
sed -i " s~bpauthorreplace~ $author ~g " $f ;
sed -i " s~bpidentifierreplace~ $identifier ~g " $f ;
sed -i " s~bppathreplace~/var/www/ $FOLDER ~g " $f ;
sed -i " s~bpdatapathreplace~/var/www/ $FOLDER /.blueprint/.storage/extensiondata/ $identifier ~g " $f ;
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-10 08:52:00 -04:00
else log_bright "[INFO] Placeholders will be skipped due to the '-placeholders.skip;' flag." ; fi ;
2023-03-22 05:20:59 -04:00
2023-06-10 08:52:00 -04:00
if [ [ $name = = "" ] ] ; then rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] 'name' is a required configuration option." ; fi ;
if [ [ $identifier = = "" ] ] ; then rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] 'identifier' is a required configuration option." ; fi ;
if [ [ $description = = "" ] ] ; then rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] 'description' is a required configuration option." ; fi ;
if [ [ $version = = "" ] ] ; then rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] 'version' is a required configuration option." ; fi ;
if [ [ $target = = "" ] ] ; then rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] 'target' is a required configuration option." ; fi ;
if [ [ $icon = = "" ] ] ; then rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] 'icon' is a required configuration option." ; fi ;
2023-03-26 09:10:04 -04:00
2023-06-10 08:52:00 -04:00
if [ [ $datafolder_directory = = "" ] ] ; then log_bright "[INFO] Datafolder field left blank, skipping.." ; fi ;
if [ [ $controller_location = = "" ] ] ; then log_bright "[INFO] Controller location field left blank, using default controller instead.." ;
controller_type = "default" ; fi ;
if [ [ $view_location = = "" ] ] ; then rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] 'view_location' 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/.storage/tmp/$n ; log_red "[FATAL] The extension file name must be the same as your identifier. (example: identifier.blueprint)" ; fi ;
if [ [ $identifier = = "blueprint" ] ] ; then rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] Extensions can not have the identifier 'blueprint'." ; fi ;
2023-03-22 05:20:59 -04:00
2023-06-10 08:52:00 -04:00
if [ [ $identifier = ~ [ a-z] ] ] ; then log_bright "[INFO] Identifier a-z checks passed." ;
else rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] The extension identifier should be lowercase and only contain characters a-z." ; fi ;
if [ [ ! -f " .blueprint/.storage/tmp/ $n / $icon " ] ] ; then
rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] The 'icon' path points to a file that does not exist." ; fi ;
2023-04-01 06:58:23 -04:00
2023-06-02 10:37:38 -04:00
if [ [ $migrations_directory != "" ] ] ; then
2023-06-10 08:52:00 -04:00
if [ [ $migrations_enabled = = "yes" ] ] ; then log_bright "[INFO] migrations_enabled yes/no checks passed." ;
2023-06-02 10:37:38 -04:00
cp -R .blueprint/.storage/tmp/$n /$migrations_directory /* database/migrations/ 2> /dev/null;
2023-06-10 08:52:00 -04:00
elif [ [ $migrations_enabled = = "no" ] ] ; then log_bright "[INFO] migrations_enabled yes/no checks passed." ;
else rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] If defined, migrations_enabled should only be 'yes' or 'no'." ; fi ;
2023-06-02 10:37:38 -04:00
fi ;
2023-03-26 09:27:37 -04:00
2023-06-02 10:37:38 -04:00
if [ [ $css_location != "" ] ] ; then
2023-06-10 08:52:00 -04:00
if [ [ $css_enabled = = "yes" ] ] ; then log_bright "[INFO] css_enabled yes/no checks passed." ; INJECTCSS = "y" ;
elif [ [ $css_enabled = = "no" ] ] ; then log_bright "[INFO] css_enabled yes/no checks passed." ;
else rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] If defined, css_enabled should only be 'yes' or 'no'." ; fi ;
2023-06-02 10:37:38 -04:00
fi ;
if [ [ $adminrequests_directory != "" ] ] ; then
2023-06-10 08:52:00 -04:00
if [ [ $adminrequests_enabled = = "yes" ] ] ; then log_bright "[INFO] adminrequests_enabled yes/no checks passed." ;
2023-06-02 10:37:38 -04:00
mkdir app/Http/Requests/Admin/Extensions/$identifier ;
cp -R .blueprint/.storage/tmp/$n /$adminrequests_directory /* app/Http/Requests/Admin/Extensions/$identifier / 2> /dev/null;
2023-06-10 08:52:00 -04:00
elif [ [ $adminrequests_enabled = = "no" ] ] ; then logbright "[INFO] adminrequests_enabled yes/no checks passed." ;
else rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] If defined, adminrequests_enabled should only be 'yes' or 'no'." ; fi ;
2023-06-02 10:37:38 -04:00
fi ;
if [ [ $publicfiles_directory != "" ] ] ; then
2023-06-10 08:52:00 -04:00
if [ [ $publicfiles_enabled = = "yes" ] ] ; then log_bright "[INFO] publicfiles_enabled yes/no checks passed." ;
2023-06-02 10:37:38 -04:00
mkdir public/extensions/$identifier ;
cp -R .blueprint/.storage/tmp/$n /$publicfiles_directory /* public/extensions/$identifier / 2> /dev/null;
2023-06-10 08:52:00 -04:00
elif [ [ $publicfiles_enabled = = "no" ] ] ; then log_bright "[INFO] publicfiles_enabled yes/no checks passed." ;
else rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] If defined, publicfiles_enabled should only be 'yes' or 'no'." ; fi ;
2023-06-02 10:37:38 -04:00
fi ;
cp -R .blueprint/.storage/defaults/extensions/admin.default .blueprint/.storage/defaults/extensions/admin.default.bak 2> /dev/null;
if [ [ $controller_type != "" ] ] ; then
2023-06-10 08:52:00 -04:00
if [ [ $controller_type = = "default" ] ] ; then log_bright "[INFO] controller_type default/custom checks passed." ;
2023-06-02 10:37:38 -04:00
cp -R .blueprint/.storage/defaults/extensions/controller.default .blueprint/.storage/defaults/extensions/controller.default.bak 2> /dev/null;
2023-06-10 08:52:00 -04:00
elif [ [ $controller_type = = "custom" ] ] ; then log_bright "[INFO] controller_type default/custom checks passed." ;
else rm -R .blueprint/.storage/tmp/$n ; log_red "[FATAL] If defined, controller_type should only be 'default' or 'custom'." ; fi ;
2023-06-02 10:37:38 -04:00
fi ;
cp -R .blueprint/.storage/defaults/extensions/route.default .blueprint/.storage/defaults/extensions/route.default.bak 2> /dev/null;
cp -R .blueprint/.storage/defaults/extensions/button.default .blueprint/.storage/defaults/extensions/button.default.bak 2> /dev/null;
mkdir .blueprint/.storage/extensiondata/$identifier ;
if [ [ $datafolder_directory != "" ] ] ; then
cp -R .blueprint/.storage/tmp/$n /$datafolder_directory /* .blueprint/.storage/extensiondata/$identifier /;
fi ;
mkdir public/assets/extensions/$identifier ;
cp .blueprint/.storage/tmp/$n /$icon public/assets/extensions/$identifier /icon.jpg;
ICON = " /assets/extensions/ $identifier /icon.jpg " ;
CONTENT = $( cat .blueprint/.storage/tmp/$n /$view_location ) ;
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;
cp -R .blueprint/.storage/tmp/$n /$css_location /* public/assets/extensions/$identifier /$identifier .style.css 2> /dev/null;
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
sed -i " s~␀title␀~ $name ~g " .blueprint/.storage/defaults/extensions/admin.default.bak;
sed -i " s~␀name␀~ $name ~g " .blueprint/.storage/defaults/extensions/admin.default.bak;
sed -i " s~␀breadcrumb␀~ $name ~g " .blueprint/.storage/defaults/extensions/admin.default.bak;
sed -i " s~␀name␀~ $name ~g " .blueprint/.storage/defaults/extensions/button.default.bak;
sed -i " s~␀description␀~ $description ~g " .blueprint/.storage/defaults/extensions/admin.default.bak;
sed -i " s~␀version␀~ $version ~g " .blueprint/.storage/defaults/extensions/admin.default.bak;
sed -i " s~␀version␀~ $version ~g " .blueprint/.storage/defaults/extensions/button.default.bak;
sed -i " s~␀icon␀~ $ICON ~g " .blueprint/.storage/defaults/extensions/admin.default.bak;
echo -e " $CONTENT \n@endsection " >> .blueprint/.storage/defaults/extensions/admin.default.bak;
if [ [ $controller_type != "custom" ] ] ; then
sed -i " s~␀id␀~ $identifier ~g " .blueprint/.storage/defaults/extensions/controller.default.bak;
fi ;
sed -i " s~␀id␀~ $identifier ~g " .blueprint/.storage/defaults/extensions/route.default.bak;
sed -i " s~␀id␀~ $identifier ~g " .blueprint/.storage/defaults/extensions/button.default.bak;
ADMINVIEW_RESULT = $( cat .blueprint/.storage/defaults/extensions/admin.default.bak) ;
ADMINROUTE_RESULT = $( cat .blueprint/.storage/defaults/extensions/route.default.bak) ;
ADMINBUTTON_RESULT = $( cat .blueprint/.storage/defaults/extensions/button.default.bak) ;
if [ [ $controller_type != "custom" ] ] ; then
ADMINCONTROLLER_RESULT = $( cat .blueprint/.storage/defaults/extensions/controller.default.bak) ;
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 ;
if [ [ $controller_type != "custom" ] ] ; then
echo $ADMINCONTROLLER_RESULT > app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
else
cp .blueprint/.storage/tmp/$n /$controller_location app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
fi ;
if [ [ $controller_type = = "custom" ] ] ; then
cp .blueprint/.storage/tmp/$n /$controller_location app/Http/Controllers/Admin/Extensions/$identifier /${ identifier } ExtensionController.php;
fi ;
echo $ADMINROUTE_RESULT >> routes/admin.php;
sed -i " s~<!--␀replace␀-->~ $ADMINBUTTON_RESULT \n<!--␀replace␀-->~g " resources/views/admin/extensions.blade.php;
rm .blueprint/.storage/defaults/extensions/admin.default.bak;
if [ [ $controller_type != "custom" ] ] ; then
rm .blueprint/.storage/defaults/extensions/controller.default.bak;
fi ;
rm .blueprint/.storage/defaults/extensions/route.default.bak;
rm .blueprint/.storage/defaults/extensions/button.default.bak;
rm -R .blueprint/.storage/tmp/$n ;
if [ [ $migrations_enabled = = "yes" ] ] ; 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 ;
chmod -R +x .blueprint/.storage/extensiondata/$identifier /*;
if [ [ $flags = = *"-run.afterinstall;" * ] ] ; then
2023-06-10 08:52:00 -04:00
log_yellow "[WARNING] This extension uses a custom installation script, proceed with caution."
2023-06-02 10:37:38 -04:00
bash .blueprint/.storage/extensiondata/$identifier /install.sh;
fi ;
2023-06-10 08:52:00 -04:00
log_green " \n\n[SUCCESS] $identifier should now be installed. If something didn't work as expected, please let us know at discord.gg/CUwHwv6xRe. " ;
2023-03-22 05:20:59 -04:00
fi ;
2023-05-04 16:01:35 -04:00
if [ [ ( $2 = = "help" ) || ( $2 = = "-help" ) || ( $2 = = "--help" ) ] ] ; then
2023-06-01 14:41:36 -04:00
echo -e " -install -i [name] install a blueprint extension" "
" " -version -v get the current blueprint version""
" " -init initialize extension development files.""
" " -build run an installation on your extension development files.""
" " -export export your extension development files ( experimental) ""
2023-06-01 15:25:15 -04:00
" " -reinstall rerun the blueprint installation script""
2023-06-05 14:45:31 -04:00
" " -upgrade update/reset to a newer version ( experimental) " ;
2023-03-27 15:17:57 -04:00
fi ;
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-05-04 16:01:35 -04:00
if [ [ $2 = = "-init" ] ] ; then
2023-06-02 10:37:38 -04:00
echo "Name (Generic Extension):" ; read ASKNAME;
echo "Identifier (genericextension):" ; read ASKIDENTIFIER;
echo "Description (My awesome description):" ; read ASKDESCRIPTION;
echo "Version (indev):" ; read ASKVERSION;
echo "Author (prplwtf):" ; read ASKAUTHOR;
2023-06-10 08:52:00 -04:00
log_bright "[INFO] Running validation checks.." ;
if [ [ $ASKIDENTIFIER = ~ [ a-z] ] ] ; then log_bright "[INFO] Identifier a-z checks passed." > /dev/null;
else log_red "[FATAL] Identifier should only contain a-z characters." ; exit 1; fi ;
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-02 10:37:38 -04:00
mkdir .blueprint/.storage/tmp/init;
cp -R .blueprint/.storage/defaults/init/* .blueprint/.storage/tmp/init/;
2023-06-10 08:52:00 -04:00
log_bright "[INFO] Applying variables.."
2023-06-02 10:37:38 -04:00
sed -i " s~␀name␀~ $ASKNAME ~g " .blueprint/.storage/tmp/init/conf.yml; #NAME
sed -i " s~␀identifier␀~ $ASKIDENTIFIER ~g " .blueprint/.storage/tmp/init/conf.yml; #IDENTIFIER
sed -i " s~␀description␀~ $ASKDESCRIPTION ~g " .blueprint/.storage/tmp/init/conf.yml; #DESCRIPTION
sed -i " s~␀ver␀~ $ASKVERSION ~g " .blueprint/.storage/tmp/init/conf.yml; #VERSION
sed -i " s~␀author␀~ $ASKAUTHOR ~g " .blueprint/.storage/tmp/init/conf.yml; #AUTHOR
icnNUM = $( expr 1 + $RANDOM % 3) ;
sed -i " s~␀num␀~ $icnNUM ~g " .blueprint/.storage/tmp/init/conf.yml;
sed -i " s~␀version␀~ $VERSION ~g " .blueprint/.storage/tmp/init/conf.yml;
# Return files to folder.
2023-06-10 08:52:00 -04:00
log_bright "[INFO] Copying output to .development directory."
2023-06-02 10:37:38 -04:00
cp -R .blueprint/.storage/tmp/init/* .blueprint/.development/;
2023-06-10 08:52:00 -04:00
# Remove tmp files.
log_bright "[INFO] Purging tmp files."
2023-06-02 10:37:38 -04:00
rm -R .blueprint/.storage/tmp;
mkdir .blueprint/.storage/tmp;
2023-06-10 08:52:00 -04:00
log_green "[SUCCESS] Your extension files have been generated and exported to '.blueprint/.development'." ;
2023-05-17 03:55:16 -04:00
fi ;
2023-06-01 14:41:36 -04:00
if [ [ ( $2 = = "-build" ) || ( $2 = = "-test" ) ] ] ; then
2023-06-02 10:37:38 -04:00
if [ [ $2 = = "-test" ] ] ; then
log_bright "-test will be removed in future versions, use -build instead." ;
fi
log "Attempting to install extension files located in '.blueprint/.development'." ;
2023-05-17 03:55:16 -04:00
2023-06-02 10:37:38 -04:00
blueprint -i test␀;
2023-05-04 16:01:35 -04:00
fi ;
2023-05-29 14:33:01 -04:00
if [ [ $2 = = "-export" ] ] ; then
2023-06-10 08:52:00 -04:00
log_yellow "[WARNING] This is an experimental feature, proceed with caution." ;
log_bright "[INFO] Exporting extension files located in '.blueprint/.development'." ;
2023-05-29 14:33:01 -04:00
2023-06-02 10:37:38 -04:00
cd .blueprint
zip .storage/tmp/blueprint.zip .development/*
mv .storage/tmp/blueprint.zip ../extension.blueprint;
2023-05-29 14:33:01 -04:00
2023-06-10 08:52:00 -04:00
log_bright "[INFO] Extension files should be exported into your Pterodactyl directory now. Some versions of Blueprint may require your identifier to match the filename (excluding the .blueprint extension). You'll need to do this manually." ;
2023-05-29 14:33:01 -04:00
fi ;
2023-04-10 10:50:23 -04:00
if [ [ $2 = = "-reinstall" ] ] ; then
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
if [ [ $2 = = "-upgrade" ] ] ; then
2023-06-10 08:52:00 -04:00
log_yellow "[WARNING] This is an experimental feature, proceed with caution.\n" ;
2023-06-02 10:37:38 -04:00
2023-06-10 08:52:00 -04:00
log_yellow "[WARNING] Upgrading will update Blueprint to an unstable work-in-progress preview of the next version. Continue? (y/N)" ;
read YN1;
if [ [ ( $YN1 != "y" ) && ( $YN1 != "Y" ) ] ] ; then log_bright "[INFO] Upgrade cancelled." ; exit 1; fi ;
log_yellow "[WARNING] Upgrading will wipe your .blueprint folder and will overwrite your extensions. Continue? (y/N)" ;
read YN2;
if [ [ ( $YN2 != "y" ) && ( $YN2 != "Y" ) ] ] ; then log_bright "[INFO] Upgrade cancelled." ; exit 1; fi ;
log_yellow "[WARNING] This is the last warning before upgrading/wiping Blueprint. Type 'continue' to continue, all other input will be taken as 'no'." ;
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." ;
bash tools/update.sh /var/www/$FOLDER ;
log_bright "[INFO] Files have been upgraded, running installation script.." ;
chmod +x blueprint.sh;
bash blueprint.sh --post-upgrade;
log_yellow "[WARNING] Database migrations are skipped when upgrading, run them anyways? (Y/n)" ;
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 ;
log_bright "[INFO] Running post-upgrade checks.." ;
score = 0;
if dbValidate "blueprint.setupFinished" ; then
score = $(( score+1)) ;
else
log_yellow "[WARNING] 'blueprint.setupFinished' could not be found." ;
fi ;
if [ [ $score = = 1 ] ] ; then
log_green "[SUCCESS] Blueprint has upgraded successfully." ;
elif [ [ $score = = 0 ] ] ; then
log_red "[FATAL] Upgrading has failed."
else
log_yellow "[WARNING] Some post-upgrade checks have failed."
2023-06-02 10:37:38 -04:00
fi ;
2023-06-02 16:01:47 -04:00
fi ;