feat(core): Sync telemetry id and developer mode status through artisan command.
This commit is contained in:
parent
4d05f71f98
commit
aa3668285c
5 changed files with 55 additions and 14 deletions
44
app/Console/Commands/BlueprintFramework/SyncCommand.php
Normal file
44
app/Console/Commands/BlueprintFramework/SyncCommand.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Console\Commands\BlueprintFramework;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Pterodactyl\BlueprintFramework\Services\VariableService\BlueprintVariableService;
|
||||
use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;
|
||||
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||
|
||||
class SyncCommand extends Command
|
||||
{
|
||||
protected $description = 'Forward some database values to Blueprint.';
|
||||
protected $signature = 'bp:sync';
|
||||
|
||||
/**
|
||||
* TelemetryCommand constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
private BlueprintVariableService $bp,
|
||||
private BlueprintExtensionLibrary $blueprint,
|
||||
private SettingsRepositoryInterface $settings,
|
||||
) { parent::__construct(); }
|
||||
|
||||
/**
|
||||
* Handle execution of command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// The following code rerolls the panel identifier used for telemetry
|
||||
// when the version name changes.
|
||||
if ($this->settings->get('blueprint::panel:id') == "" || $this->bp->version() != $this->settings->get('blueprint::version:cache')) {
|
||||
if ($this->settings->get('blueprint::telemetry') == "") {$this->settings->set('blueprint::telemetry', "true");}
|
||||
if ($this->settings->get('blueprint::telemetry') == "false") {
|
||||
$this->bp->config('TELEMETRY_ID','KEY_NOT_UPDATED');
|
||||
} else {
|
||||
$this->settings->set('blueprint::panel:id', uniqid(rand())."@".$this->bp->version());
|
||||
$this->settings->set('blueprint::version:cache', $this->bp->version());
|
||||
$this->bp->config('TELEMETRY_ID',$this->settings->get("blueprint::panel:id"));
|
||||
}
|
||||
};
|
||||
// Sync developer mode option with the core of Blueprint.
|
||||
$this->bp->config('DEVELOPER', $this->settings->get('blueprint::developer'));
|
||||
}
|
||||
}
|
|
@ -43,13 +43,6 @@ class BlueprintExtensionController extends Controller
|
|||
*/
|
||||
public function index(): View
|
||||
{
|
||||
// The following code rerolls the panel identifier used for telemetry
|
||||
// when the version name changes.
|
||||
if ($this->settings->get('blueprint::panel:id') == "" || $this->bp->version() != $this->settings->get('blueprint::version:cache')) {
|
||||
$this->settings->set('blueprint::panel:id', uniqid(rand())."@".$this->bp->version());
|
||||
$this->settings->set('blueprint::version:cache', $this->bp->version());
|
||||
$this->bp->config('TELEMETRY_ID',$this->settings->get("blueprint::panel:id"));
|
||||
};
|
||||
// Sync developer mode option with the core of Blueprint.
|
||||
$this->bp->config('DEVELOPER', $this->settings->get('blueprint::developer'));
|
||||
return $this->view->make(
|
||||
|
|
17
blueprint.sh
17
blueprint.sh
|
@ -61,6 +61,7 @@ fi
|
|||
# Write environment variables.
|
||||
export BLUEPRINT__FOLDER=$FOLDER
|
||||
export BLUEPRINT__VERSION=$VERSION
|
||||
export NODE_OPTIONS=--openssl-legacy-provider
|
||||
|
||||
# Automatically navigate to the Pterodactyl directory when running the core.
|
||||
cd $FOLDER
|
||||
|
@ -110,9 +111,6 @@ if [[ $LIB__bash_colors == "missing" ]]; then
|
|||
log_yellowb() { echo -e "$1"; }
|
||||
fi
|
||||
|
||||
# Make sure yarn doesn't freak out when building the panel.
|
||||
export NODE_OPTIONS=--openssl-legacy-provider
|
||||
|
||||
|
||||
|
||||
# -config
|
||||
|
@ -128,8 +126,11 @@ if [[ "$1" == "-config" ]]; then
|
|||
# cDEVELOPER
|
||||
# Enable/Disable developer mode.
|
||||
if [[ $cDEVELOPER != "" ]]; then
|
||||
if [[ $cDEVELOPER == "true" ]]; then dbAdd "blueprint.developerEnabled"
|
||||
else dbRemove "blueprint.developerEnabled"; fi
|
||||
if [[ $cDEVELOPER == "true" ]]; then
|
||||
dbAdd "blueprint.developerEnabled"
|
||||
else
|
||||
dbRemove "blueprint.developerEnabled"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo .
|
||||
|
@ -279,6 +280,10 @@ if [[ $1 != "-bash" ]]; then
|
|||
log_bright "[INFO] Updating route cache to include recent changes.."
|
||||
php artisan route:cache &> /dev/null
|
||||
|
||||
# Sync some database values.
|
||||
log_bright "[INFO] Syncing database values.."
|
||||
php artisan bp:sync &> /dev/null
|
||||
|
||||
# Put application into production.
|
||||
log_bright "[INFO] Disable maintenance."
|
||||
php artisan up
|
||||
|
@ -875,7 +880,7 @@ fi
|
|||
if [[ ( $2 == "help" ) || ( $2 == "-help" ) || ( $2 == "--help" ) ||
|
||||
( $2 == "h" ) || ( $2 == "-h" ) || ( $2 == "--h" ) ]]; then VCMD="y"
|
||||
|
||||
if [[ $(cat .blueprint/data/internal/db/developer) == "true"* ]]; then
|
||||
if dbValidate "blueprint.developerEnabled"; then
|
||||
help_dev_status=""
|
||||
help_dev_primary="\e[34;1m"
|
||||
help_dev_secondary="\e[34m"
|
||||
|
|
0
blueprint/tmp/.gitkeep
Normal file
0
blueprint/tmp/.gitkeep
Normal file
|
@ -1 +0,0 @@
|
|||
This folder contains temp files for Blueprint. When this folder is deleted, Blueprint may not function correctly.
|
Loading…
Reference in a new issue