2023-03-03 10:52:29 -05:00
#!/bin/bash
2023-03-22 09:04:03 -04:00
VERSION = "indev" ;
2023-03-06 13:11:53 -05:00
cd /var/www/pterodactyl;
2023-03-23 06:54:40 -04:00
if [ [ " $@ " = = *"-php" * ] ] ; then
2023-03-08 04:44:53 -05:00
exit 1;
fi ;
2023-03-19 16:02:29 -04:00
mkdir .blueprint 2> /dev/null;
cp -R blueprint/* .blueprint/ 2> /dev/null;
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-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-03 11:00:03 -05:00
dbRemove "blueprint.setupFinished" ;
2023-03-22 05:20:59 -04:00
exit 1;
2023-03-03 10:52:29 -05:00
else
2023-03-19 16:02:29 -04:00
clr_bright "/var/www/pterodactyl/public/themes/pterodactyl/css/pterodactyl.css" ;
2023-03-17 10:47:28 -04:00
sed -i "s!@import 'checkbox.css';!@import 'checkbox.css';\n@import url(/assets/extensions/blueprint/blueprint.style.css);!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-03-06 13:11:53 -05:00
php artisan view:clear > /dev/null;
2023-03-08 12:35:54 -05:00
2023-03-19 16:02:29 -04:00
clr_bright "php artisan config:clear" ;
2023-03-06 13:11:53 -05:00
php artisan config:clear > /dev/null;
2023-03-08 12:35:54 -05:00
2023-03-19 16:02:29 -04:00
clr_bright "chown -R www-data:www-data /var/www/pterodactyl/*" ;
2023-03-06 13:11:53 -05:00
chown -R www-data:www-data /var/www/pterodactyl/* > /dev/null;
2023-03-19 16:02:29 -04:00
clr_bright "chown -R www-data:www-data /var/www/pterodactyl/.*" ;
2023-03-19 15:20:01 -04:00
chown -R www-data:www-data /var/www/pterodactyl/.* > /dev/null;
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-03-23 06:54:40 -04:00
if [ [ $2 = = "-i" ] ] ; then
2023-03-27 15:17:57 -04:00
if [ [ $3 = = "" ] ] ; then clr_bright "Expected 1 argument but got 0." ; fi ;
2023-03-22 05:20:59 -04:00
FILE = $3 ".blueprint"
2023-03-27 15:17:57 -04:00
if [ [ ! -f " $FILE " ] ] ; then clr_red " $FILE could not be found. " ; exit 1; fi ;
2023-03-22 05:20:59 -04:00
ZIP = $3 ".zip"
cp $FILE .blueprint/tmp/$ZIP ;
2023-03-22 05:47:43 -04:00
cd .blueprint/tmp;
unzip $ZIP ;
cd /var/www/pterodactyl;
2023-03-22 05:20:59 -04:00
rm .blueprint/tmp/$ZIP ;
2023-03-27 15:17:57 -04:00
VERSION______BACKUP = $VERSION ;
ZIP______BACKUP = $VERSION ;
FILE______BACKUP = $VERSION ;
2023-03-27 14:52:24 -04:00
eval $( parse_yaml .blueprint/tmp/$3 /conf.yml) #documentation.ptero.shop/documentation/conf.yml
2023-03-27 15:17:57 -04:00
if [ [ $VERSION______BACKUP != $VERSION ] ] ; then clr_red "Tampering with local variables detected." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $ZIP______BACKUP != $ZIP ] ] ; then clr_red "Tampering with local variables detected." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $FILE______BACKUP != $FILE ] ] ; then clr_red "Tampering with local variables detected." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $name = = "" ] ] ; then clr_red "'name' is a required option." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $identifier = = "" ] ] ; then clr_red "'identifier' is a required option." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $description = = "" ] ] ; then clr_red "'description' is a required option." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $version = = "" ] ] ; then clr_red "'version' is a required option." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $target = = "" ] ] ; then clr_red "'target' is a required option." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ ! -f " .blueprint/tmp/ $3 /icon.jpg " ] ] ; then clr_red "This extension is currently missing an icon." ; fi ;
if [ [ $target != $VERSION ] ] ; then clr_red " The operation could not be completed since the target version of the extension ( $target ) does not match your Blueprint version ( $VERSION ). " ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $identifier != $3 ] ] ; then clr_red "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." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
if [ [ $identifier = = "blueprint" ] ] ; then clr_red "The operation could not be completed since the extension is attempting to overwrite internal files." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
# HAS NOT BEEN FULLY TESTED YET
if [ [ " $identifier " != [ a-z] ] ] ; then clr_red "The extension identifier should be lowercase and only contain characters a-z." ; rm -R .blueprint/tmp/$3 ; exit 1; fi ;
2023-03-22 05:20:59 -04:00
2023-03-27 14:52:24 -04:00
if [ [ $migrations != "" ] ] ; then
# HAS NOT BEEN FULLY TESTED YET
if [ [ $migrations = = "yes" ] ] ; then
cp -R .blueprint/tmp/$3 /migrations/* database/migrations/ 2> /dev/null;
elif [ [ $migrations = = "no" ] ] ; then
echo "ok" > /dev/null;
else
clr_red "If defined, migrations should only be 'yes' or 'no'." ;
2023-03-27 15:17:57 -04:00
rm -R .blueprint/tmp/$3 ;
2023-03-27 14:52:24 -04:00
exit 1;
fi ;
2023-03-26 12:19:10 -04:00
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-03-27 14:48:39 -04:00
if [ [ $controller != "" ] ] ; then
# HAS NOT BEEN FULLY TESTED YET
if [ [ $controller = = "default" ] ] ; then
cp -R .blueprint/defaults/extensions/controller.default .blueprint/defaults/extensions/controller.default.bak 2> /dev/null;
elif [ [ $controller = = "custom" ] ] ; then
echo "ok" > /dev/null;
else
clr_red "If defined, controller should only be 'default' or 'custom'." ;
2023-03-27 15:17:57 -04:00
rm -R .blueprint/tmp/$3 ;
2023-03-27 14:48:39 -04:00
exit 1;
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 ;
cp .blueprint/tmp/$3 /icon.jpg public/assets/extensions/$identifier /icon.jpg;
2023-03-26 11:24:30 -04:00
ICON = " /assets/extensions/ $identifier /icon.jpg " ;
2023-03-22 09:20:31 -04:00
CONTENT = $( cat .blueprint/tmp/$3 /admin/index.blade.php) ;
2023-03-22 05:20:59 -04:00
2023-03-26 09:35:47 -04:00
sed -i " s!␀title␀! $name !g " .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i " s!␀name␀! $name !g " .blueprint/defaults/extensions/admin.default.bak > /dev/null;
sed -i " s!␀breadcrumb␀! $name !g " .blueprint/defaults/extensions/admin.default.bak > /dev/null;
2023-03-26 11:24:30 -04:00
sed -i " s?␀name␀? $name ?g " .blueprint/defaults/extensions/button.default.bak > /dev/null;
2023-03-26 09:35:47 -04:00
sed -i " s!␀description␀! $description !g " .blueprint/defaults/extensions/admin.default.bak > /dev/null;
2023-03-26 11:24:30 -04:00
2023-03-26 09:35:47 -04:00
sed -i " s!␀version␀! $version !g " .blueprint/defaults/extensions/admin.default.bak > /dev/null;
2023-03-26 11:24:30 -04:00
sed -i " s?␀version␀? $version ?g " .blueprint/defaults/extensions/button.default.bak > /dev/null;
2023-03-26 09:35:47 -04:00
sed -i " s!␀icon␀! $ICON !g " .blueprint/defaults/extensions/admin.default.bak > /dev/null;
2023-03-26 11:24:30 -04:00
2023-03-26 09:35:47 -04:00
sed -i " s!␀content␀! $CONTENT !g " .blueprint/defaults/extensions/admin.default.bak > /dev/null;
2023-03-22 05:20:59 -04:00
2023-03-26 12:19:10 -04:00
if [ [ $controller != "custom" ] ] ; then
sed -i " s!␀id␀! $identifier !g " .blueprint/defaults/extensions/controller.default.bak > /dev/null;
fi ;
2023-03-26 09:35:47 -04:00
sed -i " s!␀id␀! $identifier !g " .blueprint/defaults/extensions/route.default.bak > /dev/null;
2023-03-26 11:24:30 -04:00
sed -i " s?␀id␀? $identifier ?g " .blueprint/defaults/extensions/button.default.bak > /dev/null;
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-03-26 12:19:10 -04:00
if [ [ $controller != "custom" ] ] ; then
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-03-26 12:19:10 -04:00
if [ [ $controller != "custom" ] ] ; then
echo $ADMINCONTROLLER_RESULT > app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
fi ;
if [ [ $controller = = "custom" ] ] ; then
echo $( cat .blueprint/tmp/$3 /admin/indexController.php) > app/Http/Controllers/Admin/Extensions/$identifier /$ADMINCONTROLLER_NAME ;
fi ;
2023-03-26 09:27:37 -04:00
2023-03-26 11:24:30 -04:00
echo $ADMINROUTE_RESULT >> routes/admin.php;
sed -i " s?<!--␀replace␀-->? $ADMINBUTTON_RESULT \n<!--␀replace␀-->?g " resources/views/admin/extensions.blade.php > /dev/null;
2023-03-26 09:35:47 -04:00
2023-03-22 05:20:59 -04:00
rm .blueprint/defaults/extensions/admin.default.bak;
2023-03-26 12:19:10 -04:00
if [ [ $controller != "custom" ] ] ; then
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-03-22 05:20:59 -04:00
fi ;
2023-03-19 16:02:29 -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 [ [ $2 = = "help" ] ] ; then
2023-03-27 15:17:57 -04:00
echo -e "placeholder" ;
fi ;
if [ [ $2 = = "-v" ] ] ; then
echo -e $VERSION ;
2023-03-18 06:24:16 -04:00
fi ;