2023-03-03 10:52:29 -05:00
#!/bin/bash
2023-04-24 10:43:31 -04:00
# If the fallback version below does not match your downloaded version, please let us know.
VER_FALLBACK = "indev-4N3" ;
# This will be automatically replaced by some marketplaces, if not, $VERSION will be used as fallback.
PM_VERSION = "([(pterodactylmarket_version)])" ;
if [ [ $PM_VERSION = = "([(pterodactylmarket" "_version)])" ] ] ; then
# This runs when the placeholder has not changed, indicating an issue with PterodactylMarket
# or Blueprint being installed from other sources.
if [ [ ! -f "/var/www/pterodactyl/.blueprint/.flags/versionschemefix" ] ] ; then
sed -E -i " s*&bp.version&* $VER_FALLBACK *g " app/Services/Helpers/BlueprintPlaceholderService.php;
touch /var/www/pterodactyl/.blueprint/.flags/versionschemefix;
fi ;
VERSION = $VER_FALLBACK ;
elif [ [ $PM_VERSION != "([(pterodactylmarket" "_version)])" ] ] ; then
# This runs in case it is possible to use the PterodactylMarket placeholder instead of the
# fallback version.
if [ [ ! -f "/var/www/pterodactyl/.blueprint/.flags/versionschemefix" ] ] ; then
sed -E -i " s*&bp.version&* $PM_VERSION *g " app/Services/Helpers/BlueprintPlaceholderService.php;
touch /var/www/pterodactyl/.blueprint/.flags/versionschemefix;
fi ;
VERSION = $PM_VERSION ;
fi ;
2023-03-22 09:04:03 -04:00
2023-03-19 16:02:29 -04:00
mkdir .blueprint 2> /dev/null;
cp -R blueprint/* .blueprint/ 2> /dev/null;
2023-04-23 15:23:15 -04:00
cp -R blueprint/.* .blueprint/ 2> /dev/null;
2023-03-19 16:02:29 -04:00
rm -R blueprint 2> /dev/null;
2023-03-06 13:11:53 -05:00
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
cd /var/www/pterodactyl;
if [ [ " $@ " = = *"-php" * ] ] ; then
exit 1;
fi ;
2023-04-05 15:26:33 -04:00
export NEWT_COLORS = '
root = ,black
window = black,blue
title = white,blue
border = blue,blue
textbox = white,blue
listbox = white,black
button = white,blue
' ;
error( ) {
whiptail --title " ◆ " --ok-button "ok" --msgbox " Sorry, this operation could not be completed. For troubleshooting, please go to ptero.shop/error.\n\n\" ${ 1 } \" " 15 60;
clr_red " ${ 1 } " ;
exit 1;
} ;
2023-04-02 14:47:24 -04:00
touch /usr/local/bin/blueprint > /dev/null;
echo -e "#!/bin/bash\nbash /var/www/pterodactyl/blueprint.sh -bash \$@;" > /usr/local/bin/blueprint;
chmod u+x /var/www/pterodactyl/blueprint.sh > /dev/null;
chmod u+x /usr/local/bin/blueprint > /dev/null;
2023-03-23 06:54:40 -04:00
if [ [ $1 != "-bash" ] ] ; then
2023-03-03 10:52:29 -05:00
if dbValidate "blueprint.setupFinished" ; then
2023-03-19 16:02:29 -04:00
clr_blue "This command only works if you have yet to install Blueprint. You can run \"\033[1;94mblueprint\033[0m\033[0;34m\" instead." ;
2023-03-22 05:20:59 -04:00
exit 1;
2023-03-03 10:52:29 -05:00
else
2023-04-10 10:50:23 -04:00
clr_bright "php artisan down" ;
php artisan down;
2023-03-19 16:02:29 -04:00
clr_bright "/var/www/pterodactyl/public/themes/pterodactyl/css/pterodactyl.css" ;
2023-04-17 09:43:44 -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/pterodactyl/public/themes/pterodactyl/css/pterodactyl.css;
2023-03-06 13:11:53 -05:00
2023-03-19 16:02:29 -04:00
clr_bright "php artisan view:clear" ;
2023-04-10 10:50:23 -04:00
php artisan view:clear;
2023-03-08 12:35:54 -05:00
2023-03-19 16:02:29 -04:00
clr_bright "php artisan config:clear" ;
2023-04-10 10:50:23 -04:00
php artisan config:clear;
2023-03-06 13:11:53 -05:00
2023-03-08 12:35:54 -05:00
2023-04-10 10:50:23 -04:00
clr_bright "php artisan migrate" ;
php artisan migrate;
2023-04-08 10:14:36 -04:00
2023-03-19 16:02:29 -04:00
clr_bright "chown -R www-data:www-data /var/www/pterodactyl/*" ;
2023-04-10 10:50:23 -04:00
chown -R www-data:www-data /var/www/pterodactyl/*;
2023-03-06 13:11:53 -05:00
2023-03-19 16:02:29 -04:00
clr_bright "chown -R www-data:www-data /var/www/pterodactyl/.*" ;
2023-04-10 10:50:23 -04:00
chown -R www-data:www-data /var/www/pterodactyl/.*;
clr_bright "php artisan up" ;
php artisan up;
2023-03-19 15:20:01 -04:00
2023-04-10 11:13:28 -04:00
clr_blue "\n\nBlueprint should now be installed. If something didn't work as expected, please let us know at discord.gg/CUwHwv6xRe." ;
2023-03-03 11:00:03 -05:00
dbAdd "blueprint.setupFinished" ;
2023-03-22 05:20:59 -04:00
exit 1;
2023-03-03 10:52:29 -05:00
fi ;
2023-03-19 15:20:01 -04:00
fi ;
2023-04-10 14:12:31 -04:00
if [ [ $2 = = "-placeholder" ] ] ; then
if [ [ $3 = = "" ] ] ; then
2023-04-17 10:11:33 -04:00
echo -e " Expected 1 argument but got $( expr $# - 2) . (-placeholder versionid) " ;
2023-04-10 14:12:31 -04:00
exit 1;
fi ;
2023-04-24 10:51:53 -04:00
sed -E -i " s*&version&* $3 *g " app/Services/Helpers/BlueprintPlaceholderService.php;
sed -E -i " s*&version&* $3 *g " blueprint.sh;
2023-04-10 14:12:31 -04:00
fi ;
2023-04-02 15:12:21 -04:00
if [ [ ( $2 = = "-i" ) || ( $2 = = "-install" ) ] ] ; then
2023-04-14 11:19:15 -04:00
if [ [ $( expr $# - 2) != 1 ] ] ; then error " Expected 1 argument but got $( expr $# - 2) . " ; fi ;
2023-03-22 05:20:59 -04:00
FILE = $3 ".blueprint"
2023-04-05 15:26:33 -04:00
if [ [ ! -f " $FILE " ] ] ; then error " $FILE could not be found. " ; fi ;
2023-03-22 05:20:59 -04:00
2023-04-23 11:24:23 -04:00
ZIP = $3 ".zip" ;
2023-03-22 05:20:59 -04:00
cp $FILE .blueprint/tmp/$ZIP ;
2023-03-22 05:47:43 -04:00
cd .blueprint/tmp;
unzip $ZIP ;
2023-04-14 11:19:15 -04:00
rm $ZIP ;
if [ [ ! -f " $3 /* " ] ] ; then
cd ..;
rm -R tmp;
mkdir tmp;
cd tmp;
mkdir ./$3 ;
cp ../../$FILE ./$3 /$ZIP ;
cd $3 ;
unzip $ZIP ;
rm $ZIP ;
cd ..;
2023-04-12 12:10:45 -04:00
fi ;
2023-04-17 10:54:12 -04:00
2023-03-22 05:47:43 -04:00
cd /var/www/pterodactyl;
2023-03-22 05:20:59 -04:00
2023-04-01 06:59:27 -04:00
eval $( parse_yaml .blueprint/tmp/$3 /conf.yml)
2023-03-27 15:17:57 -04:00
2023-04-18 04:07:55 -04:00
if [ [ $flags != *"-placeholders.skip;" * ] ] ; then
2023-04-17 10:54:12 -04:00
DIR = .blueprint/tmp/$3 /*;
# ^#version#^ = version
# ^#author#^ = author
for f in $DIR ; do
sed -i " s~^#version#^~ $version ~g " $f ;
sed -i " s~^#author#^~ $author ~g " $f ;
2023-04-18 04:07:55 -04:00
echo " Done placeholders in ' $f '. " ;
2023-04-17 10:54:12 -04:00
done ;
2023-04-18 04:07:55 -04:00
else echo "-placeholders.skip;" ; fi ;
2023-04-17 10:54:12 -04:00
2023-04-05 15:26:33 -04:00
if [ [ $name = = "" ] ] ; then rm -R .blueprint/tmp/$3 ; error "'name' is a required option." ; fi ;
if [ [ $identifier = = "" ] ] ; then rm -R .blueprint/tmp/$3 ; error "'identifier' is a required option." ; fi ;
if [ [ $description = = "" ] ] ; then rm -R .blueprint/tmp/$3 ; error "'description' is a required option." ; fi ;
if [ [ $version = = "" ] ] ; then rm -R .blueprint/tmp/$3 ; error "'version' is a required option." ; fi ;
if [ [ $target = = "" ] ] ; then rm -R .blueprint/tmp/$3 ; error "'target' is a required option." ; fi ;
if [ [ $icon = = "" ] ] ; then rm -R .blueprint/tmp/$3 ; error "'icon' is a required option." ; fi ;
2023-03-27 15:17:57 -04:00
2023-04-12 11:04:15 -04:00
if [ [ $controller_location = = "" ] ] ; then rm -R .blueprint/tmp/$3 ; error "'controller_location' is a required option." ; fi ;
if [ [ $view_location = = "" ] ] ; then rm -R .blueprint/tmp/$3 ; error "'view_location' is a required option." ; fi ;
2023-04-14 11:19:15 -04:00
if [ [ $target != $VERSION ] ] ; then clr_red " This extension is built for version $target , but your version is $VERSION . " ; fi ;
2023-04-05 15:26:33 -04:00
if [ [ $identifier != $3 ] ] ; then rm -R .blueprint/tmp/$3 ; error "The extension identifier should be exactly the same as your .blueprint file (just without the .blueprint). This may be subject to change, but is currently required." ; fi ;
if [ [ $identifier = = "blueprint" ] ] ; then rm -R .blueprint/tmp/$3 ; error "The operation could not be completed since the extension is attempting to overwrite internal files." ; fi ;
2023-04-01 07:20:25 -04:00
2023-04-18 11:01:41 -04:00
if [ [ $identifier = ~ [ a-z] ] ] ; then echo "ok" ;
2023-04-05 15:26:33 -04:00
else rm -R .blueprint/tmp/$3 ; error "The extension identifier should be lowercase and only contain characters a-z." ; fi ;
2023-03-22 05:20:59 -04:00
2023-04-14 11:19:15 -04:00
if [ [ ! -f " .blueprint/tmp/ $3 / $icon " ] ] ; then rm -R .blueprint/tmp/$3 ; error "The 'icon' path points to a nonexisting file." ; fi ;
2023-04-12 11:04:15 -04:00
if [ [ $migrations_directory != "" ] ] ; then
2023-04-01 06:59:27 -04:00
if [ [ $migrations_enabled = = "yes" ] ] ; then
cp -R .blueprint/tmp/$3 /$migrations_directory /* database/migrations/ 2> /dev/null;
elif [ [ $migrations_enabled = = "no" ] ] ; then
2023-04-18 04:07:55 -04:00
echo "ok" ;
2023-03-27 14:52:24 -04:00
else
2023-03-27 15:17:57 -04:00
rm -R .blueprint/tmp/$3 ;
2023-04-17 10:11:33 -04:00
error "If defined, migrations_enabled should only be 'yes' or 'no'." ;
fi ;
fi ;
if [ [ $css_location != "" ] ] ; then
if [ [ $css_enabled = = "yes" ] ] ; then
INJECTCSS = true;
elif [ [ $css_enabled = = "no" ] ] ; then
2023-04-18 04:07:55 -04:00
echo "ok" ;
2023-04-17 10:11:33 -04:00
else
rm -R .blueprint/tmp/$3 ;
error "If defined, css_enabled should only be 'yes' or 'no'." ;
2023-03-27 14:52:24 -04:00
fi ;
2023-03-26 12:19:10 -04:00
fi ;
2023-04-12 11:04:15 -04:00
if [ [ $adminrequests_directory != "" ] ] ; then
if [ [ $adminrequests_enabled = = "yes" ] ] ; then
mkdir app/Http/Requests/Admin/Extensions/$identifier ;
cp -R .blueprint/tmp/$3 /$adminrequests_directory /* app/Http/Requests/Admin/Extensions/$identifier / 2> /dev/null;
elif [ [ $adminrequests_enabled = = "no" ] ] ; then
2023-04-18 04:07:55 -04:00
echo "ok" ;
2023-04-12 11:04:15 -04:00
else
rm -R .blueprint/tmp/$3 ;
2023-04-17 10:11:33 -04:00
error "If defined, adminrequests_enabled should only be 'yes' or 'no'." ;
2023-04-12 11:04:15 -04:00
fi ;
fi ;
2023-04-01 06:58:23 -04:00
if [ [ $publicfiles_directory != "" ] ] ; then
if [ [ $publicfiles_enabled = = "yes" ] ] ; then
2023-04-12 11:04:15 -04:00
mkdir public/extensions/$identifier ;
2023-04-01 07:25:18 -04:00
cp -R .blueprint/tmp/$3 /$publicfiles_directory /* public/extensions/$identifier / 2> /dev/null;
2023-04-01 06:58:23 -04:00
elif [ [ $publicfiles_enabled = = "no" ] ] ; then
2023-04-18 04:07:55 -04:00
echo "ok" ;
2023-03-31 07:27:57 -04:00
else
rm -R .blueprint/tmp/$3 ;
2023-04-17 10:11:33 -04:00
error "If defined, publicfiles_enabled should only be 'yes' or 'no'." ;
2023-03-31 07:27:57 -04:00
fi ;
fi ;
2023-03-26 09:19:39 -04:00
cp -R .blueprint/defaults/extensions/admin.default .blueprint/defaults/extensions/admin.default.bak 2> /dev/null;
2023-04-01 06:58:23 -04:00
if [ [ $controller_type != "" ] ] ; then
if [ [ $controller_type = = "default" ] ] ; then
2023-03-27 14:48:39 -04:00
cp -R .blueprint/defaults/extensions/controller.default .blueprint/defaults/extensions/controller.default.bak 2> /dev/null;
2023-04-01 06:58:23 -04:00
elif [ [ $controller_type = = "custom" ] ] ; then
2023-04-14 11:19:15 -04:00
echo "ok" ;
2023-03-27 14:48:39 -04:00
else
2023-03-27 15:17:57 -04:00
rm -R .blueprint/tmp/$3 ;
2023-04-17 10:11:33 -04:00
error "If defined, controller_type should only be 'default' or 'custom'." ;
2023-03-27 14:48:39 -04:00
fi ;
2023-03-26 12:19:10 -04:00
fi ;
2023-03-26 09:35:47 -04:00
cp -R .blueprint/defaults/extensions/route.default .blueprint/defaults/extensions/route.default.bak 2> /dev/null;
2023-03-26 11:24:30 -04:00
cp -R .blueprint/defaults/extensions/button.default .blueprint/defaults/extensions/button.default.bak 2> /dev/null;
2023-03-26 09:19:39 -04:00
2023-03-26 09:10:04 -04:00
mkdir public/assets/extensions/$identifier ;
2023-04-14 11:19:15 -04:00
cp .blueprint/tmp/$3 /$icon public/assets/extensions/$identifier /icon.jpg;
2023-03-26 11:24:30 -04:00
ICON = " /assets/extensions/ $identifier /icon.jpg " ;
2023-04-01 06:58:23 -04:00
CONTENT = $( cat .blueprint/tmp/$3 /$view_location ) ;
2023-03-22 05:20:59 -04:00
2023-04-17 10:11:33 -04:00
if [ [ $INJECTCSS = = true ] ] ; 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/tmp/$3 /$css_location /* public/assets/extensions/$identifier /$identifier .style.css 2> /dev/null;
fi ;
2023-04-14 11:19:15 -04:00
if [ [ $name = = *"~" * ] ] ; then clr_red "'name' contains '~' and may result in an error." ; fi ;
if [ [ $description = = *"~" * ] ] ; then clr_red "'description' contains '~' and may result in an error." ; fi ;
if [ [ $version = = *"~" * ] ] ; then clr_red "'version' contains '~' and may result in an error." ; fi ;
if [ [ $CONTENT = = *"~" * ] ] ; then clr_red "'CONTENT' contains '~' and may result in an error." ; fi ;
if [ [ $ICON = = *"~" * ] ] ; then clr_red "'ICON' contains '~' and may result in an error." ; fi ;
if [ [ $identifier = = *"~" * ] ] ; then clr_red "'identifier' contains '~' and may result in an error." ; fi ;
sed -i " s~␀title␀~ $name ~g " .blueprint/defaults/extensions/admin.default.bak;
sed -i " s~␀name␀~ $name ~g " .blueprint/defaults/extensions/admin.default.bak;
sed -i " s~␀breadcrumb␀~ $name ~g " .blueprint/defaults/extensions/admin.default.bak;
sed -i " s~␀name␀~ $name ~g " .blueprint/defaults/extensions/button.default.bak;
2023-03-26 11:24:30 -04:00
2023-04-14 11:19:15 -04:00
sed -i " s~␀description␀~ $description ~g " .blueprint/defaults/extensions/admin.default.bak;
2023-03-26 11:24:30 -04:00
2023-04-14 11:19:15 -04:00
sed -i " s~␀version␀~ $version ~g " .blueprint/defaults/extensions/admin.default.bak;
sed -i " s~␀version␀~ $version ~g " .blueprint/defaults/extensions/button.default.bak;
2023-03-26 11:24:30 -04:00
2023-04-14 11:19:15 -04:00
sed -i " s~␀icon␀~ $ICON ~g " .blueprint/defaults/extensions/admin.default.bak;
2023-03-26 11:24:30 -04:00
2023-04-14 11:19:15 -04:00
sed -i " s~␀content␀~ $CONTENT ~g " .blueprint/defaults/extensions/admin.default.bak;
2023-03-22 05:20:59 -04:00
2023-04-01 06:58:23 -04:00
if [ [ $controller_type != "custom" ] ] ; then
2023-04-14 11:19:15 -04:00
sed -i " s~␀id␀~ $identifier ~g " .blueprint/defaults/extensions/controller.default.bak;
2023-03-26 12:19:10 -04:00
fi ;
2023-04-14 11:19:15 -04:00
sed -i " s~␀id␀~ $identifier ~g " .blueprint/defaults/extensions/route.default.bak;
sed -i " s~␀id␀~ $identifier ~g " .blueprint/defaults/extensions/button.default.bak;
2023-03-26 09:19:39 -04:00
2023-03-26 09:35:47 -04:00
ADMINVIEW_RESULT = $( cat .blueprint/defaults/extensions/admin.default.bak) ;
ADMINROUTE_RESULT = $( cat .blueprint/defaults/extensions/route.default.bak) ;
2023-03-26 11:24:30 -04:00
ADMINBUTTON_RESULT = $( cat .blueprint/defaults/extensions/button.default.bak) ;
2023-04-01 06:58:23 -04:00
if [ [ $controller_type != "custom" ] ] ; then
2023-03-26 12:19:10 -04:00
ADMINCONTROLLER_RESULT = $( cat .blueprint/defaults/extensions/controller.default.bak) ;
fi ;
2023-03-26 09:27:37 -04:00
ADMINCONTROLLER_NAME = $identifier "ExtensionController.php" ;
2023-03-26 09:10:04 -04:00
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;
2023-03-22 05:20:59 -04:00
2023-03-26 09:27:37 -04:00
mkdir app/Http/Controllers/Admin/Extensions/$identifier ;
touch app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
2023-04-01 06:58:23 -04:00
if [ [ $controller_type != "custom" ] ] ; then
2023-03-26 12:19:10 -04:00
echo $ADMINCONTROLLER_RESULT > app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
2023-04-01 06:58:23 -04:00
else
2023-04-14 11:19:15 -04:00
cp .blueprint/tmp/$3 /$controller_location app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
2023-03-26 12:19:10 -04:00
fi ;
2023-03-26 09:27:37 -04:00
2023-04-12 12:10:45 -04:00
if [ [ $controller_type = = "custom" ] ] ; then
cp .blueprint/tmp/$3 /$controller_location app/Http/Controllers/Admin/Extensions/$identifier /${ identifier } ExtensionController.php;
fi ;
2023-03-26 11:24:30 -04:00
echo $ADMINROUTE_RESULT >> routes/admin.php;
2023-04-14 11:19:15 -04:00
sed -i " s~<!--␀replace␀-->~ $ADMINBUTTON_RESULT \n<!--␀replace␀-->~g " resources/views/admin/extensions.blade.php;
2023-03-26 09:35:47 -04:00
2023-03-22 05:20:59 -04:00
rm .blueprint/defaults/extensions/admin.default.bak;
2023-04-01 06:58:23 -04:00
if [ [ $controller_type != "custom" ] ] ; then
2023-03-26 12:19:10 -04:00
rm .blueprint/defaults/extensions/controller.default.bak;
fi ;
2023-03-26 09:35:47 -04:00
rm .blueprint/defaults/extensions/route.default.bak;
2023-03-26 11:24:30 -04:00
rm .blueprint/defaults/extensions/button.default.bak;
2023-03-22 05:47:43 -04:00
rm -R .blueprint/tmp/$3 ;
2023-03-27 15:17:57 -04:00
if [ [ $author = = "blueprint" ] ] ; then clr_blue "Please refrain from setting the author variable to 'blueprint', thanks!" ; fi ;
if [ [ $author = = "Blueprint" ] ] ; then clr_blue "Please refrain from setting the author variable to 'Blueprint', thanks!" ; fi ;
2023-04-10 11:13:28 -04:00
2023-04-23 11:24:23 -04:00
if [ [ -f ".blueprint/.flags/onboarding.md" ] ] ; then
clr_green "Congratulations on installing your first extension! We'll now automatically disable onboarding for you." ;
rm .blueprint/.flags/onboarding.md;
fi ;
2023-04-10 11:13:28 -04:00
clr_blue " \n\n $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-03-23 06:54:40 -04:00
if [ [ $2 = = "help" ] ] ; then
2023-04-10 11:15:23 -04:00
echo -e "-i [name] | install a blueprint extension\n-v | get the current blueprint version\n-reinstall | rerun the blueprint installation script" ;
2023-03-27 15:17:57 -04:00
fi ;
2023-04-02 15:12:21 -04:00
if [ [ ( $2 = = "-v" ) || ( $2 = = "-version" ) ] ] ; then
2023-03-27 15:17:57 -04:00
echo -e $VERSION ;
2023-04-10 10:50:23 -04:00
fi ;
if [ [ $2 = = "-reinstall" ] ] ; then
dbRemove "blueprint.setupFinished" ;
cd /var/www/pterodactyl;
bash blueprint.sh;
2023-04-10 14:12:31 -04:00
fi ;