2023-03-03 10:52:29 -05:00
#!/bin/bash
2023-11-28 12:31:26 -05:00
# blueprint.zip
2023-06-26 08:42:31 -04:00
# github.com/teamblueprint/main
# prpl.wtf
2023-08-11 18:00:23 -04:00
# This should allow Blueprint to run in Docker. Please note that changing the $FOLDER variable after running
2023-05-06 10:31:31 -04:00
# the Blueprint installation script will not change anything in any files besides blueprint.sh.
2023-08-31 12:00:27 -04:00
FOLDER = "/var/www/pterodactyl" #;
2023-05-06 10:21:22 -04:00
2024-02-24 09:11:01 -05:00
# This stores the webserver ownership user which Blueprint uses when applying webserver permissions.
OWNERSHIP = "www-data:www-data" #;
2023-11-23 10:03:03 -05:00
# If the version below does not match your downloaded version, please let us know.
2024-02-22 16:16:33 -05:00
VERSION = "beta-316A3"
2023-08-27 10:01:36 -04:00
2023-08-31 12:13:44 -04:00
# Allow non-default Pterodactyl installation folders.
if [ [ $_FOLDER != "" ] ] ; then
2023-11-08 10:01:39 -05:00
if [ [ ( ! -f " $FOLDER /.blueprint/extensions/blueprint/private/db/version " ) && ( $FOLDER = = "/var/www/pterodactyl" ) ] ] ; then
2023-12-22 11:51:20 -05:00
sed -i -E " s|FOLDER=\"/var/www/pterodactyl\" #;|FOLDER=\" $_FOLDER \" #;|g " " $_FOLDER " /blueprint.sh
2023-08-31 12:19:27 -04:00
else
echo "Variable cannot be replaced right now."
2024-01-15 11:40:12 -05:00
exit 2
2023-08-31 12:19:27 -04:00
fi
2023-08-31 12:13:44 -04:00
fi
2023-12-15 13:43:57 -05:00
# Check for panels that are using Docker, which should have better support in the future.
2023-11-28 11:40:08 -05:00
if [ [ -f "/.dockerenv" ] ] ; then
2023-08-15 06:23:40 -04:00
DOCKER = "y"
2023-07-04 08:28:19 -04:00
else
2023-08-15 06:23:40 -04:00
DOCKER = "n"
fi
2023-05-06 10:21:22 -04:00
2023-08-15 06:23:40 -04:00
if [ [ -d " $FOLDER /blueprint " ] ] ; then mv $FOLDER /blueprint $FOLDER /.blueprint; fi
2023-04-25 13:33:21 -04:00
2023-11-23 10:03:03 -05:00
if [ [ $VERSION != "" ] ] ; then
# This function makes sure some placeholders get replaced with the current Blueprint version.
2023-11-08 10:01:39 -05:00
if [ [ ! -f " $FOLDER /.blueprint/extensions/blueprint/private/db/version " ] ] ; then
2024-01-01 12:09:04 -05:00
sed -E -i " s*::v* $VERSION *g " $FOLDER /app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php
sed -E -i " s*::v* $VERSION *g " $FOLDER /.blueprint/extensions/blueprint/public/index.html
2023-11-08 10:01:39 -05:00
touch $FOLDER /.blueprint/extensions/blueprint/private/db/version
2023-08-15 06:23:40 -04:00
fi
fi
2023-04-24 10:43:31 -04:00
2023-10-31 10:35:14 -04:00
# Write environment variables.
export BLUEPRINT__FOLDER = $FOLDER
export BLUEPRINT__VERSION = $VERSION
2023-12-22 10:06:02 -05:00
export BLUEPRINT__DEBUG = " $FOLDER " /.blueprint/extensions/blueprint/private/debug/logs.txt
2023-11-01 09:51:42 -04:00
export NODE_OPTIONS = --openssl-legacy-provider
2023-08-15 06:23:40 -04:00
# Automatically navigate to the Pterodactyl directory when running the core.
2023-11-23 09:52:16 -05:00
cd $FOLDER || return
2023-05-09 11:59:12 -04:00
2023-06-18 10:37:46 -04:00
# Import libraries.
2024-01-31 14:23:22 -05:00
source .blueprint/lib/parse_yaml.sh || missinglibs += "[parse_yaml]"
source .blueprint/lib/grabenv.sh || missinglibs += "[grabenv]"
source .blueprint/lib/logFormat.sh || missinglibs += "[logFormat]"
source .blueprint/lib/misc.sh || missinglibs += "[misc]"
2023-03-03 10:52:29 -05:00
2023-08-06 07:41:56 -04:00
2023-07-16 14:22:59 -04:00
# -config
# usage: "cITEM=VALUE bash blueprint.sh -config"
if [ [ " $1 " = = "-config" ] ] ; then
2023-06-27 15:49:11 -04:00
2023-07-16 14:22:59 -04:00
# cTELEMETRY_ID
# Update the telemetry id.
2023-12-17 06:51:06 -05:00
if [ [ " $cTELEMETRY_ID " != "" ] ] ; then
2023-11-08 10:01:39 -05:00
echo " $cTELEMETRY_ID " > .blueprint/extensions/blueprint/private/db/telemetry_id
2023-08-15 06:23:40 -04:00
fi
2023-06-27 15:49:11 -04:00
2023-08-07 09:50:54 -04:00
# cDEVELOPER
# Enable/Disable developer mode.
2023-12-17 06:51:06 -05:00
if [ [ " $cDEVELOPER " != "" ] ] ; then
if [ [ " $cDEVELOPER " = = "true" ] ] ; then
2023-11-01 09:51:42 -04:00
dbAdd "blueprint.developerEnabled"
else
dbRemove "blueprint.developerEnabled"
fi
2023-08-15 06:23:40 -04:00
fi
2023-08-07 09:50:54 -04:00
2023-08-15 06:23:40 -04:00
echo .
2024-01-15 11:40:12 -05:00
exit 0
2023-08-15 06:23:40 -04:00
fi
2023-04-23 15:23:15 -04:00
2024-01-15 17:59:30 -05:00
cdhalt( ) { PRINT FATAL "Attempted navigation into nonexistent directory, halting process." ; exit 1; }
2023-08-06 07:41:56 -04:00
2023-04-05 15:26:33 -04:00
2023-07-31 05:14:32 -04:00
depend( ) {
2023-09-11 10:29:38 -04:00
# Check for incorrect node version.
nodeVer = $( node -v)
2024-01-15 16:09:31 -05:00
if [ [ $nodeVer != "v17." * ] ] \
&& [ [ $nodeVer != "v18." * ] ] \
&& [ [ $nodeVer != "v19." * ] ] \
&& [ [ $nodeVer != "v20." * ] ] \
&& [ [ $nodeVer != "v21." * ] ] ; then
DEPEND_MISSING = true
fi
2023-09-11 10:29:38 -04:00
2023-12-22 08:31:31 -05:00
# Check for required (both internal and external) dependencies.
if \
! [ -x " $( command -v unzip) " ] || # unzip
! [ -x " $( command -v node) " ] || # node
! [ -x " $( command -v yarn) " ] || # yarn
! [ -x " $( command -v zip) " ] || # zip
! [ -x " $( command -v curl) " ] || # curl
! [ -x " $( command -v php) " ] || # php
! [ -x " $( command -v git) " ] || # git
! [ -x " $( command -v grep) " ] || # grep
! [ -x " $( command -v sed) " ] || # sed
! [ -x " $( command -v awk) " ] || # awk
! [ " $( ls "node_modules/" *"cross-env" * 2> /dev/null) " ] || # cross-env
2024-01-09 05:27:13 -05:00
! [ " $( ls "node_modules/" *"webpack" * 2> /dev/null) " ] || # webpack
2024-01-09 05:29:02 -05:00
! [ " $( ls "node_modules/" *"react" * 2> /dev/null) " ] || # react
2023-12-22 08:31:31 -05:00
[ [ $missinglibs != "" ] ] ; then # internal
DEPEND_MISSING = true
fi
2023-08-18 12:29:01 -04:00
# Exit when missing dependencies.
2023-09-11 10:23:49 -04:00
if [ [ $DEPEND_MISSING = = true ] ] ; then
2024-01-14 18:43:11 -05:00
PRINT FATAL "Some framework dependencies are not installed or detected."
2023-09-11 10:23:49 -04:00
2024-01-15 16:09:31 -05:00
if [ [ $nodeVer != "v18." * ] ] \
&& [ [ $nodeVer != "v19." * ] ] \
&& [ [ $nodeVer != "v20." * ] ] \
&& [ [ $nodeVer != "v21." * ] ] ; then
PRINT FATAL "Required dependency \"node\" is using an unsupported version."
fi
2023-12-22 08:31:31 -05:00
2024-01-14 18:43:11 -05:00
if ! [ -x " $( command -v unzip) " ] ; then PRINT FATAL "Required dependency \"unzip\" is not installed or detected." ; fi
if ! [ -x " $( command -v node) " ] ; then PRINT FATAL "Required dependency \"node\" is not installed or detected." ; fi
if ! [ -x " $( command -v yarn) " ] ; then PRINT FATAL "Required dependency \"yarn\" is not installed or detected." ; fi
if ! [ -x " $( command -v zip) " ] ; then PRINT FATAL "Required dependency \"zip\" is not installed or detected." ; fi
if ! [ -x " $( command -v curl) " ] ; then PRINT FATAL "Required dependency \"curl\" is not installed or detected." ; fi
if ! [ -x " $( command -v php) " ] ; then PRINT FATAL "Required dependency \"php\" is not installed or detected." ; fi
if ! [ -x " $( command -v git) " ] ; then PRINT FATAL "Required dependency \"git\" is not installed or detected." ; fi
if ! [ -x " $( command -v grep) " ] ; then PRINT FATAL "Required dependency \"grep\" is not installed or detected." ; fi
if ! [ -x " $( command -v sed) " ] ; then PRINT FATAL "Required dependency \"sed\" is not installed or detected." ; fi
if ! [ -x " $( command -v awk) " ] ; then PRINT FATAL "Required dependency \"awk\" is not installed or detected." ; fi
if ! [ " $( ls "node_modules/" *"cross-env" * 2> /dev/null) " ] ; then PRINT FATAL "Required dependency \"cross-env\" is not installed or detected." ; fi
if ! [ " $( ls "node_modules/" *"webpack" * 2> /dev/null) " ] ; then PRINT FATAL "Required dependency \"webpack\" is not installed or detected." ; fi
if ! [ " $( ls "node_modules/" *"react" * 2> /dev/null) " ] ; then PRINT FATAL "Required dependency \"react\" is not installed or detected." ; fi
if [ [ $missinglibs = = *"[parse_yaml]" * ] ] ; then PRINT FATAL "Required internal dependency \"internal:parse_yaml\" is not installed or detected." ; fi
if [ [ $missinglibs = = *"[grabEnv]" * ] ] ; then PRINT FATAL "Required internal dependency \"internal:grabEnv\" is not installed or detected." ; fi
if [ [ $missinglibs = = *"[logFormat]" * ] ] ; then PRINT FATAL "Required internal dependency \"internal:logFormat\" is not installed or detected." ; fi
2024-01-15 17:59:30 -05:00
if [ [ $missinglibs = = *"[misc]" * ] ] ; then PRINT FATAL "Required internal dependency \"internal:misc\" is not installed or detected." ; fi
2023-09-11 10:29:38 -04:00
exit 1
2023-09-11 10:23:49 -04:00
fi
2023-07-31 05:14:32 -04:00
}
2023-12-11 09:33:33 -05:00
# Assign variables for extension flags.
assignflags( ) {
F_ignorePlaceholders = false
F_ignoreAlphabetPlaceholders = false
F_hasInstallScript = false
F_hasRemovalScript = false
F_hasExportScript = false
F_developerIgnoreInstallScript = false
2023-12-11 09:56:05 -05:00
F_developerIgnoreRebuild = false
2023-12-11 09:33:33 -05:00
if [ [ ( $flags = = *"ignorePlaceholders," * ) || ( $flags = = *"ignorePlaceholders" ) ] ] ; then F_ignorePlaceholders = true ; fi
if [ [ ( $flags = = *"ignoreAlphabetPlaceholders," * ) || ( $flags = = *"ignoreAlphabetPlaceholders" ) ] ] ; then F_ignoreAlphabetPlaceholders = true ; fi
if [ [ ( $flags = = *"hasInstallScript," * ) || ( $flags = = *"hasInstallScript" ) ] ] ; then F_hasInstallScript = true ; fi
if [ [ ( $flags = = *"hasRemovalScript," * ) || ( $flags = = *"hasRemovalScript" ) ] ] ; then F_hasRemovalScript = true ; fi
if [ [ ( $flags = = *"hasExportScript," * ) || ( $flags = = *"hasExportScript" ) ] ] ; then F_hasExportScript = true ; fi
if [ [ ( $flags = = *"developerIgnoreInstallScript," * ) || ( $flags = = *"developerIgnoreInstallScript" ) ] ] ; then F_developerIgnoreInstallScript = true ; fi
2023-12-11 09:56:05 -05:00
if [ [ ( $flags = = *"developerIgnoreRebuild," * ) || ( $flags = = *"developerIgnoreRebuild" ) ] ] ; then F_developerIgnoreRebuild = true ; fi
2023-12-11 09:33:33 -05:00
}
2023-08-06 07:41:56 -04:00
2023-06-18 10:37:46 -04:00
# Adds the "blueprint" command to the /usr/local/bin directory and configures the correct permissions for it.
2024-01-31 14:23:22 -05:00
{
touch /usr/local/bin/blueprint
chmod u+x \
$FOLDER /blueprint.sh \
/usr/local/bin/blueprint
} >> $BLUEPRINT__DEBUG
2023-08-15 06:23:40 -04:00
echo -e " #!/bin/bash\nbash $FOLDER /blueprint.sh -bash \$@; " > /usr/local/bin/blueprint
2023-04-02 14:47:24 -04:00
2023-08-06 07:41:56 -04:00
2023-03-23 06:54:40 -04:00
if [ [ $1 != "-bash" ] ] ; then
2023-06-02 10:37:38 -04:00
if dbValidate "blueprint.setupFinished" ; then
2024-01-14 18:43:11 -05:00
PRINT FATAL "Installation process has already been finished before, consider using the 'blueprint' command."
2024-01-15 11:40:12 -05:00
exit 2
2023-06-02 10:37:38 -04:00
else
2023-06-26 06:40:33 -04:00
# Only run if Blueprint is not in the process of upgrading.
2023-06-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
2024-01-21 15:16:32 -05:00
echo -e " ██\n██ ██\n ████\n" ; # Blueprint "ascii" "logo".
2023-06-10 08:52:00 -04:00
if [ [ $DOCKER = = "y" ] ] ; then
2024-01-14 18:52:51 -05:00
PRINT WARNING "Docker is untested and you might run into issues."
2023-08-15 06:23:40 -04:00
fi
fi
2023-05-06 10:21:22 -04:00
2024-01-14 18:43:11 -05:00
PRINT INFO "Searching and validating framework dependencies.."
2023-07-30 06:13:53 -04:00
# Check if required programs are installed
2023-08-15 06:23:40 -04:00
depend
2023-07-30 06:13:53 -04:00
2023-11-08 05:35:18 -05:00
# Link directories.
2024-01-14 18:43:11 -05:00
PRINT INFO "Linking directories and filesystems.."
2024-01-15 17:59:30 -05:00
cd $FOLDER /public/extensions || cdhalt; ln -s -T $FOLDER /.blueprint/extensions/blueprint/public blueprint 2>> $BLUEPRINT__DEBUG ; cd $FOLDER || cdhalt
cd $FOLDER /public/assets/extensions || cdhalt; ln -s -T $FOLDER /.blueprint/extensions/blueprint/assets blueprint 2>> $BLUEPRINT__DEBUG ; cd $FOLDER || cdhalt
2024-01-14 18:43:11 -05:00
php artisan storage:link & >> $BLUEPRINT__DEBUG
2023-11-08 05:35:18 -05:00
2024-01-14 18:43:11 -05:00
PRINT INFO "Replacing internal placeholders.."
2023-06-26 06:40:33 -04:00
# Update folder placeholder on PlaceholderService and admin layout.
2024-01-01 12:09:04 -05:00
sed -i " s!::f! $FOLDER !g " $FOLDER /app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php
2024-02-17 15:38:10 -05:00
sed -i " s!::f! $FOLDER !g " $FOLDER /resources/views/blueprint/admin/admin.blade.php
2023-07-04 04:37:31 -04:00
# Copy "Blueprint" extension page logo from assets.
2023-11-08 10:01:39 -05:00
cp $FOLDER /.blueprint/assets/logo.jpg $FOLDER /.blueprint/extensions/blueprint/assets/logo.jpg
2023-07-04 04:37:31 -04:00
2023-06-17 07:28:26 -04:00
# Put application into maintenance.
2024-01-14 18:43:11 -05:00
PRINT INFO "Put application into maintenance mode."
2023-12-22 10:06:02 -05:00
php artisan down & >> $BLUEPRINT__DEBUG
2023-04-10 10:50:23 -04:00
2024-01-15 12:34:11 -05:00
# Flush cache.
PRINT INFO "Flushing view, config and route cache.."
2024-01-14 18:43:11 -05:00
{
php artisan view:clear
php artisan config:clear
php artisan route:cache
2024-02-13 09:06:17 -05:00
php artisan cache:clear
2024-01-14 18:43:11 -05:00
} & >> $BLUEPRINT__DEBUG
2023-08-15 06:23:40 -04:00
updateCacheReminder
2023-08-11 15:50:34 -04:00
2023-06-17 07:28:26 -04:00
# Run migrations if Blueprint is not upgrading.
2023-06-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
2024-01-14 18:43:11 -05:00
PRINT INPUT "Would you like to migrate your database? (Y/n)"
2023-10-10 15:28:42 -04:00
read -r YN
2023-09-24 09:58:26 -04:00
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] ; then
2024-01-14 18:43:11 -05:00
PRINT INFO "Running database migrations.."
2023-08-17 05:44:09 -04:00
php artisan migrate --force
else
2024-01-14 18:43:11 -05:00
PRINT INFO "Database migrations have been skipped."
2023-08-17 05:44:09 -04:00
fi
2023-08-15 06:23:40 -04:00
fi
2023-04-08 10:14:36 -04:00
2023-06-26 06:40:33 -04:00
# Make sure all files have correct permissions.
2024-01-14 18:43:11 -05:00
PRINT INFO "Changing Pterodactyl file ownership to 'www-data'.."
2024-02-24 09:11:01 -05:00
chown -R $OWNERSHIP \
2024-01-31 14:23:22 -05:00
$FOLDER /.blueprint/* \
$FOLDER /app/* \
$FOLDER /config/* \
$FOLDER /database/* \
$FOLDER /public/* \
$FOLDER /resources/* \
$FOLDER /routes/* \
$FOLDER /storage/*
2023-03-06 13:11:53 -05:00
2023-07-29 06:29:18 -04:00
# Rebuild panel assets.
2024-01-14 18:43:11 -05:00
PRINT INFO "Rebuilding panel assets.."
2024-02-18 11:17:01 -05:00
yarn run build:production --progress
2023-07-29 06:29:18 -04:00
2023-06-17 07:28:26 -04:00
# Put application into production.
2024-01-14 18:43:11 -05:00
PRINT INFO "Put application into production."
2023-12-22 10:06:02 -05:00
php artisan up & >> $BLUEPRINT__DEBUG
2023-03-19 15:20:01 -04:00
2023-11-14 09:20:54 -05:00
# Sync some database values.
2024-01-14 18:43:11 -05:00
PRINT INFO "Syncing Blueprint-related database values.."
2023-11-14 09:20:54 -05:00
php artisan bp:sync
2024-01-14 18:43:11 -05:00
# Finish installation
2023-06-10 08:52:00 -04:00
if [ [ $1 != "--post-upgrade" ] ] ; then
2024-01-15 11:40:12 -05:00
PRINT SUCCESS "Blueprint has completed it's installation process."
2023-08-15 06:23:40 -04:00
fi
2023-04-10 11:13:28 -04:00
2023-08-15 06:23:40 -04:00
dbAdd "blueprint.setupFinished"
2023-07-09 01:47:40 -04:00
# Let the panel know the user has finished installation.
2023-09-07 10:17:04 -04:00
sed -i "s!NOTINSTALLED!INSTALLED!g" $FOLDER /app/BlueprintFramework/Services/PlaceholderService/BlueprintPlaceholderService.php
2023-08-15 06:23:40 -04:00
exit 1
fi
fi
2023-03-19 15:20:01 -04:00
2023-08-06 07:41:56 -04:00
2024-01-31 13:36:44 -05:00
# help, -help, --help,
# h, -h, --h
if [ [ ( $2 = = "help" ) || ( $2 = = "-help" ) || ( $2 = = "--help" ) ||
( $2 = = "h" ) || ( $2 = = "-h" ) || ( $2 = = "--h" ) || ( $2 = = "" ) ] ] ; then VCMD = "y"
if dbValidate "blueprint.developerEnabled" ; then
help_dev_status = ""
help_dev_primary = "\e[34;1m"
help_dev_secondary = "\e[34m"
else
help_dev_status = " (disabled)"
help_dev_primary = "\x1b[2;1m"
help_dev_secondary = "\x1b[2m"
fi
echo -e "
\x 1b[ 34; 1mExtensions\x 1b[ 0m\x 1b[ 34m
2024-02-14 02:21:09 -05:00
-install [ name] -add -i install/update a blueprint extension
-remove [ name] -r remove a blueprint extension
2024-01-31 13:36:44 -05:00
\x 1b[ 0m
${ help_dev_primary } Developer${ help_dev_status } \x 1b[ 0m${ help_dev_secondary }
2024-02-14 02:21:09 -05:00
-init -I initialize development files
-build -b install/update your development files
-export ( expose) -e export/download your development files
-wipe -w remove your development files
2024-01-31 13:36:44 -05:00
\x 1b[ 0m
\x 1b[ 34; 1mMisc\x 1b[ 0m\x 1b[ 34m
2024-02-14 02:21:09 -05:00
-version -v returns the blueprint version
-help -h displays this menu
-info -f show neofetch-like information about blueprint
-debug [ lines] print given amount of debug lines
2024-01-31 13:36:44 -05:00
\x 1b[ 0m
\x 1b[ 34; 1mAdvanced\x 1b[ 0m\x 1b[ 34m
2024-02-14 02:21:09 -05:00
-upgrade ( dev) update/reset to a newer/development version
-rerun-install rerun the blueprint installation script
2024-01-31 13:36:44 -05:00
\x 1b[ 0m
"
fi
2024-02-14 02:21:09 -05:00
# -i, -install, -add
if [ [ ( $2 = = "-i" ) || ( $2 = = "-install" ) || ( $2 = = "-add" ) ] ] ; then VCMD = "y"
2024-01-15 11:40:12 -05:00
if [ [ $(( $# - 2 )) != 1 ] ] ; then PRINT FATAL " Expected 1 argument but got $(( $# - 2 )) . " ; exit 2; fi
if [ [ ( $3 = = "./" * ) || ( $3 = = "../" * ) || ( $3 = = "/" * ) ] ] ; then PRINT FATAL "Cannot import extensions from external paths." ; exit 2; fi
2023-08-10 05:40:26 -04:00
2024-01-14 18:43:11 -05:00
PRINT INFO "Searching and validating framework dependencies.."
2023-07-30 06:13:53 -04:00
# Check if required programs are installed
2023-08-15 06:23:40 -04:00
depend
2023-07-30 06:13:53 -04:00
2023-09-05 12:46:43 -04:00
# The following code does some magic to allow for extensions with a
# different root folder structure than expected by Blueprint.
2024-02-08 12:45:14 -05:00
if [ [ $3 = = "[developer-build]" ] ] ; then
2023-08-15 06:23:40 -04:00
dev = true
n = "dev"
2023-10-31 05:38:52 -04:00
mkdir -p ".blueprint/tmp/dev"
cp -R ".blueprint/dev/" * ".blueprint/tmp/dev/"
2023-06-02 10:37:38 -04:00
else
2023-08-15 06:23:40 -04:00
dev = false
2023-10-31 05:38:52 -04:00
n = " $3 "
FILE = " ${ n } .blueprint "
2024-02-14 02:22:50 -05:00
if [ [ ( $FILE = = *".blueprint.blueprint" ) && ( $n = = *".blueprint" ) ] ] ; then PRINT FATAL "Argument one must not end with '.blueprint'." ; exit 2; fi
2024-01-15 11:40:12 -05:00
if [ [ ! -f " $FILE " ] ] ; then PRINT FATAL " $FILE could not be found or detected. " ; exit 2; fi
2023-08-15 06:23:40 -04:00
2023-10-31 05:38:52 -04:00
ZIP = " ${ n } .zip "
cp " $FILE " " .blueprint/tmp/ $ZIP "
2024-01-15 17:59:30 -05:00
cd ".blueprint/tmp" || cdhalt
2023-10-31 05:38:52 -04:00
unzip -o -qq " $ZIP "
rm " $ZIP "
2023-06-02 10:37:38 -04:00
if [ [ ! -f " $n /* " ] ] ; then
2024-01-15 17:59:30 -05:00
cd ".." || cdhalt
2023-10-31 05:38:52 -04:00
rm -R "tmp"
mkdir -p "tmp"
2024-01-15 17:59:30 -05:00
cd "tmp" || cdhalt
2023-10-31 05:38:52 -04:00
mkdir -p " ./ $n "
cp " ../../ $FILE " " ./ $n / $ZIP "
2024-01-15 17:59:30 -05:00
cd " $n " || cdhalt
2023-10-31 05:38:52 -04:00
unzip -o -qq " $ZIP "
rm " $ZIP "
2024-01-15 17:59:30 -05:00
cd ".." || cdhalt
2023-08-15 06:23:40 -04:00
fi
fi
2023-04-17 10:54:12 -04:00
2023-06-18 10:37:46 -04:00
# Return to the Pterodactyl installation folder.
2024-01-15 17:59:30 -05:00
cd $FOLDER || cdhalt
2023-03-22 05:20:59 -04:00
2023-06-17 07:28:26 -04:00
# Get all strings from the conf.yml file and make them accessible as variables.
2023-10-21 14:05:48 -04:00
if [ [ ! -f " .blueprint/tmp/ $n /conf.yml " ] ] ; then
# Quit if the extension doesn't have a conf.yml file.
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 15:39:39 -05:00
PRINT FATAL "Extension configuration file not found or detected."
exit 1
2023-10-21 14:05:48 -04:00
fi
2023-11-23 09:52:16 -05:00
2023-12-22 07:15:54 -05:00
eval " $( parse_yaml .blueprint/tmp/" ${ n } " /conf.yml conf_) "
2023-06-17 07:28:26 -04:00
2023-07-09 01:47:40 -04:00
# Add aliases for config values to make working with them easier.
2023-08-15 06:23:40 -04:00
name = " $conf_info_name "
identifier = " $conf_info_identifier "
description = " $conf_info_description "
2023-10-01 08:25:10 -04:00
flags = " $conf_info_flags " #(optional)
2023-08-15 06:23:40 -04:00
version = " $conf_info_version "
target = " $conf_info_target "
2023-10-01 08:25:10 -04:00
author = " $conf_info_author " #(optional)
2023-08-31 11:19:50 -04:00
icon = " $conf_info_icon " #(optional)
2023-07-30 16:22:08 -04:00
website = " $conf_info_website " ; #(optional)
2023-08-15 06:23:40 -04:00
admin_view = " $conf_admin_view "
2023-07-30 16:22:08 -04:00
admin_controller = " $conf_admin_controller " ; #(optional)
admin_css = " $conf_admin_css " ; #(optional)
admin_wrapper = " $conf_admin_wrapper " ; #(optional)
dashboard_css = " $conf_dashboard_css " ; #(optional)
2023-12-06 15:18:01 -05:00
dashboard_wrapper = " $conf_dashboard_wrapper " ; #(optional)
2023-12-28 14:45:03 -05:00
dashboard_components = " $conf_dashboard_components " ; #(optional)
2023-07-30 16:22:08 -04:00
data_directory = " $conf_data_directory " ; #(optional)
data_public = " $conf_data_public " ; #(optional)
2023-07-02 14:58:59 -04:00
2023-08-20 04:46:52 -04:00
database_migrations = " $conf_database_migrations " ; #(optional)
2023-12-11 08:44:29 -05:00
2023-09-06 11:54:23 -04:00
# "prevent" folder "escaping"
2024-02-04 09:18:41 -05:00
if [ [ ( $icon = = "/" * ) || ( $icon = = *"/.." * ) || ( $icon = = *"../" * ) || ( $icon = = *"/../" * ) || ( $icon = = *"\n" * ) ] ] \
|| [ [ ( $admin_view = = "/" * ) || ( $admin_view = = *"/.." * ) || ( $admin_view = = *"../" * ) || ( $admin_view = = *"/../" * ) || ( $admin_view = = *"\n" * ) ] ] \
|| [ [ ( $admin_controller = = "/" * ) || ( $admin_controller = = *"/.." * ) || ( $admin_controller = = *"../" * ) || ( $admin_controller = = *"/../" * ) || ( $admin_controller = = *"\n" * ) ] ] \
|| [ [ ( $admin_css = = "/" * ) || ( $admin_css = = *"/.." * ) || ( $admin_css = = *"../" * ) || ( $admin_css = = *"/../" * ) || ( $admin_css = = *"\n" * ) ] ] \
|| [ [ ( $admin_wrapper = = "/" * ) || ( $admin_wrapper = = *"/.." * ) || ( $admin_wrapper = = *"../" * ) || ( $admin_wrapper = = *"/../" * ) || ( $admin_wrapper = = *"\n" * ) ] ] \
|| [ [ ( $dashboard_css = = "/" * ) || ( $dashboard_css = = *"/.." * ) || ( $dashboard_css = = *"../" * ) || ( $dashboard_css = = *"/../" * ) || ( $dashboard_css = = *"\n" * ) ] ] \
|| [ [ ( $dashboard_wrapper = = "/" * ) || ( $dashboard_wrapper = = *"/.." * ) || ( $dashboard_wrapper = = *"../" * ) || ( $dashboard_wrapper = = *"/../" * ) || ( $dashboard_wrapper = = *"\n" * ) ] ] \
|| [ [ ( $dashboard_components = = "/" * ) || ( $dashboard_components = = *"/.." * ) || ( $dashboard_components = = *"../" * ) || ( $dashboard_components = = *"/../" * ) || ( $dashboard_components = = *"\n" * ) ] ] \
|| [ [ ( $data_directory = = "/" * ) || ( $data_directory = = *"/.." * ) || ( $data_directory = = *"../" * ) || ( $data_directory = = *"/../" * ) || ( $data_directory = = *"\n" * ) ] ] \
|| [ [ ( $data_public = = "/" * ) || ( $data_public = = *"/.." * ) || ( $data_public = = *"../" * ) || ( $data_public = = *"/../" * ) || ( $data_public = = *"\n" * ) ] ] \
|| [ [ ( $database_migrations = = "/" * ) || ( $database_migrations = = *"/.." * ) || ( $database_migrations = = *"../" * ) || ( $database_migrations = = *"/../" * ) || ( $database_migrations = = *"\n" * ) ] ] ; then
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 15:39:39 -05:00
PRINT FATAL "Config file paths cannot escape the extension bundle."
exit 1
2023-09-06 11:54:23 -04:00
fi
# prevent potentional problems during installation due to wrongly defined folders
2023-12-28 14:45:03 -05:00
if [ [ ( $dashboard_components = = *"/" ) ||
( $data_directory = = *"/" ) ||
( $data_public = = *"/" ) ||
( $database_migrations = = *"/" ) ] ] ; then
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 11:40:12 -05:00
PRINT FATAL "Directory paths in conf.yml should not end with a slash."
exit 1
2023-09-06 11:54:23 -04:00
fi
# check if extension still has placeholder values
2024-02-09 07:04:47 -05:00
if [ [ ( $name = = "[name]" ) || ( $identifier = = "[identifier]" ) || ( $description = = "[description]" ) ] ] \
|| [ [ ( $version = = "[ver]" ) || ( $target = = "[version]" ) || ( $author = = "[author]" ) ] ] ; then
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 11:40:12 -05:00
PRINT FATAL "Extension contains placeholder values which need to be replaced."
exit 1
2023-08-15 06:23:40 -04:00
fi
2023-06-19 15:04:06 -04:00
2023-07-22 07:13:00 -04:00
# Detect if extension is already installed and prepare the upgrading process.
2023-11-08 10:01:39 -05:00
if [ [ $( cat .blueprint/extensions/blueprint/private/db/installed_extensions) = = *" $identifier , " * ] ] ; then
2024-01-15 11:40:12 -05:00
PRINT INFO "Switching to update process as extension has already been installed."
2023-12-22 07:15:54 -05:00
eval " $( parse_yaml .blueprint/extensions/" ${ identifier } " /private/.store/conf.yml old_) "
2023-08-15 06:23:40 -04:00
DUPLICATE = "y"
2023-07-22 06:40:00 -04:00
2023-11-08 10:01:39 -05:00
if [ [ ! -f " .blueprint/extensions/ $identifier /private/.store/build/button.blade.php " ] ] ; then
2023-10-26 07:09:31 -04:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 11:40:12 -05:00
PRINT FATAL "Upgrading extension has failed due to missing essential .store files."
exit 1
2023-08-15 06:23:40 -04:00
fi
2023-07-22 07:13:00 -04:00
2023-10-01 08:25:10 -04:00
# Clean up some old extension files.
2023-07-22 07:13:00 -04:00
if [ [ $old_data_public != "" ] ] ; then
2023-10-01 08:25:10 -04:00
# Clean up old public folder.
2023-11-08 10:01:39 -05:00
rm -R " .blueprint/extensions/ $identifier /public "
mkdir " .blueprint/extensions/ $identifier /public "
2023-08-15 06:23:40 -04:00
fi
fi
2023-07-20 09:36:58 -04:00
2023-12-11 09:33:33 -05:00
# Assign variables to extension flags.
2024-02-03 10:41:05 -05:00
PRINT INFO "Reading and assigning extension flags.."
assignflags
2023-12-11 09:33:33 -05:00
2023-10-31 05:29:21 -04:00
# Force http/https url scheme for extension website urls.
if [ [ $website != "" ] ] ; then
if [ [ ( $website != "https://" * ) && ( $website != "http://" * ) ] ] ; then
2023-12-17 06:51:06 -05:00
website = " http:// ${ conf_info_website } "
conf_info_website = " ${ website } "
2023-10-31 05:29:21 -04:00
fi
2023-11-08 05:22:47 -05:00
# Change link icon depending on website url.
websiteiconclass = "bx-link-external"
2023-11-14 09:30:38 -05:00
2023-11-19 09:07:33 -05:00
# git
2024-01-12 10:32:42 -05:00
if [ [ $website = = *"://github.com/" * ] ] || [ [ $website = = *"://www.github.com/" * ] ] ||
[ [ $website = = *"://github.com" ] ] || [ [ $website = = *"://www.github.com" ] ] ||
[ [ $website = = *"://gitlab.com/" * ] ] || [ [ $website = = *"://www.gitlab.com/" * ] ] ||
[ [ $website = = *"://gitlab.com" ] ] || [ [ $website = = *"://www.gitlab.com" ] ] ; then websiteiconclass = "bx-git-branch" ; fi
# marketplaces
if [ [ $website = = *"://sourcexchange.net/" * ] ] || [ [ $website = = *"://www.sourcexchange.net/" * ] ] ||
[ [ $website = = *"://sourcexchange.net" ] ] || [ [ $website = = *"://www.sourcexchange.net" ] ] ||
[ [ $website = = *"://builtbybit.com/" * ] ] || [ [ $website = = *"://www.builtbybit.com/" * ] ] ||
[ [ $website = = *"://builtbybit.com" ] ] || [ [ $website = = *"://www.builtbybit.com" ] ] ||
[ [ $website = = *"://builtbyb.it/" * ] ] || [ [ $website = = *"://www.builtbyb.it/" * ] ] ||
[ [ $website = = *"://builtbyb.it" ] ] || [ [ $website = = *"://www.builtbyb.it" ] ] ; then websiteiconclass = "bx-store" ; fi
2023-11-19 09:07:33 -05:00
# discord
2024-01-12 10:32:42 -05:00
if [ [ $website = = *"://discord.com/" * ] ] || [ [ $website = = *"://www.discord.com/" * ] ] ||
[ [ $website = = *"://discord.com" ] ] || [ [ $website = = *"://www.discord.com" ] ] ||
[ [ $website = = *"://discord.gg/" * ] ] || [ [ $website = = *"://www.discord.gg/" * ] ] ||
[ [ $website = = *"://discord.gg" ] ] || [ [ $website = = *"://www.discord.gg" ] ] ; then websiteiconclass = "bxl-discord-alt" ; fi
2023-11-19 09:07:33 -05:00
# patreon
2024-01-12 10:32:42 -05:00
if [ [ $website = = *"://patreon.com/" * ] ] || [ [ $website = = *"://www.patreon.com/" * ] ] ||
[ [ $website = = *"://patreon.com" ] ] || [ [ $website = = *"://www.patreon.com" ] ] ; then websiteiconclass = "bxl-patreon" ; fi
2023-11-19 09:07:33 -05:00
# reddit
2024-01-12 10:32:42 -05:00
if [ [ $website = = *"://reddit.com/" * ] ] || [ [ $website = = *"://www.reddit.com/" * ] ] ||
[ [ $website = = *"://reddit.com" ] ] || [ [ $website = = *"://www.reddit.com" ] ] ; then websiteiconclass = "bxl-reddit" ; fi
2023-11-19 09:07:33 -05:00
# trello
2024-01-12 10:32:42 -05:00
if [ [ $website = = *"://trello.com/" * ] ] || [ [ $website = = *"://www.trello.com/" * ] ] ||
[ [ $website = = *"://trello.com" ] ] || [ [ $website = = *"://www.trello.com" ] ] ; then websiteiconclass = "bxl-trello" ; fi
2023-10-31 05:29:21 -04:00
fi
2023-05-17 03:55:16 -04:00
2023-07-03 06:48:40 -04:00
if [ [ $dev = = true ] ] ; then
2023-10-31 05:38:52 -04:00
mv " .blueprint/tmp/ $n " " .blueprint/tmp/ $identifier "
2023-08-15 06:23:40 -04:00
n = $identifier
fi
2023-03-26 12:19:10 -04:00
2023-12-11 09:50:54 -05:00
if ! $F_ignorePlaceholders ; then
2023-10-20 09:09:48 -04:00
# Prepare variables for placeholders
2024-01-15 11:40:12 -05:00
PRINT INFO "Writing extension placeholders.."
2023-10-25 15:17:28 -04:00
DIR = " .blueprint/tmp/ $n "
INSTALLMODE = "normal"
2023-11-14 09:50:14 -05:00
installation_timestamp = $( date +%s)
if [ [ $dev = = true ] ] ; then INSTALLMODE = "developer" ; fi
EXTPUBDIR = " $FOLDER /.blueprint/extensions/ $identifier /public "
if [ [ $data_public = = "" ] ] ; then EXTPUBDIR = "null" ; fi
2023-10-25 15:17:28 -04:00
PLACE_PLACEHOLDERS( ) {
local dir = " $1 "
for file in " $dir " /*; do
if [ -f " $file " ] ; then
2023-12-22 11:51:20 -05:00
file = ${ file // / \\ }
2024-01-31 11:38:47 -05:00
sed -i \
-e " s~\^#version#\^~ $version ~g " \
-e " s~\^#author#\^~ $author ~g " \
-e " s~\^#name#\^~ $name ~g " \
-e " s~\^#identifier#\^~ $identifier ~g " \
-e " s~\^#path#\^~ $FOLDER ~g " \
-e " s~\^#datapath#\^~ $FOLDER /.blueprint/extensions/ $identifier /private~g " \
-e " s~\^#publicpath#\^~ $EXTPUBDIR ~g " \
-e " s~\^#installmode#\^~ $INSTALLMODE ~g " \
-e " s~\^#blueprintversion#\^~ $VERSION ~g " \
-e " s~\^#timestamp#\^~ $installation_timestamp ~g " \
-e " s~\^#componentroot#\^~@/blueprint/extensions/ $identifier ~g " \
" $file "
2023-12-11 09:50:54 -05:00
if ! $F_ignoreAlphabetPlaceholders ; then
2024-01-31 11:38:47 -05:00
sed -i \
-e " s~__version__~ $version ~g " \
-e " s~__author__~ $author ~g " \
-e " s~__identifier__~ $identifier ~g " \
-e " s~__name__~ $name ~g " \
-e " s~__path__~ $FOLDER ~g " \
-e " s~__datapath__~ $FOLDER /.blueprint/extensions/ $identifier /private~g " \
-e " s~__publicpath__~ $EXTPUBDIR ~g " \
-e " s~__installmode__~ $INSTALLMODE ~g " \
-e " s~__blueprintversion__~ $VERSION ~g " \
-e " s~__timestamp__~ $installation_timestamp ~g " \
-e " s~__componentroot__~@/blueprint/extensions/ $identifier ~g " \
" $file "
2023-10-25 15:17:28 -04:00
fi
elif [ -d " $file " ] ; then
PLACE_PLACEHOLDERS " $file "
fi
done
}
PLACE_PLACEHOLDERS " $DIR "
2024-01-15 11:40:12 -05:00
fi
2023-08-15 06:23:40 -04:00
2024-01-15 11:40:12 -05:00
if [ [ $name = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "'info_name' is a required configuration option." ; exit 1; fi
if [ [ $identifier = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "'info_identifier' is a required configuration option." ; exit 1; fi
if [ [ $description = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "'info_description' is a required configuration option." ; exit 1; fi
if [ [ $version = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "'info_version' is a required configuration option." ; exit 1; fi
if [ [ $target = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "'info_target' is a required configuration option." ; exit 1; fi
if [ [ $admin_view = = "" ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "'admin_view' is a required configuration option." ; exit 1; fi
2023-12-11 08:32:32 -05:00
2024-01-15 11:40:12 -05:00
if [ [ $icon = = "" ] ] ; then PRINT WARNING "This extension does not come with an icon, consider adding one." ; fi
if [ [ $target != " $VERSION " ] ] ; then PRINT WARNING " This extension is built for version $target , but your version is $VERSION . " ; fi
if [ [ $identifier != " $n " ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "Extension file name must be the same as your identifier. (example: identifier.blueprint)" ; exit 1; fi
if ! [ [ $identifier = ~ [ a-z] ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "Extension identifier should be lowercase and only contain characters a-z." ; exit 1; fi
if [ [ $identifier = = "blueprint" ] ] ; then rm -R " .blueprint/tmp/ $n " ; PRINT FATAL "Extensions can not have the identifier 'blueprint'." ; exit 1; fi
2023-12-11 08:32:32 -05:00
2023-12-11 08:44:29 -05:00
# Validate paths to files and directories defined in conf.yml.
2023-12-28 14:45:03 -05:00
if [ [ ( ! -f " .blueprint/tmp/ $n / $icon " ) && ( ${ icon } != "" ) ] ] || # file: icon (optional)
[ [ ( ! -f " .blueprint/tmp/ $n / $admin_view " ) ] ] || # file: admin_view
[ [ ( ! -f " .blueprint/tmp/ $n / $admin_controller " ) && ( ${ admin_controller } != "" ) ] ] || # file: admin_controller (optional)
[ [ ( ! -f " .blueprint/tmp/ $n / $admin_css " ) && ( ${ admin_css } != "" ) ] ] || # file: admin_css (optional)
[ [ ( ! -f " .blueprint/tmp/ $n / $admin_wrapper " ) && ( ${ admin_wrapper } != "" ) ] ] || # file: admin_wrapper (optional)
[ [ ( ! -f " .blueprint/tmp/ $n / $dashboard_css " ) && ( ${ dashboard_css } != "" ) ] ] || # file: dashboard_css (optional)
[ [ ( ! -f " .blueprint/tmp/ $n / $dashboard_wrapper " ) && ( ${ dashboard_wrapper } != "" ) ] ] || # file: dashboard_wrapper (optional)
[ [ ( ! -d " .blueprint/tmp/ $n / $dashboard_components " ) && ( ${ dashboard_components } != "" ) ] ] || # folder: dashboard_components (optional)
[ [ ( ! -d " .blueprint/tmp/ $n / $data_directory " ) && ( ${ data_directory } != "" ) ] ] || # folder: data_directory (optional)
[ [ ( ! -d " .blueprint/tmp/ $n / $data_public " ) && ( ${ data_public } != "" ) ] ] || # folder: data_public (optional)
[ [ ( ! -d " .blueprint/tmp/ $n / $data_migrations " ) && ( ${ data_migrations } != "" ) ] ] ; then # folder: data_migrations (optional)
2023-12-11 08:44:29 -05:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 15:39:39 -05:00
PRINT FATAL "Extension configuration points towards one or more files that do not exist."
exit 1
2023-12-11 08:32:32 -05:00
fi
2023-12-11 10:13:24 -05:00
# Validate custom script paths.
2023-12-11 14:05:29 -05:00
if [ [ $F_hasInstallScript = = true || $F_hasRemovalScript = = true || $F_hasExportScript = = true ] ] ; then
2024-01-15 17:59:30 -05:00
if [ [ $data_directory = = "" ] ] ; then
rm -R " .blueprint/tmp/ $n "
PRINT FATAL "Install/Remove/Export script requires private folder to be enabled."
exit 1
fi
2023-12-11 10:13:24 -05:00
2023-12-11 12:43:01 -05:00
if [ [ $F_hasInstallScript = = true ] ] && [ [ ! -f " .blueprint/tmp/ $n / $data_directory /install.sh " ] ] ||
[ [ $F_hasRemovalScript = = true ] ] && [ [ ! -f " .blueprint/tmp/ $n / $data_directory /remove.sh " ] ] ||
[ [ $F_hasExportScript = = true ] ] && [ [ ! -f " .blueprint/tmp/ $n / $data_directory /export.sh " ] ] ; then
2023-12-11 10:13:24 -05:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 17:59:30 -05:00
PRINT FATAL "Install/Remove/Export script could not be found or detected, even though enabled."
exit 1
2023-12-11 10:13:24 -05:00
fi
fi
2023-12-28 15:03:05 -05:00
# Place database migrations.
2023-06-11 14:58:20 -04:00
if [ [ $database_migrations != "" ] ] ; then
2024-01-15 11:40:12 -05:00
PRINT INFO "Cloning database migration files.."
2023-12-22 10:06:02 -05:00
cp -R " .blueprint/tmp/ $n / $database_migrations / " * "database/migrations/" 2>> $BLUEPRINT__DEBUG
2023-08-15 06:23:40 -04:00
fi
2023-03-26 09:27:37 -04:00
2023-12-28 15:03:05 -05:00
# Create, link and connect components directory.
if [ [ $dashboard_components != "" ] ] ; then
YARN = "y"
2024-01-15 11:40:12 -05:00
PRINT INFO "Cloning and linking components directory.."
2023-12-28 15:03:05 -05:00
mkdir -p " .blueprint/extensions/ $identifier /components "
2024-01-15 17:59:30 -05:00
cd $FOLDER /resources/scripts/blueprint/extensions || cdhalt
2023-12-28 15:03:05 -05:00
ln -s -T $FOLDER /.blueprint/extensions/" $identifier " /components " $identifier " 2>> $BLUEPRINT__DEBUG
2024-01-15 17:59:30 -05:00
cd $FOLDER || cdhalt
2023-12-28 15:03:05 -05:00
2024-01-30 14:42:05 -05:00
# Remove custom routes to prevent duplicates.
if [ [ $DUPLICATE = = "y" ] ] ; then
2024-01-31 11:38:47 -05:00
sed -i \
-e " s/\/\* ${ identifier ^ } ImportStart \*\/.*\/\* ${ identifier ^ } ImportEnd \*\/// " \
-e " s~/\* ${ identifier ^ } ImportStart \*/~~g " \
-e " s~/\* ${ identifier ^ } ImportEnd \*/~~g " \
\
-e " s/\/\* ${ identifier ^ } AccountRouteStart \*\/.*\/\* ${ identifier ^ } AccountRouteEnd \*\/// " \
-e " s~/\* ${ identifier ^ } AccountRouteStart \*~~g " \
-e " s~/\* ${ identifier ^ } AccountRouteEnd \*~~g " \
\
-e " s/\/\* ${ identifier ^ } ServerRouteStart \*\/.*\/\* ${ identifier ^ } ServerRouteEnd \*\/// " \
-e " s~/\* ${ identifier ^ } ServerRouteStart \*~~g " \
-e " s~/\* ${ identifier ^ } ServerRouteEnd \*~~g " \
\
"resources/scripts/blueprint/extends/routers/routes.ts"
2024-01-30 14:42:05 -05:00
fi
2023-12-28 15:03:05 -05:00
cp -R " .blueprint/tmp/ $n / $dashboard_components / " * " .blueprint/extensions/ $identifier /components/ " 2>> $BLUEPRINT__DEBUG
2023-12-28 18:59:12 -05:00
if [ [ -f " .blueprint/tmp/ $n / $dashboard_components /Components.yml " ] ] ; then
2023-12-28 15:24:17 -05:00
# fetch component config
2023-12-28 18:59:12 -05:00
eval " $( parse_yaml .blueprint/tmp/" $n " /" $dashboard_components " /Components.yml Components_) "
2024-01-05 19:34:31 -05:00
if [ [ $DUPLICATE = = "y" ] ] ; then eval " $( parse_yaml .blueprint/extensions/" ${ identifier } " /private/.store/Components.yml OldComponents_) " ; fi
2023-12-28 18:59:12 -05:00
# define static variables to make stuff a bit easier
im = "\/\* blueprint\/import \*\/" ; re = "{/\* blueprint\/react \*/}" ; co = "resources/scripts/blueprint/components"
s = " import ${ identifier ^ } Component from ' " ; e = "';"
PLACE_REACT( ) {
2024-01-15 15:39:39 -05:00
if [ [
( $1 = = "/" * ) ||
( $1 = = *"/.." * ) ||
( $1 = = *"../" * ) ||
( $1 = = *"/../" * ) ||
( $1 = = *"\n" * ) ||
( $1 = = *"@" * ) ||
( $1 = = *"\\" * )
] ] ; then
rm -R " .blueprint/tmp/ $n "
PRINT FATAL "Component file paths cannot escape the components folder."
exit 1
fi
2024-01-05 19:34:31 -05:00
if [ [ $3 != " $1 " ] ] ; then
# remove old components
sed -i "s~" " ${ s } @/blueprint/extensions/ ${ identifier } / $3 ${ e } " "~~g" " $co " /" $2 "
sed -i "s~" " < ${ identifier ^ } Component /> " "~~g" " $co " /" $2 "
fi
if [ [ ! $1 = = "" ] ] ; then
2024-01-02 19:33:07 -05:00
# validate file name
2024-01-05 19:34:31 -05:00
if [ [ ${ 1 } = = *".tsx" ] ] ||
[ [ ${ 1 } = = *".ts" ] ] ||
[ [ ${ 1 } = = *".jsx" ] ] ||
[ [ ${ 1 } = = *".js" ] ] ; then
2024-01-02 19:33:07 -05:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 15:39:39 -05:00
PRINT FATAL "Component paths may not end with a file extension."
exit 1
2024-01-02 19:33:07 -05:00
fi
# validate path
2024-01-05 19:34:31 -05:00
if [ [ ! -f " .blueprint/tmp/ $n / $dashboard_components / ${ 1 } .tsx " ] ] &&
[ [ ! -f " .blueprint/tmp/ $n / $dashboard_components / ${ 1 } .ts " ] ] &&
[ [ ! -f " .blueprint/tmp/ $n / $dashboard_components / ${ 1 } .jsx " ] ] &&
[ [ ! -f " .blueprint/tmp/ $n / $dashboard_components / ${ 1 } .js " ] ] ; then
2024-01-02 19:33:07 -05:00
rm -R " .blueprint/tmp/ $n "
2024-01-15 15:39:39 -05:00
PRINT FATAL "Components configuration points towards one or more files that do not exist."
exit 1
2024-01-02 19:33:07 -05:00
fi
2024-01-31 14:23:22 -05:00
# Purge and add components.
2024-01-31 13:36:44 -05:00
sed -i \
-e "s~" " ${ s } @/blueprint/extensions/ ${ identifier } / $1 ${ e } " "~~g" \
-e "s~" " < ${ identifier ^ } Component /> " "~~g" \
2024-01-31 14:23:22 -05:00
\
2024-01-31 13:36:44 -05:00
-e "s~" " $im " "~" " ${ im } ${ s } @/blueprint/extensions/ ${ identifier } / $1 ${ e } " "~g" \
-e "s~" " $re " "~" " ${ re } \< ${ identifier ^ } Component /\> " "~g" \
" $co " /" $2 "
2023-12-28 18:59:12 -05:00
fi
}
2023-12-28 18:05:30 -05:00
2024-01-05 17:58:46 -05:00
# place component items
2024-01-05 19:58:57 -05:00
# -> PLACE_REACT "$Components_" "path/.tsx" "$OldComponents_"
2024-01-06 10:32:17 -05:00
# navigation
2024-01-05 19:34:31 -05:00
PLACE_REACT " $Components_Navigation_NavigationBar_BeforeNavigation " "Navigation/NavigationBar/BeforeNavigation.tsx" " $OldComponents_Navigation_NavigationBar_BeforeNavigation "
PLACE_REACT " $Components_Navigation_NavigationBar_AdditionalItems " "Navigation/NavigationBar/AdditionalItems.tsx" " $OldComponents_Navigation_NavigationBar_AdditionalItems "
PLACE_REACT " $Components_Navigation_NavigationBar_AfterNavigation " "Navigation/NavigationBar/AfterNavigation.tsx" " $OldComponents_Navigation_NavigationBar_AfterNavigation "
2024-01-06 17:07:18 -05:00
PLACE_REACT " $Components_Navigation_SubNavigation_BeforeSubNavigation " "Navigation/SubNavigation/BeforeSubNavigation.tsx" " $OldComponents_Navigation_SubNavigation_BeforeSubNavigation "
PLACE_REACT " $Components_Navigation_SubNavigation_AdditionalServerItems " "Navigation/SubNavigation/AdditionalServerItems.tsx" " $OldComponents_Navigation_SubNavigation_AdditionalServerItems "
PLACE_REACT " $Components_Navigation_SubNavigation_AdditionalAccountItems " "Navigation/SubNavigation/AdditionalAccountItems.tsx" " $OldComponents_Navigation_SubNavigation_AdditionalAccountItems "
PLACE_REACT " $Components_Navigation_SubNavigation_AfterSubNavigation " "Navigation/SubNavigation/AfterSubNavigation.tsx" " $OldComponents_Navigation_SubNavigation_AfterSubNavigation "
2024-01-06 10:32:17 -05:00
2024-01-06 15:24:36 -05:00
# dashboard
PLACE_REACT " $Components_Dashboard_ServerRow_BeforeEntryName " "Dashboard/ServerRow/BeforeEntryName.tsx" " $OldComponents_Dashboard_ServerRow_BeforeEntryName "
PLACE_REACT " $Components_Dashboard_ServerRow_AfterEntryName " "Dashboard/ServerRow/AfterEntryName.tsx" " $OldComponents_Dashboard_ServerRow_AfterEntryName "
PLACE_REACT " $Components_Dashboard_ServerRow_BeforeEntryDescription " "Dashboard/ServerRow/BeforeEntryDescription.tsx" " $OldComponents_Dashboard_ServerRow_BeforeEntryDescription "
PLACE_REACT " $Components_Dashboard_ServerRow_AfterEntryDescription " "Dashboard/ServerRow/AfterEntryDescription.tsx" " $OldComponents_Dashboard_ServerRow_AfterEntryDescription "
PLACE_REACT " $Components_Dashboard_ServerRow_ResourceLimits " "Dashboard/ServerRow/ResourceLimits.tsx" " $OldComponents_Dashboard_ServerRow_ResourceLimits "
2024-01-31 16:14:11 -05:00
# authentication
PLACE_REACT " $Components_Authentication_Container_BeforeContent " "Authentication/Container/BeforeContent.tsx" " $OldComponents_Authentication_Container_BeforeContent "
PLACE_REACT " $Components_Authentication_Container_AfterContent " "Authentication/Container/AfterContent.tsx" " $OldComponents_Authentication_Container_AfterContent "
2024-01-06 15:24:36 -05:00
2024-01-06 10:32:17 -05:00
# server
2024-01-05 19:34:31 -05:00
PLACE_REACT " $Components_Server_Terminal_BeforeContent " "Server/Terminal/BeforeContent.tsx" " $OldComponents_Server_Terminal_BeforeContent "
PLACE_REACT " $Components_Server_Terminal_AfterContent " "Server/Terminal/AfterContent.tsx" " $OldComponents_Server_Terminal_AfterContent "
2024-01-05 19:58:57 -05:00
2024-01-05 19:34:31 -05:00
PLACE_REACT " $Components_Server_Files_Browse_BeforeContent " "Server/Files/Browse/BeforeContent.tsx" " $OldComponents_Server_Files_Browse_BeforeContent "
PLACE_REACT " $Components_Server_Files_Browse_FileButtons " "Server/Files/Browse/FileButtons.tsx" " $OldComponents_Server_Files_Browse_FileButtons "
2024-01-06 15:40:40 -05:00
PLACE_REACT " $Components_Server_Files_Browse_DropdownItems " "Server/Files/Browse/DropdownItems.tsx" " $OldComponents_Server_Files_Browse_DropdownItems "
2024-01-05 19:34:31 -05:00
PLACE_REACT " $Components_Server_Files_Browse_AfterContent " "Server/Files/Browse/AfterContent.tsx" " $OldComponents_Server_Files_Browse_AfterContent "
PLACE_REACT " $Components_Server_Files_Edit_BeforeEdit " "Server/Files/Edit/BeforeEdit.tsx" " $OldComponents_Server_Files_Edit_BeforeEdit "
PLACE_REACT " $Components_Server_Files_Edit_AfterEdit " "Server/Files/Edit/AfterEdit.tsx" " $OldComponents_Server_Files_Edit_AfterEdit "
2024-01-05 19:58:57 -05:00
PLACE_REACT " $Components_Server_Databases_BeforeContent " "Server/Databases/BeforeContent.tsx" " $OldComponents_Server_Databases_BeforeContent "
PLACE_REACT " $Components_Server_Databases_AfterContent " "Server/Databases/AfterContent.tsx" " $OldComponents_Server_Databases_AfterContent "
PLACE_REACT " $Components_Server_Schedules_List_BeforeContent " "Server/Schedules/List/BeforeContent.tsx" " $OldComponents_Server_Schedules_List_BeforeContent "
PLACE_REACT " $Components_Server_Schedules_List_AfterContent " "Server/Schedules/List/AfterContent.tsx" " $OldComponents_Server_Schedules_List_AfterContent "
PLACE_REACT " $Components_Server_Schedules_Edit_BeforeEdit " "Server/Schedules/Edit/BeforeEdit.tsx" " $OldComponents_Server_Schedules_Edit_BeforeEdit "
PLACE_REACT " $Components_Server_Schedules_Edit_AfterEdit " "Server/Schedules/Edit/AfterEdit.tsx" " $OldComponents_Server_Schedules_Edit_AfterEdit "
2024-01-05 17:58:46 -05:00
2024-01-05 20:48:45 -05:00
PLACE_REACT " $Components_Server_Users_BeforeContent " "Server/Users/BeforeContent.tsx" " $OldComponents_Server_Users_BeforeContent "
PLACE_REACT " $Components_Server_Users_AfterContent " "Server/Users/AfterContent.tsx" " $OldComponents_Server_Users_AfterContent "
PLACE_REACT " $Components_Server_Backups_BeforeContent " "Server/Backups/BeforeContent.tsx" " $OldComponents_Server_Backups_BeforeContent "
2024-01-06 15:40:40 -05:00
PLACE_REACT " $Components_Server_Backups_DropdownItems " "Server/Backups/DropdownItems.tsx" " $OldComponents_Server_Backups_DropdownItems "
2024-01-05 20:48:45 -05:00
PLACE_REACT " $Components_Server_Backups_AfterContent " "Server/Backups/AfterContent.tsx" " $OldComponents_Server_Backups_AfterContent "
PLACE_REACT " $Components_Server_Network_BeforeContent " "Server/Network/BeforeContent.tsx" " $OldComponents_Server_Network_BeforeContent "
PLACE_REACT " $Components_Server_Network_AfterContent " "Server/Network/AfterContent.tsx" " $OldComponents_Server_Network_AfterContent "
PLACE_REACT " $Components_Server_Startup_BeforeContent " "Server/Startup/BeforeContent.tsx" " $OldComponents_Server_Startup_BeforeContent "
PLACE_REACT " $Components_Server_Startup_AfterContent " "Server/Startup/AfterContent.tsx" " $OldComponents_Server_Startup_AfterContent "
PLACE_REACT " $Components_Server_Settings_BeforeContent " "Server/Settings/BeforeContent.tsx" " $OldComponents_Server_Settings_BeforeContent "
PLACE_REACT " $Components_Server_Settings_AfterContent " "Server/Settings/AfterContent.tsx" " $OldComponents_Server_Settings_AfterContent "
2024-01-06 10:32:17 -05:00
# account
PLACE_REACT " $Components_Account_Overview_BeforeContent " "Account/Overview/BeforeContent.tsx" " $OldComponents_Account_Overview_BeforeContent "
PLACE_REACT " $Components_Account_Overview_AfterContent " "Account/Overview/AfterContent.tsx" " $OldComponents_Account_Overview_AfterContent "
PLACE_REACT " $Components_Account_API_BeforeContent " "Account/API/BeforeContent.tsx" " $OldComponents_Account_API_BeforeContent "
PLACE_REACT " $Components_Account_API_AfterContent " "Account/API/AfterContent.tsx" " $OldComponents_Account_API_AfterContent "
PLACE_REACT " $Components_Account_SSH_BeforeContent " "Account/SSH/BeforeContent.tsx" " $OldComponents_Account_SSH_BeforeContent "
PLACE_REACT " $Components_Account_SSH_AfterContent " "Account/SSH/AfterContent.tsx" " $OldComponents_Account_SSH_AfterContent "
2024-01-27 10:49:33 -05:00
2024-01-30 14:42:05 -05:00
2024-01-27 10:49:33 -05:00
# Place custom extension routes.
if [ [ $Components_Navigation_Routes_ != "" ] ] ; then
PRINT INFO "Linking navigation routes.."
2024-01-30 12:59:08 -05:00
ImportConstructor = ".blueprint/extensions/blueprint/private/build/extensions/routes/importConstructor.bak"
AccountRouteConstructor = ".blueprint/extensions/blueprint/private/build/extensions/routes/accountRouteConstructor.bak"
ServerRouteConstructor = ".blueprint/extensions/blueprint/private/build/extensions/routes/serverRouteConstructor.bak"
2024-01-30 12:04:12 -05:00
{
2024-01-30 12:59:08 -05:00
cp ".blueprint/extensions/blueprint/private/build/extensions/routes/importConstructor" " $ImportConstructor "
cp ".blueprint/extensions/blueprint/private/build/extensions/routes/accountRouteConstructor" " $AccountRouteConstructor "
cp ".blueprint/extensions/blueprint/private/build/extensions/routes/serverRouteConstructor" " $ServerRouteConstructor "
2024-01-30 12:04:12 -05:00
} 2>> $BLUEPRINT__DEBUG
2024-01-30 15:50:33 -05:00
sed -i "s~\[id\^]~" " ${ identifier ^ } " "~g" $ImportConstructor
sed -i "s~\[id\^]~" " ${ identifier ^ } " "~g" $AccountRouteConstructor
sed -i "s~\[id\^]~" " ${ identifier ^ } " "~g" $ServerRouteConstructor
2024-01-30 12:04:12 -05:00
2024-01-27 10:49:33 -05:00
for parent in $Components_Navigation_Routes_ ; do
parent = " ${ parent } _ "
for child in ${ !parent } ; do
# Route name
2024-01-27 13:30:19 -05:00
if [ [ $child = = "Components_Navigation_Routes_" +( [ 0-9] ) "_Name" ] ] ; then COMPONENTS_ROUTE_NAME = " ${ !child } " ; fi
2024-01-27 10:49:33 -05:00
# Route path
2024-01-27 13:30:19 -05:00
if [ [ $child = = "Components_Navigation_Routes_" +( [ 0-9] ) "_Path" ] ] ; then COMPONENTS_ROUTE_PATH = " ${ !child } " ; fi
2024-01-27 10:49:33 -05:00
# Route type
2024-01-27 13:30:19 -05:00
if [ [ $child = = "Components_Navigation_Routes_" +( [ 0-9] ) "_Type" ] ] ; then COMPONENTS_ROUTE_TYPE = " ${ !child } " ; fi
2024-01-27 10:49:33 -05:00
# Route component
2024-01-27 13:30:19 -05:00
if [ [ $child = = "Components_Navigation_Routes_" +( [ 0-9] ) "_Component" ] ] ; then COMPONENTS_ROUTE_COMP = " ${ !child } " ; fi
2024-02-24 14:46:59 -05:00
# Route admin
if [ [ $child = = "Components_Navigation_Routes_" +( [ 0-9] ) "_Admin" ] ] ; then COMPONENTS_ROUTE_ADMI = " ${ !child } " ; fi
2024-01-27 10:49:33 -05:00
done
2024-01-27 13:30:19 -05:00
# Route identifier
COMPONENTS_ROUTE_IDEN = $( tr -dc '[:lower:]' < /dev/urandom | fold -w 10 | head -n 1)
2024-01-30 09:13:17 -05:00
COMPONENTS_ROUTE_IDEN = " ${ identifier ^ } ${ COMPONENTS_ROUTE_IDEN ^ } "
2024-01-27 13:30:19 -05:00
echo -e " NAME: $COMPONENTS_ROUTE_NAME \nPATH: $COMPONENTS_ROUTE_PATH \nTYPE: $COMPONENTS_ROUTE_TYPE \nCOMP: $COMPONENTS_ROUTE_COMP \nIDEN: $COMPONENTS_ROUTE_IDEN " >> $BLUEPRINT__DEBUG
# Return error if type is not defined correctly.
if [ [ ( $COMPONENTS_ROUTE_TYPE != "server" ) && ( $COMPONENTS_ROUTE_TYPE != "account" ) ] ] ; then
rm -R " .blueprint/tmp/ $n "
PRINT FATAL "Navigation route types can only be either 'server' or 'account'."
exit 1
fi
# Prevent escaping components folder.
if [ [
( ${ COMPONENTS_ROUTE_COMP } = = "/" * ) ||
( ${ COMPONENTS_ROUTE_COMP } = = *"/.." * ) ||
( ${ COMPONENTS_ROUTE_COMP } = = *"../" * ) ||
( ${ COMPONENTS_ROUTE_COMP } = = *"/../" * ) ||
( ${ COMPONENTS_ROUTE_COMP } = = *"\n" * ) ||
( ${ COMPONENTS_ROUTE_COMP } = = *"@" * ) ||
( ${ COMPONENTS_ROUTE_COMP } = = *"\\" * )
] ] ; then
rm -R " .blueprint/tmp/ $n "
PRINT FATAL "Navigation route component paths may not escape the components directory."
exit 1
fi
# Validate file names for route components.
2024-02-04 09:18:41 -05:00
if [ [ ${ COMPONENTS_ROUTE_COMP } = = *".tsx" ] ] \
|| [ [ ${ COMPONENTS_ROUTE_COMP } = = *".ts" ] ] \
|| [ [ ${ COMPONENTS_ROUTE_COMP } = = *".jsx" ] ] \
|| [ [ ${ COMPONENTS_ROUTE_COMP } = = *".js" ] ] ; then
2024-01-27 13:30:19 -05:00
rm -R " .blueprint/tmp/ $n "
PRINT FATAL "Navigation route component paths may not end with a file extension."
exit 1
2024-01-30 17:48:09 -05:00
fi
# Validate file path.
2024-02-04 09:18:41 -05:00
if [ [ ! -f " .blueprint/tmp/ $n / $dashboard_components / ${ COMPONENTS_ROUTE_COMP } .tsx " ] ] \
&& [ [ ! -f " .blueprint/tmp/ $n / $dashboard_components / ${ COMPONENTS_ROUTE_COMP } .ts " ] ] \
&& [ [ ! -f " .blueprint/tmp/ $n / $dashboard_components / ${ COMPONENTS_ROUTE_COMP } .jsx " ] ] \
&& [ [ ! -f " .blueprint/tmp/ $n / $dashboard_components / ${ COMPONENTS_ROUTE_COMP } .js " ] ] ; then
2024-01-30 17:48:09 -05:00
rm -R " .blueprint/tmp/ $n "
PRINT FATAL "Navigation route configuration points towards one or more components that do not exist."
exit 1
2024-01-27 13:30:19 -05:00
fi
# Return error if identifier is generated incorrectly.
if [ [ $COMPONENTS_ROUTE_IDEN = = "" ] ] ; then
rm -R " .blueprint/tmp/ $n "
PRINT FATAL "Failed to generate extension navigation route identifier, halting process."
exit 1
fi
2024-01-27 10:49:33 -05:00
# Return error if routes are defined incorrectly.
if [ [ $COMPONENTS_ROUTE_NAME = = "" ] ] \
|| [ [ $COMPONENTS_ROUTE_PATH = = "" ] ] \
|| [ [ $COMPONENTS_ROUTE_TYPE = = "" ] ] \
|| [ [ $COMPONENTS_ROUTE_COMP = = "" ] ] ; then
2024-01-27 13:30:19 -05:00
rm -R " .blueprint/tmp/ $n "
PRINT FATAL "One or more extension navigation routes appear to have undefined fields."
2024-01-27 10:49:33 -05:00
exit 1
fi
2024-02-24 14:46:59 -05:00
# Assign value to ROUTE_ADMI if empty
if [ [ $COMPONENTS_ROUTE_ADMI != "true" ] ] ; then
COMPONENTS_ROUTE_ADMI = "false"
fi
2024-01-27 13:30:19 -05:00
2024-01-30 12:04:12 -05:00
# Apply routes.
if [ [ $COMPONENTS_ROUTE_TYPE = = "account" ] ] ; then
# Account routes
2024-01-30 14:22:35 -05:00
COMPONENTS_IMPORT = " import $COMPONENTS_ROUTE_IDEN from '@/blueprint/extensions/ $identifier / $COMPONENTS_ROUTE_COMP '; "
2024-02-24 14:46:59 -05:00
COMPONENTS_ROUTE = " { path: ' $COMPONENTS_ROUTE_PATH ', name: ' $COMPONENTS_ROUTE_NAME ', component: $COMPONENTS_ROUTE_IDEN , admin: $COMPONENTS_ROUTE_ADMI }, "
2024-01-30 09:13:17 -05:00
2024-01-30 14:18:00 -05:00
sed -i "s~/\* \[import] \*/~/* [import] */" " $COMPONENTS_IMPORT " "~g" $ImportConstructor
2024-01-30 18:21:05 -05:00
sed -i "s~/\* \[routes] \*/~/* [routes] */" " $COMPONENTS_ROUTE " "~g" $AccountRouteConstructor
2024-01-30 12:04:12 -05:00
elif [ [ $COMPONENTS_ROUTE_TYPE = = "server" ] ] ; then
# Server routes
2024-01-30 14:22:35 -05:00
COMPONENTS_IMPORT = " import $COMPONENTS_ROUTE_IDEN from '@/blueprint/extensions/ $identifier / $COMPONENTS_ROUTE_COMP '; "
2024-02-03 10:41:05 -05:00
COMPONENTS_ROUTE = " { path: ' $COMPONENTS_ROUTE_PATH ', permission: null, name: ' $COMPONENTS_ROUTE_NAME ', component: $COMPONENTS_ROUTE_IDEN , }, "
2024-01-29 16:00:48 -05:00
2024-01-30 14:18:00 -05:00
sed -i "s~/\* \[import] \*/~/* [import] */" " $COMPONENTS_IMPORT " "~g" $ImportConstructor
2024-01-30 18:21:05 -05:00
sed -i "s~/\* \[routes] \*/~/* [routes] */" " $COMPONENTS_ROUTE " "~g" $ServerRouteConstructor
2024-01-28 16:25:06 -05:00
fi
2024-01-27 13:30:19 -05:00
2024-01-27 10:49:33 -05:00
# Clear variables after doing all route stuff for a defined route.
2024-01-30 12:04:12 -05:00
COMPONENTS_ROUTE = ""
COMPONENTS_IMPORT = ""
2024-01-27 10:49:33 -05:00
COMPONENTS_ROUTE_NAME = ""
COMPONENTS_ROUTE_PATH = ""
COMPONENTS_ROUTE_TYPE = ""
COMPONENTS_ROUTE_COMP = ""
2024-01-27 13:30:19 -05:00
COMPONENTS_ROUTE_IDEN = ""
2024-01-27 10:49:33 -05:00
done
2024-01-30 12:04:12 -05:00
2024-01-30 14:22:35 -05:00
sed -i "s~/\* \[import] \*/~~g" $ImportConstructor
2024-01-31 06:46:09 -05:00
sed -i "s~/\* \[routes] \*/~~g" $AccountRouteConstructor
sed -i "s~/\* \[routes] \*/~~g" $ServerRouteConstructor
2024-01-30 14:22:35 -05:00
2024-01-31 13:36:44 -05:00
sed -i \
-e "s~\/\* blueprint\/import \*\/~/* blueprint/import */" " $( tr '\n' '\001' <${ ImportConstructor } ) " "~g" \
-e "s~\/\* routes/account \*\/~/* routes/account */" " $( tr '\n' '\001' <${ AccountRouteConstructor } ) " "~g" \
-e "s~\/\* routes/server \*\/~/* routes/server */" " $( tr '\n' '\001' <${ ServerRouteConstructor } ) " "~g" \
"resources/scripts/blueprint/extends/routers/routes.ts"
2024-01-30 12:41:48 -05:00
2024-01-31 11:38:47 -05:00
# Fix line breaks by removing all of them.
sed -i -E "s~ ~~g" "resources/scripts/blueprint/extends/routers/routes.ts"
2024-01-30 18:05:06 -05:00
2024-01-30 15:50:33 -05:00
{
2024-01-30 12:59:08 -05:00
rm " $ImportConstructor "
2024-01-30 12:04:12 -05:00
rm " $AccountRouteConstructor "
rm " $ServerRouteConstructor "
} 2>> $BLUEPRINT__DEBUG
2024-01-27 10:49:33 -05:00
fi
2023-12-28 15:03:05 -05:00
else
2023-12-28 15:24:17 -05:00
# warn about missing components.yml file
2024-01-15 11:40:12 -05:00
PRINT WARNING " Could not find ' $dashboard_components /Components.yml', component extendability might be limited. "
2023-12-28 15:03:05 -05:00
fi
fi
# Create and link public directory.
2023-06-11 14:58:20 -04:00
if [ [ $data_public != "" ] ] ; then
2024-01-15 11:40:12 -05:00
PRINT INFO "Cloning and linking public directory.."
2023-11-08 10:01:39 -05:00
mkdir -p " .blueprint/extensions/ $identifier /public "
2023-12-17 06:51:06 -05:00
2024-01-15 17:59:30 -05:00
cd $FOLDER /public/extensions || cdhalt
2023-12-22 10:06:02 -05:00
ln -s -T $FOLDER /.blueprint/extensions/" $identifier " /public " $identifier " 2>> $BLUEPRINT__DEBUG
2024-01-15 17:59:30 -05:00
cd $FOLDER || cdhalt
2023-12-17 06:51:06 -05:00
2023-12-22 10:06:02 -05:00
cp -R " .blueprint/tmp/ $n / $data_public / " * " .blueprint/extensions/ $identifier /public/ " 2>> $BLUEPRINT__DEBUG
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2024-01-15 11:40:12 -05:00
if [ [ $admin_controller = = "" ] ] ; then
controller_type = "default"
else
controller_type = "custom"
fi
2023-12-28 15:03:05 -05:00
# Prepare build files.
2024-01-31 11:38:47 -05:00
AdminControllerConstructor = ".blueprint/extensions/blueprint/private/build/extensions/controller.build.bak"
2024-01-31 13:36:44 -05:00
AdminBladeConstructor = ".blueprint/extensions/blueprint/private/build/extensions/admin.blade.php.bak"
2024-01-31 11:38:47 -05:00
AdminRouteConstructor = ".blueprint/extensions/blueprint/private/build/extensions/route.php.bak"
AdminButtonConstructor = ".blueprint/extensions/blueprint/private/build/extensions/button.blade.php.bak"
{
if [ [ $controller_type = = "default" ] ] ; then cp ".blueprint/extensions/blueprint/private/build/extensions/controller.build" " $AdminControllerConstructor " ; fi
2024-01-31 13:36:44 -05:00
cp ".blueprint/extensions/blueprint/private/build/extensions/admin.blade.php" " $AdminBladeConstructor "
2024-01-31 11:38:47 -05:00
cp ".blueprint/extensions/blueprint/private/build/extensions/route.php" " $AdminRouteConstructor "
cp ".blueprint/extensions/blueprint/private/build/extensions/button.blade.php" " $AdminButtonConstructor "
} 2>> $BLUEPRINT__DEBUG ;
2023-06-02 10:37:38 -04:00
2023-12-28 15:03:05 -05:00
2023-07-12 08:18:43 -04:00
# Start creating data directory.
2024-01-15 12:34:11 -05:00
PRINT INFO "Cloning and linking private directory.."
2024-01-31 11:38:47 -05:00
mkdir -p \
" .blueprint/extensions/ $identifier /private " \
" .blueprint/extensions/ $identifier /private/.store "
2023-07-12 08:18:43 -04:00
2024-01-15 12:34:11 -05:00
if [ [ $data_directory != "" ] ] ; then cp -R " .blueprint/tmp/ $n / $data_directory / " * " .blueprint/extensions/ $identifier /private/ " ; fi
2024-01-05 18:43:46 -05:00
cp " .blueprint/tmp/ $n /conf.yml " " .blueprint/extensions/ $identifier /private/.store/conf.yml " #backup conf.yml
if [ [ -f " .blueprint/tmp/ $n / $dashboard_components /Components.yml " ] ] ; then
cp " .blueprint/tmp/ $n / $dashboard_components /Components.yml " " .blueprint/extensions/ $identifier /private/.store/Components.yml " #backup Components.yml
fi
2023-07-12 08:18:43 -04:00
# End creating data directory.
2023-06-02 10:37:38 -04:00
2023-12-28 15:03:05 -05:00
2024-01-15 12:34:11 -05:00
# Link and create assets folder
PRINT INFO "Linking and writing assets directory.."
2023-11-24 06:11:55 -05:00
if [ [ $DUPLICATE != "y" ] ] ; then
# Create assets folder if the extension is not updating.
2023-12-17 06:51:06 -05:00
mkdir .blueprint/extensions/" $identifier " /assets
2023-11-24 06:11:55 -05:00
fi
2024-01-15 17:59:30 -05:00
cd $FOLDER /public/assets/extensions || cdhalt
2023-12-22 10:06:02 -05:00
ln -s -T $FOLDER /.blueprint/extensions/" $identifier " /assets " $identifier " 2>> $BLUEPRINT__DEBUG
2024-01-15 17:59:30 -05:00
cd $FOLDER || cdhalt
2023-12-17 06:51:06 -05:00
2023-08-31 11:19:50 -04:00
if [ [ $icon = = "" ] ] ; then
# use random placeholder icon if extension does not
# come with an icon.
2024-01-23 17:26:34 -05:00
icnNUM = $(( 1 + RANDOM % 5 ))
2023-11-08 10:01:39 -05:00
cp " .blueprint/assets/defaultExtensionLogo $icnNUM .jpg " " .blueprint/extensions/ $identifier /assets/icon.jpg "
2023-08-31 11:19:50 -04:00
else
2023-11-08 10:01:39 -05:00
cp " .blueprint/tmp/ $n / $icon " " .blueprint/extensions/ $identifier /assets/icon.jpg "
2023-08-31 11:19:50 -04:00
fi ;
2023-08-15 06:23:40 -04:00
ICON = " /assets/extensions/ $identifier /icon.jpg "
2023-12-17 06:51:06 -05:00
CONTENT = $( cat .blueprint/tmp/" $n " /" $admin_view " )
2023-06-02 10:37:38 -04:00
2023-07-21 10:00:56 -04:00
if [ [ $admin_css != "" ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT INFO "Cloning and linking admin css.."
2023-08-15 06:23:40 -04:00
updateCacheReminder
2023-12-03 12:48:41 -05:00
sed -i " s~@import url(/assets/extensions/ $identifier /admin.style.css);~~g " ".blueprint/extensions/blueprint/assets/admin.extensions.css"
echo -e " @import url(/assets/extensions/ $identifier /admin.style.css); " >> ".blueprint/extensions/blueprint/assets/admin.extensions.css"
2023-11-08 10:01:39 -05:00
cp " .blueprint/tmp/ $n / $admin_css " " .blueprint/extensions/ $identifier /assets/admin.style.css "
2023-08-15 06:23:40 -04:00
fi
2023-07-28 08:04:46 -04:00
if [ [ $dashboard_css != "" ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT INFO "Cloning and linking dashboard css.."
2023-08-15 06:23:40 -04:00
YARN = "y"
2024-01-05 10:55:56 -05:00
sed -i " s~@import url(./imported/ $identifier .css);~~g " "resources/scripts/blueprint/css/extensions.css"
echo -e " @import url(./imported/ $identifier .css); " >> "resources/scripts/blueprint/css/extensions.css"
2023-12-28 11:56:33 -05:00
cp " .blueprint/tmp/ $n / $dashboard_css " " resources/scripts/blueprint/css/imported/ $identifier .css "
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2024-01-15 12:34:11 -05:00
if [ [ $name = = *"~" * ] ] ; then PRINT WARNING "'name' contains '~' and may result in an error." ; fi
if [ [ $description = = *"~" * ] ] ; then PRINT WARNING "'description' contains '~' and may result in an error." ; fi
if [ [ $version = = *"~" * ] ] ; then PRINT WARNING "'version' contains '~' and may result in an error." ; fi
if [ [ $CONTENT = = *"~" * ] ] ; then PRINT WARNING "'CONTENT' contains '~' and may result in an error." ; fi
if [ [ $ICON = = *"~" * ] ] ; then PRINT WARNING "'ICON' contains '~' and may result in an error." ; fi
if [ [ $identifier = = *"~" * ] ] ; then PRINT WARNING "'identifier' contains '~' and may result in an error." ; fi
2023-06-02 10:37:38 -04:00
2024-01-31 13:36:44 -05:00
# Construct admin button
sed -i \
-e " s~\[name\]~ $name ~g " \
-e " s~\[version\]~ $version ~g " \
-e " s~\[id\]~ $identifier ~g " \
" $AdminButtonConstructor "
# Construct admin view
sed -i \
-e " s~\[name\]~ $name ~g " \
-e " s~\[description\]~ $description ~g " \
-e " s~\[version\]~ $version ~g " \
-e " s~\[icon\]~ $ICON ~g " \
" $AdminBladeConstructor "
2023-06-19 15:04:06 -04:00
if [ [ $website != "" ] ] ; then
2024-01-31 13:36:44 -05:00
sed -i \
-e " s~\[website\]~ $website ~g " \
-e "s~<!--\[web\] ~~g" \
-e "s~ \[web\]-->~~g" \
-e " s~\[webicon\]~ $websiteiconclass ~g " \
" $AdminBladeConstructor "
2023-08-15 06:23:40 -04:00
fi
2024-01-31 13:36:44 -05:00
echo -e " $CONTENT \n@endsection " >> " $AdminBladeConstructor "
2023-06-19 15:04:06 -04:00
2024-01-31 13:36:44 -05:00
# Construct admin route
sed -i " s~\[id\]~ $identifier ~g " " $AdminRouteConstructor "
2023-08-15 06:23:40 -04:00
2024-01-31 13:36:44 -05:00
# Construct admin controller
if [ [ $controller_type = = "default" ] ] ; then sed -i " s~\[id\]~ $identifier ~g " " $AdminControllerConstructor " ; fi
2023-10-01 08:25:10 -04:00
# Read final results.
2024-01-31 13:36:44 -05:00
ADMINVIEW_RESULT = $( <" $AdminBladeConstructor " )
ADMINROUTE_RESULT = $( <" $AdminRouteConstructor " )
ADMINBUTTON_RESULT = $( <" $AdminButtonConstructor " )
2023-12-17 06:51:06 -05:00
if [ [ $controller_type = = "default" ] ] ; then
2024-01-31 13:36:44 -05:00
ADMINCONTROLLER_RESULT = $( <" $AdminControllerConstructor " )
2023-08-15 06:23:40 -04:00
fi
2023-10-25 16:28:52 -04:00
ADMINCONTROLLER_NAME = " ${ identifier } ExtensionController.php "
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Place admin extension view.
2024-01-15 12:34:11 -05:00
PRINT INFO "Cloning admin view.."
2023-10-25 16:28:52 -04:00
mkdir -p " resources/views/admin/extensions/ $identifier "
touch " resources/views/admin/extensions/ $identifier /index.blade.php "
2023-12-17 06:51:06 -05:00
echo " $ADMINVIEW_RESULT " > " resources/views/admin/extensions/ $identifier /index.blade.php "
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Place admin extension view controller.
2024-01-15 12:34:11 -05:00
PRINT INFO "Cloning admin controller.."
2023-10-25 16:28:52 -04:00
mkdir -p " app/Http/Controllers/Admin/Extensions/ $identifier "
touch " app/Http/Controllers/Admin/Extensions/ $identifier / $ADMINCONTROLLER_NAME "
2023-12-17 06:51:06 -05:00
if [ [ $controller_type = = "default" ] ] ; then
2023-10-01 08:25:10 -04:00
# Use custom view controller.
2023-10-25 16:28:52 -04:00
touch " app/Http/Controllers/Admin/Extensions/ $identifier / $ADMINCONTROLLER_NAME "
2023-12-17 06:51:06 -05:00
echo " $ADMINCONTROLLER_RESULT " > " app/Http/Controllers/Admin/Extensions/ $identifier / $ADMINCONTROLLER_NAME "
2023-06-02 10:37:38 -04:00
else
2023-10-01 08:25:10 -04:00
# Use default extension controller.
2023-12-17 06:51:06 -05:00
cp .blueprint/tmp/" $n " /" $admin_controller " " app/Http/Controllers/Admin/Extensions/ $identifier / $ADMINCONTROLLER_NAME "
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2023-07-20 09:36:58 -04:00
if [ [ $DUPLICATE != "y" ] ] ; then
2023-10-01 08:25:10 -04:00
# Place admin route if extension is not updating.
2024-01-15 12:34:11 -05:00
PRINT INFO "Editing admin routes.."
2023-10-10 15:40:54 -04:00
{ echo "
// $identifier :start" ;
2023-12-17 06:51:06 -05:00
echo " $ADMINROUTE_RESULT " ;
2024-02-14 02:32:44 -05:00
echo // " $identifier " :stop; } >> "routes/blueprint.php"
2023-10-01 08:25:10 -04:00
else
# Replace old extensions page button if extension is updating.
2023-12-17 06:51:06 -05:00
OLDBUTTON_RESULT = $( <.blueprint/extensions/" $identifier " /private/.store/build/button.blade.php)
2023-10-26 07:01:33 -04:00
sed -i " s~ $OLDBUTTON_RESULT ~~g " "resources/views/admin/extensions.blade.php"
2023-08-15 06:23:40 -04:00
fi
2024-01-30 07:45:19 -05:00
sed -i " s~<!-- \[entryplaceholder\] -->~ $ADMINBUTTON_RESULT \n<!-- \[entryplaceholder\] -->~g " "resources/views/admin/extensions.blade.php"
2023-06-02 10:37:38 -04:00
2023-10-01 08:25:10 -04:00
# Place dashboard wrapper
2023-07-13 15:27:05 -04:00
if [ [ $dashboard_wrapper != "" ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT INFO "Cloning and injecting dashboard wrapper.."
2023-07-22 07:13:00 -04:00
if [ [ $DUPLICATE = = "y" ] ] ; then
2024-02-18 06:47:32 -05:00
sed -n -i " /<!--@ $identifier :s@-->/{p; :a; N; /<!--@ $identifier :e@-->/!ba; s/.*\n//}; p " "resources/views/blueprint/dashboard/dashboard.blade.php"
2024-02-04 09:18:41 -05:00
sed -i \
2024-02-14 11:18:23 -05:00
-e " s~<!--@ $identifier :s@-->~~g " \
-e " s~<!--@ $identifier :e@-->~~g " \
2024-02-18 06:47:32 -05:00
"resources/views/blueprint/dashboard/dashboard.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-10-26 07:01:33 -04:00
touch " .blueprint/tmp/ $n / $dashboard_wrapper .BLUEPRINTBAK "
2024-02-14 11:18:23 -05:00
cat <( echo " <!--@ $identifier :s@--> " ) " .blueprint/tmp/ $n / $dashboard_wrapper " > " .blueprint/tmp/ $n / $dashboard_wrapper .BLUEPRINTBAK "
2023-10-26 07:01:33 -04:00
cp " .blueprint/tmp/ $n / $dashboard_wrapper .BLUEPRINTBAK " " .blueprint/tmp/ $n / $dashboard_wrapper "
rm " .blueprint/tmp/ $n / $dashboard_wrapper .BLUEPRINTBAK "
2024-02-14 11:18:23 -05:00
echo -e " \n<!--@ $identifier :e@--> " >> " .blueprint/tmp/ $n / $dashboard_wrapper "
2024-02-18 06:47:32 -05:00
sed -i " /<\!-- wrapper:insert -->/r .blueprint/tmp/ $n / $dashboard_wrapper " "resources/views/blueprint/dashboard/dashboard.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-07-13 04:41:44 -04:00
2023-10-01 08:25:10 -04:00
# Place admin wrapper
2023-07-21 11:32:22 -04:00
if [ [ $admin_wrapper != "" ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT INFO "Cloning and injecting admin wrapper.."
2023-07-22 07:13:00 -04:00
if [ [ $DUPLICATE = = "y" ] ] ; then
2024-02-18 06:47:32 -05:00
sed -n -i " /<!--@ $identifier :s@-->/{p; :a; N; /<!--@ $identifier :e@-->/!ba; s/.*\n//}; p " "resources/views/blueprint/admin/admin.blade.php"
2024-02-04 09:18:41 -05:00
sed -i \
2024-02-14 11:18:23 -05:00
-e " s~<!--@ $identifier :s@-->~~g " \
-e " s~<!--@ $identifier :e@-->~~g " \
2024-02-18 06:47:32 -05:00
"resources/views/blueprint/admin/admin.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-10-26 07:01:33 -04:00
touch " .blueprint/tmp/ $n / $admin_wrapper .BLUEPRINTBAK "
2024-02-14 11:18:23 -05:00
cat <( echo " <!--@ $identifier :s@--> " ) " .blueprint/tmp/ $n / $admin_wrapper " > " .blueprint/tmp/ $n / $admin_wrapper .BLUEPRINTBAK "
2023-10-26 07:01:33 -04:00
cp " .blueprint/tmp/ $n / $admin_wrapper .BLUEPRINTBAK " " .blueprint/tmp/ $n / $admin_wrapper "
rm " .blueprint/tmp/ $n / $admin_wrapper .BLUEPRINTBAK "
2024-02-14 11:18:23 -05:00
echo -e " \n<!--@ $identifier :e@--> " >> " .blueprint/tmp/ $n / $admin_wrapper "
2024-02-18 06:47:32 -05:00
sed -i " /<\!-- wrapper:insert -->/r .blueprint/tmp/ $n / $admin_wrapper " "resources/views/blueprint/admin/admin.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-07-20 11:26:09 -04:00
2023-07-22 06:40:00 -04:00
# Create backup of generated values.
2023-11-08 10:01:39 -05:00
mkdir -p " .blueprint/extensions/ $identifier /private/.store/build "
cp ".blueprint/extensions/blueprint/private/build/extensions/button.blade.php.bak" " .blueprint/extensions/ $identifier /private/.store/build/button.blade.php "
cp ".blueprint/extensions/blueprint/private/build/extensions/route.php.bak" " .blueprint/extensions/ $identifier /private/.store/build/route.php "
2023-07-22 06:40:00 -04:00
2024-01-15 15:39:39 -05:00
# Remove temporary build files.
2024-01-15 12:34:11 -05:00
PRINT INFO "Cleaning up build files.."
2024-01-31 11:38:47 -05:00
if [ [ $controller_type = = "default" ] ] ; then rm ".blueprint/extensions/blueprint/private/build/extensions/controller.build.bak" ; fi
rm \
2024-01-31 13:36:44 -05:00
" $AdminBladeConstructor " \
" $AdminRouteConstructor " \
" $AdminButtonConstructor "
2023-10-26 07:01:33 -04:00
rm -R " .blueprint/tmp/ $n "
2023-06-02 10:37:38 -04:00
2023-06-11 14:58:20 -04:00
if [ [ $database_migrations != "" ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT INPUT "Would you like to migrate your database? (Y/n)"
2023-10-10 15:28:42 -04:00
read -r YN
2023-09-24 09:58:26 -04:00
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT INFO "Running database migrations.."
2023-08-23 15:42:34 -04:00
php artisan migrate --force
else
2024-01-15 12:34:11 -05:00
PRINT INFO "Database migrations have been skipped."
2023-08-23 15:42:34 -04:00
fi
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2023-09-24 09:58:26 -04:00
if [ [ $YARN = = "y" ] ] ; then
2024-01-15 12:34:11 -05:00
if ! [ [ ( $F_developerIgnoreRebuild = = true ) && ( $dev = = true ) ] ] ; then
PRINT INFO "Rebuilding panel assets.."
2024-02-18 11:01:30 -05:00
yarn run build:production --progress
2023-12-11 09:56:05 -05:00
fi
2023-09-24 09:58:26 -04:00
fi
2024-01-15 12:34:11 -05:00
# Flush cache.
PRINT INFO "Flushing view, config and route cache.."
{
php artisan view:clear
php artisan config:clear
php artisan route:cache
2024-02-13 09:06:17 -05:00
php artisan cache:clear
2024-01-15 12:34:11 -05:00
} & >> $BLUEPRINT__DEBUG
2023-09-24 09:58:26 -04:00
2024-02-24 09:11:01 -05:00
chown -R $OWNERSHIP " $FOLDER /.blueprint/extensions/ $identifier /private "
2023-12-22 10:06:02 -05:00
chmod --silent -R +x ".blueprint/extensions/" * 2>> $BLUEPRINT__DEBUG
2023-06-02 10:37:38 -04:00
2023-12-11 15:25:44 -05:00
if [ [ ( $F_developerIgnoreInstallScript = = false ) || ( $dev != true ) ] ] ; then
2023-12-11 09:50:54 -05:00
if $F_hasInstallScript ; then
2024-01-15 15:39:39 -05:00
PRINT WARNING "Extension uses a custom installation script, proceed with caution."
2023-11-08 10:01:39 -05:00
chmod +x " .blueprint/extensions/ $identifier /private/install.sh "
2023-11-25 07:38:37 -05:00
2023-11-14 15:17:11 -05:00
# Run script while also parsing some useful variables for the install script to use.
2023-11-25 07:39:35 -05:00
EXTENSION_IDENTIFIER = " $identifier " \
EXTENSION_TARGET = " $target " \
EXTENSION_VERSION = " $version " \
PTERODACTYL_DIRECTORY = " $FOLDER " \
BLUEPRINT_VERSION = " $VERSION " \
BLUEPRINT_DEVELOPER = " $dev " \
2023-11-25 07:38:37 -05:00
bash " .blueprint/extensions/ $identifier /private/install.sh "
2023-10-16 14:20:25 -04:00
echo -e "\e[0m\x1b[0m\033[0m"
fi
2023-08-15 06:23:40 -04:00
fi
2023-06-02 10:37:38 -04:00
2023-07-20 09:36:58 -04:00
if [ [ $DUPLICATE != "y" ] ] ; then
2024-01-15 15:39:39 -05:00
PRINT INFO " Adding ' $identifier ' to active extensions list.. "
2023-11-08 10:01:39 -05:00
echo " ${ identifier } , " >> ".blueprint/extensions/blueprint/private/db/installed_extensions"
2023-08-15 06:23:40 -04:00
fi
2023-07-20 09:36:58 -04:00
2023-07-28 08:04:46 -04:00
if [ [ $dev != true ] ] ; then
2023-09-24 09:58:26 -04:00
if [ [ $DUPLICATE = = "y" ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT SUCCESS " $identifier has been updated. "
2023-09-24 09:58:26 -04:00
else
2024-01-15 12:34:11 -05:00
PRINT SUCCESS " $identifier has been installed. "
2023-09-24 09:58:26 -04:00
fi
2023-12-22 10:06:02 -05:00
sendTelemetry "FINISH_EXTENSION_INSTALLATION" >> $BLUEPRINT__DEBUG
2023-11-28 12:31:26 -05:00
elif [ [ $dev = = true ] ] ; then
2024-01-15 12:34:11 -05:00
PRINT SUCCESS " $identifier has been built. "
2023-12-22 10:06:02 -05:00
sendTelemetry "BUILD_DEVELOPMENT_EXTENSION" >> $BLUEPRINT__DEBUG
2023-08-15 06:23:40 -04:00
fi
2024-01-15 15:39:39 -05:00
exit 0 # success
2023-08-15 06:23:40 -04:00
fi
2023-03-22 05:20:59 -04:00
2023-07-30 07:28:03 -04:00
# -r, -remove
2023-08-15 06:23:40 -04:00
if [ [ ( $2 = = "-r" ) || ( $2 = = "-remove" ) ] ] ; then VCMD = "y"
2024-01-15 15:39:39 -05:00
if [ [ $(( $# - 2 )) != 1 ] ] ; then PRINT FATAL " Expected 1 argument but got $(( $# - 2 )) . " ; exit 2; fi
2023-07-30 07:28:03 -04:00
# Check if the extension is installed.
2024-01-15 15:39:39 -05:00
if [ [ $( cat ".blueprint/extensions/blueprint/private/db/installed_extensions" ) != *" $3 , " * ] ] ; then
PRINT FATAL " ' $3 ' is not installed or detected. "
exit 2
2023-08-15 06:23:40 -04:00
fi
2023-07-30 07:28:03 -04:00
2024-02-14 02:22:50 -05:00
if [ [ ( $FILE = = *".blueprint" ) ] ] ; then PRINT FATAL "Argument one must not end with '.blueprint'." ; exit 2; fi
2023-11-08 10:01:39 -05:00
if [ [ -f " .blueprint/extensions/ $3 /private/.store/conf.yml " ] ] ; then
2023-12-22 11:51:20 -05:00
eval " $( parse_yaml " .blueprint/extensions/ $3 /private/.store/conf.yml " conf_) "
2023-07-30 07:28:03 -04:00
# Add aliases for config values to make working with them easier.
2023-07-30 16:22:08 -04:00
name = " $conf_info_name " ;
2023-08-15 06:23:40 -04:00
identifier = " $conf_info_identifier "
description = " $conf_info_description "
2023-10-01 08:25:10 -04:00
flags = " $conf_info_flags " #(optional)
2023-08-15 06:23:40 -04:00
version = " $conf_info_version "
target = " $conf_info_target "
2023-10-01 08:25:10 -04:00
author = " $conf_info_author " #(optional)
icon = " $conf_info_icon " #(optional)
2023-07-30 16:22:08 -04:00
website = " $conf_info_website " ; #(optional)
2023-08-15 06:23:40 -04:00
admin_view = " $conf_admin_view "
2023-07-30 16:22:08 -04:00
admin_controller = " $conf_admin_controller " ; #(optional)
admin_css = " $conf_admin_css " ; #(optional)
admin_wrapper = " $conf_admin_wrapper " ; #(optional)
dashboard_css = " $conf_dashboard_css " ; #(optional)
2023-12-06 15:18:01 -05:00
dashboard_wrapper = " $conf_dashboard_wrapper " ; #(optional)
2023-12-28 19:58:12 -05:00
dashboard_components = " $conf_dashboard_components " ; #(optional)
2023-07-30 16:22:08 -04:00
data_directory = " $conf_data_directory " ; #(optional)
data_public = " $conf_data_public " ; #(optional)
database_migrations = " $conf_database_migrations " ; #(optional)
2023-07-30 07:28:03 -04:00
else
2024-01-15 15:39:39 -05:00
PRINT FATAL "Backup conf.yml could not be found."
PRINT FATAL "Extension configuration file not found or detected."
exit 1
2023-08-15 06:23:40 -04:00
fi
2023-07-30 07:28:03 -04:00
2024-01-15 15:39:39 -05:00
PRINT INPUT "Do you want to proceed with this transaction? Some files might not be removed properly. (y/N)"
2023-10-10 15:28:42 -04:00
read -r YN
2024-02-21 06:04:52 -05:00
if [ [ ( ( ${ YN } != "y" * ) && ( ${ YN } != "Y" * ) ) || ( ( ${ YN } = = "" ) ) ] ] ; then PRINT INFO "Extension removal cancelled." ; exit 1; fi
2023-07-31 05:10:39 -04:00
2024-01-14 18:43:11 -05:00
PRINT INFO "Searching and validating framework dependencies.."
2023-12-11 09:34:26 -05:00
depend
2023-12-11 09:33:33 -05:00
# Assign variables to extension flags.
2024-01-15 11:40:12 -05:00
PRINT INFO "Reading and assigning extension flags.."
2023-12-11 09:33:33 -05:00
assignflags
2023-12-11 09:50:54 -05:00
if $F_hasRemovalScript ; then
2024-01-15 15:39:39 -05:00
PRINT WARNING "Extension uses a custom removal script, proceed with caution."
2023-11-14 15:17:11 -05:00
chmod +x " .blueprint/extensions/ $identifier /private/remove.sh "
2023-11-25 07:38:37 -05:00
2023-11-14 15:17:11 -05:00
# Run script while also parsing some useful variables for the uninstall script to use.
2023-11-25 07:40:33 -05:00
EXTENSION_IDENTIFIER = " $identifier " \
EXTENSION_TARGET = " $target " \
EXTENSION_VERSION = " $version " \
PTERODACTYL_DIRECTORY = " $FOLDER " \
BLUEPRINT_VERSION = " $VERSION " \
2023-11-25 07:38:37 -05:00
bash " .blueprint/extensions/ $identifier /private/remove.sh "
2023-11-14 15:17:11 -05:00
echo -e "\e[0m\x1b[0m\033[0m"
fi
2023-07-30 12:22:10 -04:00
# Remove admin button
2024-01-15 15:39:39 -05:00
PRINT INFO "Editing 'extensions' admin page.."
2023-11-08 10:01:39 -05:00
OLDBUTTON_RESULT = $( cat " .blueprint/extensions/ $identifier /private/.store/build/button.blade.php " )
2023-10-26 07:05:04 -04:00
sed -i " s~ $OLDBUTTON_RESULT ~~g " "resources/views/admin/extensions.blade.php"
2023-07-30 12:22:10 -04:00
2023-10-01 08:25:10 -04:00
# Remove admin routes
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing admin routes.."
2024-02-14 02:32:44 -05:00
sed -n -i " /\/\/ $identifier :start/{p; :a; N; /\/\/ $identifier :stop/!ba; s/.*\n//}; p " "routes/blueprint.php"
2024-01-31 13:36:44 -05:00
sed -i \
-e " s~// $identifier :start~~g " \
-e " s~// $identifier :stop~~g " \
2024-02-14 02:32:44 -05:00
"routes/blueprint.php"
2023-09-30 11:33:38 -04:00
2023-07-30 07:28:03 -04:00
# Remove admin view
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing admin view directory.."
rm -r " resources/views/admin/extensions/ $identifier "
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove admin controller
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing admin controller directory.."
rm -r " app/Http/Controllers/Admin/Extensions/ $identifier "
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove admin css
2023-07-30 12:22:10 -04:00
if [ [ $admin_css != "" ] ] ; then
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing and unlinking admin css.."
2023-08-15 06:23:40 -04:00
updateCacheReminder
2023-12-03 12:48:41 -05:00
sed -i " s~@import url(/assets/extensions/ $identifier /admin.style.css);~~g " ".blueprint/extensions/blueprint/assets/admin.extensions.css"
2023-08-15 06:23:40 -04:00
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove admin wrapper
2023-07-30 12:22:10 -04:00
if [ [ $admin_wrapper != "" ] ] ; then
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing admin wrapper.."
2024-02-18 06:47:32 -05:00
sed -n -i " /<!--@ $identifier :s@-->/{p; :a; N; /<!--@ $identifier :e@-->/!ba; s/.*\n//}; p " "resources/views/blueprint/admin/admin.blade.php"
2024-01-31 13:36:44 -05:00
sed -i \
2024-02-09 07:04:47 -05:00
-e " s~<!--@ $identifier :s@-->~~g " \
-e " s~<!--@ $identifier :e@-->~~g " \
2024-02-18 06:47:32 -05:00
"resources/views/blueprint/admin/admin.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove dashboard wrapper
2023-07-30 12:22:10 -04:00
if [ [ $dashboard_wrapper != "" ] ] ; then
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing dashboard wrapper.."
2024-02-18 06:47:32 -05:00
sed -n -i " /<!--@ $identifier :s@-->/{p; :a; N; /<!--@ $identifier :e@-->/!ba; s/.*\n//}; p " "resources/views/blueprint/dashboard/dashboard.blade.php"
2024-01-31 13:36:44 -05:00
sed -i \
2024-02-09 07:04:47 -05:00
-e " s~<!--@ $identifier :s@-->~~g " \
-e " s~<!--@ $identifier :e@-->~~g " \
2024-02-18 06:47:32 -05:00
"resources/views/blueprint/dashboard/dashboard.blade.php"
2023-08-15 06:23:40 -04:00
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove dashboard css
2023-07-30 12:22:10 -04:00
if [ [ $dashboard_css != "" ] ] ; then
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing and unlinking dashboard css.."
2024-01-05 10:55:56 -05:00
sed -i " s~@import url(./imported/ $identifier .css);~~g " "resources/scripts/blueprint/css/extensions.css"
2023-12-28 11:56:33 -05:00
rm " resources/scripts/blueprint/css/imported/ $identifier .css "
2023-08-15 06:23:40 -04:00
YARN = "y"
fi
2023-07-30 12:22:10 -04:00
2023-12-28 19:58:12 -05:00
# Remove dashboard components
if [ [ $dashboard_components != "" ] ] ; then
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing and unlinking dashboard components.."
2023-12-28 19:58:12 -05:00
# fetch component config
eval " $( parse_yaml .blueprint/extensions/" $identifier " /components/Components.yml Components_) "
# define static variables to make stuff a bit easier
im = "\/\* blueprint\/import \*\/" ; re = "{/\* blueprint\/react \*/}" ; co = "resources/scripts/blueprint/components"
s = " import ${ identifier ^ } Component from ' " ; e = "';"
REMOVE_REACT( ) {
2024-01-05 19:34:31 -05:00
if [ [ ! $1 = = "" ] ] ; then
2023-12-28 19:58:12 -05:00
# remove components
2024-01-31 13:36:44 -05:00
sed -i \
-e "s~" " ${ s } @/blueprint/extensions/ ${ identifier } / $1 ${ e } " "~~g" \
-e "s~" " < ${ identifier ^ } Component /> " "~~g" \
" $co " /" $2 "
2023-12-28 19:58:12 -05:00
fi
}
2024-01-05 19:34:31 -05:00
# remove component items
2024-01-05 19:58:57 -05:00
# -> REMOVE_REACT "$Components_" "path/.tsx" "$OldComponents_"
2024-01-06 10:32:17 -05:00
# navigation
2024-01-05 19:34:31 -05:00
REMOVE_REACT " $Components_Navigation_NavigationBar_BeforeNavigation " "Navigation/NavigationBar/BeforeNavigation.tsx"
REMOVE_REACT " $Components_Navigation_NavigationBar_AdditionalItems " "Navigation/NavigationBar/AdditionalItems.tsx"
REMOVE_REACT " $Components_Navigation_NavigationBar_AfterNavigation " "Navigation/NavigationBar/AfterNavigation.tsx"
2024-01-06 17:07:18 -05:00
REMOVE_REACT " $Components_Navigation_SubNavigation_BeforeSubNavigation " "Navigation/SubNavigation/BeforeSubNavigation.tsx"
REMOVE_REACT " $Components_Navigation_SubNavigation_AdditionalServerItems " "Navigation/SubNavigation/AdditionalServerItems.tsx"
REMOVE_REACT " $Components_Navigation_SubNavigation_AdditionalAccountItems " "Navigation/SubNavigation/AdditionalAccountItems.tsx"
REMOVE_REACT " $Components_Navigation_SubNavigation_AfterSubNavigation " "Navigation/SubNavigation/AfterSubNavigation.tsx"
2024-01-05 19:34:31 -05:00
2024-01-06 15:24:36 -05:00
# dashboard
REMOVE_REACT " $Components_Dashboard_ServerRow_BeforeEntryName " "Dashboard/ServerRow/BeforeEntryName.tsx"
REMOVE_REACT " $Components_Dashboard_ServerRow_AfterEntryName " "Dashboard/ServerRow/AfterEntryName.tsx"
REMOVE_REACT " $Components_Dashboard_ServerRow_BeforeEntryDescription " "Dashboard/ServerRow/BeforeEntryDescription.tsx"
REMOVE_REACT " $Components_Dashboard_ServerRow_AfterEntryDescription " "Dashboard/ServerRow/AfterEntryDescription.tsx"
REMOVE_REACT " $Components_Dashboard_ServerRow_ResourceLimits " "Dashboard/ServerRow/ResourceLimits.tsx"
2024-01-31 16:14:11 -05:00
# authentication
REMOVE_REACT " $Components_Authentication_Container_BeforeContent " "Authentication/Container/BeforeContent.tsx"
REMOVE_REACT " $Components_Authentication_Container_AfterContent " "Authentication/Container/AfterContent.tsx"
2024-01-06 15:24:36 -05:00
2024-01-06 10:32:17 -05:00
# server
2024-01-05 19:34:31 -05:00
REMOVE_REACT " $Components_Server_Terminal_BeforeContent " "Server/Terminal/BeforeContent.tsx"
REMOVE_REACT " $Components_Server_Terminal_AfterContent " "Server/Terminal/AfterContent.tsx"
2024-01-06 15:24:36 -05:00
2024-01-05 19:34:31 -05:00
REMOVE_REACT " $Components_Server_Files_Browse_BeforeContent " "Server/Files/Browse/BeforeContent.tsx"
REMOVE_REACT " $Components_Server_Files_Browse_FileButtons " "Server/Files/Browse/FileButtons.tsx"
2024-01-06 15:40:40 -05:00
REMOVE_REACT " $Components_Server_Files_Browse_DropdownItems " "Server/Files/Browse/DropdownItems.tsx"
2024-01-05 19:34:31 -05:00
REMOVE_REACT " $Components_Server_Files_Browse_AfterContent " "Server/Files/Browse/AfterContent.tsx"
REMOVE_REACT " $Components_Server_Files_Edit_BeforeEdit " "Server/Files/Edit/BeforeEdit.tsx"
REMOVE_REACT " $Components_Server_Files_Edit_AfterEdit " "Server/Files/Edit/AfterEdit.tsx"
2024-01-06 15:24:36 -05:00
2024-01-05 19:58:57 -05:00
REMOVE_REACT " $Components_Server_Databases_BeforeContent " "Server/Databases/BeforeContent.tsx"
REMOVE_REACT " $Components_Server_Databases_AfterContent " "Server/Databases/AfterContent.tsx"
REMOVE_REACT " $Components_Server_Schedules_List_BeforeContent " "Server/Schedules/List/BeforeContent.tsx"
REMOVE_REACT " $Components_Server_Schedules_List_AfterContent " "Server/Schedules/List/AfterContent.tsx"
REMOVE_REACT " $Components_Server_Schedules_Edit_BeforeEdit " "Server/Schedules/Edit/BeforeEdit.tsx"
REMOVE_REACT " $Components_Server_Schedules_Edit_AfterEdit " "Server/Schedules/Edit/AfterEdit.tsx"
2024-01-05 20:48:45 -05:00
REMOVE_REACT " $Components_Server_Users_BeforeContent " "Server/Users/BeforeContent.tsx"
REMOVE_REACT " $Components_Server_Users_AfterContent " "Server/Users/AfterContent.tsx"
REMOVE_REACT " $Components_Server_Backups_BeforeContent " "Server/Backups/BeforeContent.tsx"
2024-01-06 15:40:40 -05:00
REMOVE_REACT " $Components_Server_Backups_DropdownItems " "Server/Backups/DropdownItems.tsx"
2024-01-05 20:48:45 -05:00
REMOVE_REACT " $Components_Server_Backups_AfterContent " "Server/Backups/AfterContent.tsx"
REMOVE_REACT " $Components_Server_Network_BeforeContent " "Server/Network/BeforeContent.tsx"
REMOVE_REACT " $Components_Server_Network_AfterContent " "Server/Network/AfterContent.tsx"
REMOVE_REACT " $Components_Server_Startup_BeforeContent " "Server/Startup/BeforeContent.tsx"
REMOVE_REACT " $Components_Server_Startup_AfterContent " "Server/Startup/AfterContent.tsx"
REMOVE_REACT " $Components_Server_Settings_BeforeContent " "Server/Settings/BeforeContent.tsx"
REMOVE_REACT " $Components_Server_Settings_AfterContent " "Server/Settings/AfterContent.tsx"
2024-01-06 15:24:36 -05:00
# account
REMOVE_REACT " $Components_Account_Overview_BeforeContent " "Account/Overview/BeforeContent.tsx"
REMOVE_REACT " $Components_Account_Overview_AfterContent " "Account/Overview/AfterContent.tsx"
REMOVE_REACT " $Components_Account_API_BeforeContent " "Account/API/BeforeContent.tsx"
REMOVE_REACT " $Components_Account_API_AfterContent " "Account/API/AfterContent.tsx"
REMOVE_REACT " $Components_Account_SSH_BeforeContent " "Account/SSH/BeforeContent.tsx"
REMOVE_REACT " $Components_Account_SSH_AfterContent " "Account/SSH/AfterContent.tsx"
2024-01-30 17:29:21 -05:00
rm -r $FOLDER /.blueprint/extensions/" $identifier " /components
rm -r $FOLDER /resources/scripts/blueprint/extensions/" $identifier "
2023-12-28 19:58:12 -05:00
YARN = "y"
fi
2024-01-30 15:16:17 -05:00
# Remove custom routes
PRINT INFO "Unlinking navigation routes.."
2024-01-31 13:36:44 -05:00
sed -i \
-e " s/\/\* ${ identifier ^ } ImportStart \*\/.*\/\* ${ identifier ^ } ImportEnd \*\/// " \
-e " s~/\* ${ identifier ^ } ImportStart \*/~~g " \
-e " s~/\* ${ identifier ^ } ImportEnd \*/~~g " \
\
-e " s/\/\* ${ identifier ^ } AccountRouteStart \*\/.*\/\* ${ identifier ^ } AccountRouteEnd \*\/// " \
-e " s~/\* ${ identifier ^ } AccountRouteStart \*~~g " \
-e " s~/\* ${ identifier ^ } AccountRouteEnd \*~~g " \
\
-e " s/\/\* ${ identifier ^ } ServerRouteStart \*\/.*\/\* ${ identifier ^ } ServerRouteEnd \*\/// " \
-e " s~/\* ${ identifier ^ } ServerRouteStart \*~~g " \
-e " s~/\* ${ identifier ^ } ServerRouteEnd \*~~g " \
\
"resources/scripts/blueprint/extends/routers/routes.ts"
2024-01-30 15:16:17 -05:00
2024-01-15 15:39:39 -05:00
# Remove private folder
PRINT INFO "Removing and unlinking private folder.."
rm -R " .blueprint/extensions/ $identifier /private "
2023-07-30 07:28:03 -04:00
# Remove public folder
2023-07-30 12:22:10 -04:00
if [ [ $data_public != "" ] ] ; then
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing and unlinking public folder.."
2024-01-31 13:36:44 -05:00
rm -R \
" .blueprint/extensions/ $identifier /public " \
" public/extensions/ $identifier "
2024-01-15 15:39:39 -05:00
fi
2023-07-30 12:22:10 -04:00
2023-07-30 07:28:03 -04:00
# Remove assets folder
2024-01-15 15:39:39 -05:00
PRINT INFO "Removing and unlinking assets folder.."
2024-01-31 13:36:44 -05:00
rm -R \
" .blueprint/extensions/ $identifier /assets " \
" public/assets/extensions/ $identifier "
2023-07-30 12:22:10 -04:00
2024-01-30 17:29:21 -05:00
# Remove extension directory
PRINT INFO "Removing extension folder.."
rm -R " .blueprint/extensions/ $identifier "
2023-07-30 15:02:48 -04:00
# Rebuild panel
if [ [ $YARN = = "y" ] ] ; then
2024-01-15 15:39:39 -05:00
PRINT INFO "Rebuilding panel assets.."
2024-02-18 11:17:01 -05:00
yarn run build:production --progress
2023-08-15 06:23:40 -04:00
fi
2023-07-30 15:02:48 -04:00
2024-01-15 12:34:11 -05:00
# Flush cache.
PRINT INFO "Flushing view, config and route cache.."
{
php artisan view:clear
php artisan config:clear
php artisan route:cache
2024-02-13 09:06:17 -05:00
php artisan cache:clear
2024-01-15 12:34:11 -05:00
} & >> $BLUEPRINT__DEBUG
2023-09-24 09:58:26 -04:00
# Remove from installed list
2024-01-15 15:39:39 -05:00
PRINT INFO " Removing ' $identifier ' from active extensions list.. "
2023-11-08 10:01:39 -05:00
sed -i " s~ $identifier ,~~g " ".blueprint/extensions/blueprint/private/db/installed_extensions"
2023-09-12 13:55:48 -04:00
2024-01-15 15:39:39 -05:00
PRINT SUCCESS " ' $identifier ' has been removed. "
2023-12-22 10:06:02 -05:00
sendTelemetry "FINISH_EXTENSION_REMOVAL" >> $BLUEPRINT__DEBUG
2024-01-15 15:39:39 -05:00
exit 0 # success
2023-08-15 06:23:40 -04:00
fi
2023-07-30 07:28:03 -04:00
2023-08-06 07:41:56 -04:00
2023-06-18 10:37:46 -04:00
# -v, -version
2023-08-15 06:23:40 -04:00
if [ [ ( $2 = = "-v" ) || ( $2 = = "-version" ) ] ] ; then VCMD = "y"
2023-10-24 08:53:17 -04:00
echo -e ${ VERSION }
2023-08-15 06:23:40 -04:00
fi
2023-04-10 10:50:23 -04:00
2024-01-31 13:36:44 -05:00
2023-12-22 10:06:02 -05:00
# -debug
if [ [ $2 = = "-debug" ] ] ; then VCMD = "y"
2024-01-15 15:39:39 -05:00
if [ [ $3 -lt 1 ] ] ; then PRINT FATAL "Provide the amount of debug lines to print as an argument, which must be greater than one (1)." ; exit 2; fi
2023-12-22 10:06:02 -05:00
echo -e "\x1b[30;47;1m --- DEBUG START --- \x1b[0m"
2023-12-22 11:51:20 -05:00
echo -e " $( v = " $( <.blueprint/extensions/blueprint/private/debug/logs.txt) " ; printf -- "%s" " $v " | tail -" $3 " ) "
2023-12-22 10:06:02 -05:00
echo -e "\x1b[30;47;1m --- DEBUG END --- \x1b[0m"
fi
2023-08-06 07:41:56 -04:00
2023-06-18 10:37:46 -04:00
# -init
2023-09-23 11:14:04 -04:00
if [ [ ( $2 = = "-init" || $2 = = "-I" ) ] ] ; then VCMD = "y"
2023-12-30 18:16:40 -05:00
# Check for developer mode through the database library.
2024-01-15 11:40:12 -05:00
if ! dbValidate "blueprint.developerEnabled" ; then PRINT FATAL "Developer mode is not enabled." ; exit 2; fi
2023-07-03 08:42:01 -04:00
2023-08-31 04:51:44 -04:00
# To prevent accidental wiping of your dev directory, you are unable to initialize another extension
# until you wipe the contents of the .blueprint/dev directory.
2023-10-13 13:43:33 -04:00
if [ [ -n $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory contains files. To protect you against accidental data loss, you are unable to initialize another extension unless you clear the '.blueprint/dev' folder."
exit 2
2023-08-15 06:23:40 -04:00
fi
2023-07-28 16:12:59 -04:00
2023-09-23 09:36:32 -04:00
ask_template( ) {
2024-01-16 13:19:49 -05:00
PRINT INPUT "Choose an extension template:"
2024-01-15 17:59:30 -05:00
echo -e " $( curl 'https://raw.githubusercontent.com/teamblueprint/templates/main/repository' 2>> $BLUEPRINT__DEBUG ) "
2023-10-10 15:28:42 -04:00
read -r ASKTEMPLATE
2023-09-23 09:36:32 -04:00
REDO_TEMPLATE = false
2023-10-24 08:53:17 -04:00
# Template should not be empty
if [ [ ${ ASKTEMPLATE } = = "" ] ] ; then
2024-01-15 17:59:30 -05:00
PRINT WARNING "Template should not be empty."
2023-09-23 09:36:32 -04:00
REDO_TEMPLATE = true
fi
# Unknown template.
2023-12-22 10:06:02 -05:00
if [ [ $( echo -e " $( curl " https://raw.githubusercontent.com/teamblueprint/templates/main/ ${ ASKTEMPLATE } /TemplateConfiguration.yml " 2>> $BLUEPRINT__DEBUG ) " ) = = "404: Not Found" ] ] ; then
2024-01-15 17:59:30 -05:00
PRINT WARNING "Unknown template, please choose a valid option."
2023-09-23 09:36:32 -04:00
REDO_TEMPLATE = true
fi
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_TEMPLATE } = = true ] ] ; then ASKTEMPLATE = "" ; ask_template; fi
2023-09-23 09:36:32 -04:00
}
2023-07-03 08:42:01 -04:00
ask_name( ) {
2024-01-15 17:59:30 -05:00
PRINT INPUT "Name [SpaceInvaders]:"
2023-10-10 15:28:42 -04:00
read -r ASKNAME
2023-08-15 06:23:40 -04:00
REDO_NAME = false
2023-07-03 08:42:01 -04:00
# Name should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKNAME } = = "" ] ] ; then
2024-01-15 17:59:30 -05:00
PRINT WARNING "Name should not be empty."
2023-08-15 06:23:40 -04:00
REDO_NAME = true
fi
2023-07-03 08:42:01 -04:00
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_NAME } = = true ] ] ; then ASKNAME = "" ; ask_name; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
ask_identifier( ) {
2024-01-15 17:59:30 -05:00
PRINT INPUT "Identifier [spaceinvaders]:"
2023-10-10 15:28:42 -04:00
read -r ASKIDENTIFIER
2023-08-15 06:23:40 -04:00
REDO_IDENTIFIER = false
2023-07-03 08:42:01 -04:00
# Identifier should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKIDENTIFIER } = = "" ] ] ; then
2024-01-15 17:59:30 -05:00
PRINT WARNING "Identifier should not be empty."
2023-08-15 06:23:40 -04:00
REDO_IDENTIFIER = true
fi
2023-07-03 08:42:01 -04:00
# Identifier should be a-z.
2024-01-15 17:59:30 -05:00
if ! [ [ ${ ASKIDENTIFIER } = ~ [ a-z] ] ] ; then
PRINT WARNING "Identifier should only contain a-z characters."
2023-08-15 06:23:40 -04:00
REDO_IDENTIFIER = true
fi
2023-07-03 08:42:01 -04:00
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_IDENTIFIER } = = true ] ] ; then ASKIDENTIFIER = "" ; ask_identifier; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
ask_description( ) {
2024-01-15 17:59:30 -05:00
PRINT INPUT "Description [Shoot down space aliens!]:"
2023-10-10 15:28:42 -04:00
read -r ASKDESCRIPTION
2023-08-15 06:23:40 -04:00
REDO_DESCRIPTION = false
2023-07-03 08:42:01 -04:00
# Description should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKDESCRIPTION } = = "" ] ] ; then
2024-01-15 17:59:30 -05:00
PRINT WARNING "Description should not be empty."
2023-08-15 06:23:40 -04:00
REDO_DESCRIPTION = true
fi
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_DESCRIPTION } = = true ] ] ; then ASKDESCRIPTION = "" ; ask_description; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
ask_version( ) {
2024-01-15 17:59:30 -05:00
PRINT INPUT "Version [1.0]:"
2023-10-10 15:28:42 -04:00
read -r ASKVERSION
2023-08-15 06:23:40 -04:00
REDO_VERSION = false
2023-07-03 08:42:01 -04:00
# Version should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKVERSION } = = "" ] ] ; then
2024-01-15 17:59:30 -05:00
PRINT WARNING "Version should not be empty."
2023-08-15 06:23:40 -04:00
REDO_VERSION = true
fi
2023-07-03 08:42:01 -04:00
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_VERSION } = = true ] ] ; then ASKVERSION = "" ; ask_version; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
ask_author( ) {
2024-01-15 17:59:30 -05:00
PRINT INPUT "Author [byte]:"
2023-10-10 15:28:42 -04:00
read -r ASKAUTHOR
2023-08-15 06:23:40 -04:00
REDO_AUTHOR = false
2023-07-03 08:42:01 -04:00
# Author should not be empty
2023-10-24 08:53:17 -04:00
if [ [ ${ ASKAUTHOR } = = "" ] ] ; then
2024-01-15 17:23:54 -05:00
PRINT WARNING "Author should not be empty."
2023-08-15 06:23:40 -04:00
REDO_AUTHOR = true
fi
2024-02-13 09:09:18 -05:00
# Ask again if response does not pass validation.
if [ [ ${ REDO_AUTHOR } = = true ] ] ; then ASKAUTHOR = "" ; ask_author; fi
2023-08-15 06:23:40 -04:00
}
2023-07-03 08:42:01 -04:00
2023-09-23 10:07:49 -04:00
ask_template
2023-08-15 06:23:40 -04:00
ask_name
ask_identifier
ask_description
ask_version
ask_author
2023-06-02 10:37:38 -04:00
2023-10-24 09:00:28 -04:00
tnum = ${ ASKTEMPLATE }
2024-01-15 17:59:30 -05:00
PRINT INFO "Fetching templates.."
2024-02-14 02:21:09 -05:00
if [ [ $( php artisan bp:latest) != " $VERSION " ] ] ; then PRINT WARNING "Active Blueprint version is not latest, you might run into compatibility issues." ; fi
2024-01-15 17:59:30 -05:00
cd .blueprint/tmp || cdhalt
2023-10-13 14:13:35 -04:00
git clone "https://github.com/teamblueprint/templates.git"
2024-01-15 17:59:30 -05:00
cd ${ FOLDER } /.blueprint || cdhalt
2023-11-08 10:01:39 -05:00
cp -R tmp/templates/* extensions/blueprint/private/build/templates/
2023-10-13 14:25:35 -04:00
rm -R tmp/templates
2024-01-15 17:59:30 -05:00
cd ${ FOLDER } || cdhalt
2023-10-13 14:13:35 -04:00
2023-12-22 07:15:54 -05:00
eval " $( parse_yaml .blueprint/extensions/blueprint/private/build/templates/" ${ tnum } " /TemplateConfiguration.yml t_) "
2023-09-23 10:07:49 -04:00
2024-01-15 17:59:30 -05:00
PRINT INFO "Building template.."
2023-08-15 06:23:40 -04:00
mkdir -p .blueprint/tmp/init
2023-12-17 06:57:26 -05:00
cp -R .blueprint/extensions/blueprint/private/build/templates/" ${ tnum } " /contents/* .blueprint/tmp/init/
2023-06-02 10:37:38 -04:00
2024-01-31 13:36:44 -05:00
sed -i \
-e " s~␀name␀~ ${ ASKNAME } ~g " \
-e " s~␀identifier␀~ ${ ASKIDENTIFIER } ~g " \
-e " s~␀description␀~ ${ ASKDESCRIPTION } ~g " \
-e " s~␀ver␀~ ${ ASKVERSION } ~g " \
-e " s~␀author␀~ ${ ASKAUTHOR } ~g " \
-e " s~␀version␀~ ${ VERSION } ~g " \
2024-02-09 07:04:47 -05:00
-e " s~\[name\]~ ${ ASKNAME } ~g " \
-e " s~\[identifier\]~ ${ ASKIDENTIFIER } ~g " \
-e " s~\[description\]~ ${ ASKDESCRIPTION } ~g " \
-e " s~\[ver\]~ ${ ASKVERSION } ~g " \
-e " s~\[author\]~ ${ ASKAUTHOR } ~g " \
-e " s~\[version\]~ ${ VERSION } ~g " \
2024-01-31 13:36:44 -05:00
".blueprint/tmp/init/conf.yml"
2023-06-02 10:37:38 -04:00
# Return files to folder.
2023-08-15 06:23:40 -04:00
cp -R .blueprint/tmp/init/* .blueprint/dev/
2023-06-02 10:37:38 -04:00
2023-06-10 08:52:00 -04:00
# Remove tmp files.
2024-01-15 17:59:30 -05:00
PRINT INFO "Cleaning up build files.."
2024-01-31 13:36:44 -05:00
rm -R \
".blueprint/tmp" \
".blueprint/extensions/blueprint/private/build/templates/" *
2023-08-15 06:23:40 -04:00
mkdir -p .blueprint/tmp
2023-06-02 10:37:38 -04:00
2023-12-22 10:06:02 -05:00
sendTelemetry "INITIALIZE_DEVELOPMENT_EXTENSION" >> $BLUEPRINT__DEBUG
2023-09-19 13:30:46 -04:00
2024-01-31 13:36:44 -05:00
PRINT SUCCESS "Extension files initialized and imported to '.blueprint/dev'."
2023-08-15 06:23:40 -04:00
fi
2023-05-17 03:55:16 -04:00
2023-08-06 07:41:56 -04:00
2023-06-28 15:31:22 -04:00
# -build
2023-09-23 11:14:04 -04:00
if [ [ ( $2 = = "-build" || $2 = = "-b" ) ] ] ; then VCMD = "y"
2023-12-30 18:16:40 -05:00
# Check for developer mode through the database library.
2024-01-15 11:40:12 -05:00
if ! dbValidate "blueprint.developerEnabled" ; then PRINT FATAL "Developer mode is not enabled." ; exit 2; fi
2023-08-07 09:53:49 -04:00
2023-10-13 13:43:33 -04:00
if [ [ -z $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory is empty."
2024-01-15 11:40:12 -05:00
exit 2
2023-08-15 06:23:40 -04:00
fi
2024-01-15 11:40:12 -05:00
PRINT INFO "Starting developer extension installation.."
2024-02-08 12:45:14 -05:00
blueprint -i "[developer-build]"
2023-08-15 06:23:40 -04:00
fi
2023-05-04 16:01:35 -04:00
2023-08-06 07:41:56 -04:00
2023-06-24 04:55:21 -04:00
# -export
2023-09-23 11:14:04 -04:00
if [ [ ( $2 = = "-export" || $2 = = "-e" ) ] ] ; then VCMD = "y"
2023-12-30 18:16:40 -05:00
# Check for developer mode through the database library.
2024-01-15 11:40:12 -05:00
if ! dbValidate "blueprint.developerEnabled" ; then PRINT FATAL "Developer mode is not enabled." ; exit 2; fi
2023-08-15 06:05:59 -04:00
2023-10-13 13:43:33 -04:00
if [ [ -z $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory is empty."
2024-01-15 11:40:12 -05:00
exit 2
2023-08-15 06:23:40 -04:00
fi
2023-08-04 06:47:25 -04:00
2024-01-15 11:40:12 -05:00
PRINT INFO "Start packaging extension.."
2023-05-29 14:33:01 -04:00
2024-01-15 17:59:30 -05:00
cd .blueprint || cdhalt
2023-12-22 10:06:02 -05:00
rm dev/.gitkeep 2>> $BLUEPRINT__DEBUG
2023-11-23 13:02:33 -05:00
2023-11-23 09:52:16 -05:00
eval " $( parse_yaml dev/conf.yml conf_) " ; identifier = " ${ conf_info_identifier } "
2023-11-23 13:02:33 -05:00
2024-01-31 13:36:44 -05:00
cp -r dev/* tmp/
2024-01-15 17:59:30 -05:00
cd tmp || cdhalt
2023-11-23 13:02:33 -05:00
2023-12-11 09:50:54 -05:00
# Assign variables to extension flags.
flags = " $conf_info_flags "
2024-01-15 11:40:12 -05:00
PRINT INFO "Reading and assigning extension flags.."
2023-12-11 09:50:54 -05:00
assignflags
if $F_hasExportScript ; then
2023-11-23 13:12:53 -05:00
chmod +x " ${ conf_data_directory } " "/export.sh"
2023-11-25 07:38:37 -05:00
2023-11-23 13:12:53 -05:00
# Run script while also parsing some useful variables for the export script to use.
2023-11-25 07:38:37 -05:00
EXTENSION_IDENTIFIER = " $conf_info_identifier " \
EXTENSION_TARGET = " $conf_info_target " \
EXTENSION_VERSION = " $conf_info_version " \
PTERODACTYL_DIRECTORY = " $FOLDER " \
BLUEPRINT_EXPORT_DIRECTORY = " $FOLDER /.blueprint/tmp " \
BLUEPRINT_VERSION = " $VERSION " \
bash " ${ conf_data_directory } " "/export.sh"
2023-11-23 13:12:53 -05:00
echo -e "\e[0m\x1b[0m\033[0m"
fi
2023-11-23 13:02:33 -05:00
2023-12-22 11:51:20 -05:00
zip -r extension.zip ./*
2024-01-15 17:59:30 -05:00
cd ${ FOLDER } || cdhalt
2023-12-17 06:40:57 -05:00
cp .blueprint/tmp/extension.zip " ${ identifier } .blueprint "
2023-08-15 06:23:40 -04:00
rm -R .blueprint/tmp
mkdir -p .blueprint/tmp
2023-06-26 08:42:31 -04:00
2023-10-31 06:28:47 -04:00
if [ [ $3 = = "expose" * ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT INFO "Generating download url.. (expires after 2 minutes)"
2023-11-01 05:54:10 -04:00
randstr = ${ RANDOM } ${ RANDOM } ${ RANDOM } ${ RANDOM } ${ RANDOM }
2023-11-08 10:01:39 -05:00
mkdir .blueprint/extensions/blueprint/assets/exports/${ randstr }
2023-12-17 06:57:26 -05:00
cp " ${ identifier } " .blueprint .blueprint/extensions/blueprint/assets/exports/${ randstr } /" ${ identifier } " .blueprint
2023-10-31 06:50:41 -04:00
2023-12-22 10:06:02 -05:00
sendTelemetry "EXPOSE_DEVELOPMENT_EXTENSION" >> $BLUEPRINT__DEBUG
2024-01-15 16:09:31 -05:00
PRINT SUCCESS " Extension has been exported to ' $( grabAppUrl) /assets/extensions/blueprint/exports/ ${ randstr } / ${ identifier } .blueprint' and ' ${ FOLDER } / ${ identifier } .blueprint'. "
2023-10-31 06:50:41 -04:00
2023-12-22 11:51:20 -05:00
eval " $( sleep 120 && rm -R .blueprint/extensions/blueprint/assets/exports/${ randstr } 2>> $BLUEPRINT__DEBUG ) " &
2023-10-31 06:28:47 -04:00
else
2023-12-22 10:06:02 -05:00
sendTelemetry "EXPORT_DEVELOPMENT_EXTENSION" >> $BLUEPRINT__DEBUG
2024-01-15 16:09:31 -05:00
PRINT SUCCESS " Extension has been exported to ' ${ FOLDER } / ${ identifier } .blueprint'. "
2023-10-31 06:28:47 -04:00
fi
2023-09-23 11:14:04 -04:00
fi
# -wipe
if [ [ ( $2 = = "-wipe" || $2 = = "-w" ) ] ] ; then VCMD = "y"
2023-12-30 18:16:40 -05:00
# Check for developer mode through the database library.
2024-01-15 11:40:12 -05:00
if ! dbValidate "blueprint.developerEnabled" ; then PRINT FATAL "Developer mode is not enabled." ; exit 2; fi
2023-10-25 13:02:33 -04:00
2023-10-13 13:43:33 -04:00
if [ [ -z $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory is empty."
2024-01-16 15:33:37 -05:00
exit 2
2023-09-24 09:58:26 -04:00
fi
2024-01-15 16:09:31 -05:00
PRINT INPUT "You are about to wipe all of your development files, are you sure you want to continue? This cannot be undone. (y/N)"
2023-10-10 15:28:42 -04:00
read -r YN
2024-01-15 16:09:31 -05:00
if [ [ ( ( ${ YN } != "y" * ) && ( ${ YN } != "Y" * ) ) || ( ( ${ YN } = = "" ) ) ] ] ; then PRINT INFO "Development files removal cancelled." ; exit 1; fi
2023-09-23 11:14:04 -04:00
2024-01-15 16:09:31 -05:00
PRINT INFO "Clearing development folder.."
2024-01-31 13:36:44 -05:00
rm -R \
.blueprint/dev/* \
.blueprint/dev/.* \
2>> $BLUEPRINT__DEBUG
2023-09-23 11:14:04 -04:00
2024-01-15 16:09:31 -05:00
PRINT SUCCESS "Development folder has been cleared."
2023-08-15 06:23:40 -04:00
fi
2023-05-29 14:33:01 -04:00
2024-01-31 13:36:44 -05:00
2023-11-02 14:14:06 -04:00
# -info
if [ [ ( $2 = = "-info" || $2 = = "-f" ) ] ] ; then VCMD = "y"
2024-01-20 08:19:51 -05:00
fetchversion( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $VERSION != "" ] ] ; then echo $VERSION ; else echo "none" ; fi }
fetchfolder( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $FOLDER != "" ] ] ; then echo $FOLDER ; else echo "none" ; fi }
fetchurl( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( grabAppUrl) != "" ] ] ; then grabAppUrl; else echo "none" ; fi }
fetchlocale( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( grabAppLocale) != "" ] ] ; then grabAppLocale; else echo "none" ; fi }
fetchtimezone( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( grabAppTimezone) != "" ] ] ; then grabAppTimezone; else echo "none" ; fi }
fetchextensions( ) { printf "\x1b[0m\x1b[37m" ; tr -cd ',' <.blueprint/extensions/blueprint/private/db/installed_extensions | wc -c | tr -d ' ' ; }
fetchdeveloper( ) { printf "\x1b[0m\x1b[37m" ; if dbValidate "blueprint.developerEnabled" ; then echo "true" ; else echo "false" ; fi ; }
fetchtelemetry( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( cat .blueprint/extensions/blueprint/private/db/telemetry_id) = = "KEY_NOT_UPDATED" ] ] ; then echo "false" ; else echo "true" ; fi ; }
fetchnode( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( node -v) != "" ] ] ; then node -v; else echo "none" ; fi }
fetchyarn( ) { printf "\x1b[0m\x1b[37m" ; if [ [ $( yarn -v) != "" ] ] ; then yarn -v; else echo "none" ; fi }
echo " "
echo -e " \x1b[34;1m ⣿⣿ Version: $( fetchversion) "
echo -e " \x1b[34;1m ⣿⣿ ⣿⣿ Folder: $( fetchfolder) "
echo -e " \x1b[34;1m ⣿⣿⣿⣿ URL: $( fetchurl) "
echo -e " \x1b[34;1m Locale: $( fetchlocale) "
echo -e " \x1b[34;1m Timezone: $( fetchtimezone) "
echo -e " \x1b[34;1m Extensions: $( fetchextensions) "
echo -e " \x1b[34;1m Developer: $( fetchdeveloper) "
echo -e " \x1b[34;1m Telemetry: $( fetchtelemetry) "
echo -e " \x1b[34;1m Node: $( fetchnode) "
echo -e " \x1b[34;1m Yarn: $( fetchyarn) "
echo -e "\x1b[0m"
2023-11-02 14:14:06 -04:00
fi
2023-08-06 07:41:56 -04:00
2024-01-31 13:36:44 -05:00
2023-08-14 07:28:15 -04:00
# -rerun-install
2023-11-02 14:14:06 -04:00
if [ [ $2 = = "-rerun-install" ] ] ; then VCMD = "y"
2024-01-15 16:09:31 -05:00
PRINT WARNING "This is an advanced feature, only proceed if you know what you are doing."
2023-08-15 06:23:40 -04:00
dbRemove "blueprint.setupFinished"
2024-01-15 17:59:30 -05:00
cd ${ FOLDER } || cdhalt
2023-08-15 06:23:40 -04:00
bash blueprint.sh
fi
2023-06-01 15:25:15 -04:00
2024-01-31 13:36:44 -05:00
2023-06-18 10:37:46 -04:00
# -upgrade
2023-08-15 06:23:40 -04:00
if [ [ $2 = = "-upgrade" ] ] ; then VCMD = "y"
2024-01-15 16:09:31 -05:00
PRINT WARNING "This is an advanced feature, only proceed if you know what you are doing."
2023-07-14 04:39:26 -04:00
2023-10-13 13:43:33 -04:00
if [ [ -n $( find .blueprint/dev -maxdepth 1 -type f -not -name ".gitkeep" -print -quit) ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "Development directory contains files. To protect you against accidental data loss, you are unable to upgrade unless you clear the '.blueprint/dev' folder."
exit 2
2023-08-15 06:23:40 -04:00
fi
2023-07-14 04:39:26 -04:00
2023-12-22 07:31:44 -05:00
# Confirmation question for developer upgrade.
if [ [ $3 = = "dev" ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT INPUT "Upgrading to the latest development build will update Blueprint to an unstable work-in-progress preview of the next version. Continue? (y/N)"
2023-12-22 07:31:44 -05:00
read -r YN
2024-01-15 16:09:31 -05:00
if [ [ ( ${ YN } != "y" * ) && ( ${ YN } != "Y" * ) ] ] ; then PRINT INFO "Upgrade cancelled." ; exit 1; fi
2023-12-22 07:31:44 -05:00
YN = ""
2023-08-15 06:23:40 -04:00
fi
2023-12-22 07:31:44 -05:00
# Confirmation question for both developer and stable upgrade.
2024-01-15 16:09:31 -05:00
PRINT INPUT "Upgrading will wipe your .blueprint folder and will deactivate all active extensions. Continue? (y/N)"
2023-12-22 07:31:44 -05:00
read -r YN
2024-01-15 16:09:31 -05:00
if [ [ ( ${ YN } != "y" * ) && ( ${ YN } != "Y" * ) ] ] ; then PRINT INFO "Upgrade cancelled." ; exit 1; fi
2023-12-22 07:31:44 -05:00
YN = ""
# Last confirmation question for both developer and stable upgrade.
2024-01-15 16:09:31 -05:00
PRINT INPUT "This is the last warning before upgrading/wiping Blueprint. Type 'continue' to continue, all other input will be taken as 'no'."
2023-12-22 07:31:44 -05:00
read -r YN
2024-01-15 16:09:31 -05:00
if [ [ ${ YN } != "continue" ] ] ; then PRINT INFO "Upgrade cancelled." ; exit 1; fi
2023-12-22 07:31:44 -05:00
YN = ""
2023-08-15 06:23:40 -04:00
2024-01-15 16:09:31 -05:00
if [ [ $3 = = "dev" ] ] ; then PRINT INFO "Fetching and pulling latest commit.."
else PRINT INFO "Fetching and pulling latest release.." ; fi
2023-08-15 06:23:40 -04:00
cp blueprint.sh .blueprint.sh.bak
2024-01-18 05:03:13 -05:00
mkdir $FOLDER /.tmp
cd $FOLDER /.tmp || cdhalt
if [ [ $3 = = "dev" ] ] ; then
# download latest commit
git clone https://github.com/teamblueprint/main.git
else
# download latest release
LOCATION = $( curl -s https://api.github.com/repos/teamblueprint/main/releases/latest \
| grep "zipball_url" \
| awk '{ print $2 }' \
| sed 's/,$//' \
| sed 's/"//g' ) \
; curl -L -o main.zip " $LOCATION "
unzip main.zip
rm main.zip
mv ./* main
fi
cp -r main/* " $FOLDER " /
2024-01-31 13:36:44 -05:00
rm -r \
"main" \
" $FOLDER " /.blueprint \
" $FOLDER " /.tmp
2024-01-18 05:03:13 -05:00
cd $FOLDER || cdhalt
2023-12-22 07:31:44 -05:00
2023-08-15 06:23:40 -04:00
chmod +x blueprint.sh
2023-11-28 11:40:08 -05:00
sed -i -E " s|FOLDER=\"/var/www/pterodactyl\" #;|FOLDER=\" $FOLDER \" #;|g " $FOLDER /blueprint.sh
2024-02-24 09:11:01 -05:00
sed -i -E " s|OWNERSHIP=\"www-data:www-data\" #;|OWNERSHIP=\" $OWNERSHIP \" #;|g " $FOLDER /blueprint.sh
2023-11-28 11:40:08 -05:00
mv $FOLDER /blueprint $FOLDER /.blueprint;
bash blueprint.sh --post-upgrade
2023-12-22 07:31:44 -05:00
# Ask user if they'd like to migrate their database.
2024-01-15 12:34:11 -05:00
PRINT INPUT "Would you like to migrate your database? (Y/n)"
2023-12-22 07:31:44 -05:00
read -r YN
2024-01-15 12:34:11 -05:00
if [ [ ( $YN = = "y" * ) || ( $YN = = "Y" * ) || ( $YN = = "" ) ] ] ; then
PRINT INFO "Running database migrations.."
2023-08-16 12:45:50 -04:00
php artisan migrate --force
2023-06-10 08:52:00 -04:00
else
2024-01-15 12:34:11 -05:00
PRINT INFO "Database migrations have been skipped."
2023-08-15 06:23:40 -04:00
fi
2023-12-22 07:31:44 -05:00
YN = ""
2023-06-12 09:21:38 -04:00
2023-07-28 16:12:59 -04:00
# Post-upgrade checks.
2024-01-15 16:09:31 -05:00
PRINT INFO "Validating update.."
2023-08-15 06:23:40 -04:00
score = 0
2023-06-12 09:21:38 -04:00
2024-01-31 13:36:44 -05:00
if dbValidate "blueprint.setupFinished" ; then score = $(( score+1))
else PRINT WARNING "'blueprint.setupFinished' could not be detected or found." ; fi
2023-06-12 09:21:38 -04:00
2023-07-28 16:12:59 -04:00
# Finalize upgrade.
2023-10-24 09:04:22 -04:00
if [ [ ${ score } = = 1 ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT SUCCESS "Upgrade finished."
2023-08-15 06:23:40 -04:00
rm .blueprint.sh.bak
2024-01-15 16:09:31 -05:00
exit 0 # success
2023-10-24 09:04:22 -04:00
elif [ [ ${ score } = = 0 ] ] ; then
2024-01-15 16:09:31 -05:00
PRINT FATAL "All checks have failed. The 'blueprint.sh' file has been reverted."
2023-08-15 06:23:40 -04:00
rm blueprint.sh
mv .blueprint.sh.bak blueprint.sh
2024-01-15 16:09:31 -05:00
exit 1 # error
2023-06-10 08:52:00 -04:00
else
2024-01-15 16:09:31 -05:00
PRINT FATAL "Some checks have failed. The 'blueprint.sh' file has been reverted."
2023-08-15 06:23:40 -04:00
rm blueprint.sh
mv .blueprint.sh.bak blueprint.sh
2024-01-15 16:09:31 -05:00
exit 1 # error
2023-08-15 06:23:40 -04:00
fi
fi
2023-08-09 06:57:18 -04:00
# When the users attempts to run an invalid command.
2023-10-24 09:04:22 -04:00
if [ [ ${ VCMD } != "y" && $1 = = "-bash" ] ] ; then
2023-08-15 06:10:30 -04:00
# This is logged as a "fatal" error since it's something that is making Blueprint run unsuccessfully.
2024-01-15 17:59:30 -05:00
PRINT FATAL " ' $2 ' is not a valid command or argument. Use argument '-help' for a list of commands. "
2024-01-15 16:09:31 -05:00
exit 1
2023-11-24 11:00:08 -05:00
fi