fix: refresh public ips on start
This commit is contained in:
parent
d7b359e432
commit
911e29f2ea
@ -20,6 +20,7 @@ class Init extends Command
|
||||
public function handle()
|
||||
{
|
||||
$this->alive();
|
||||
get_public_ips();
|
||||
$full_cleanup = $this->option('full-cleanup');
|
||||
$cleanup_deployments = $this->option('cleanup-deployments');
|
||||
if ($cleanup_deployments) {
|
||||
@ -56,6 +57,7 @@ public function handle()
|
||||
$this->cleanup_stucked_helper_containers();
|
||||
$this->call('cleanup:stucked-resources');
|
||||
}
|
||||
|
||||
private function restore_coolify_db_backup()
|
||||
{
|
||||
try {
|
||||
|
@ -29,11 +29,13 @@
|
||||
use Illuminate\Database\UniqueConstraintViolationException;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Process\Pool;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
@ -2011,3 +2013,37 @@ function parseLineForSudo(string $command, Server $server): string
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
function get_public_ips()
|
||||
{
|
||||
try {
|
||||
echo "Refreshing public ips!\n";
|
||||
$settings = InstanceSettings::get();
|
||||
[$first, $second] = Process::concurrently(function (Pool $pool) {
|
||||
$pool->path(__DIR__)->command('curl -4s https://ifconfig.io');
|
||||
$pool->path(__DIR__)->command('curl -6s https://ifconfig.io');
|
||||
});
|
||||
$ipv4 = $first->output();
|
||||
if ($ipv4) {
|
||||
$ipv4 = trim($ipv4);
|
||||
$validate_ipv4 = filter_var($ipv4, FILTER_VALIDATE_IP);
|
||||
if ($validate_ipv4 == false) {
|
||||
echo "Invalid ipv4: $ipv4\n";
|
||||
return;
|
||||
}
|
||||
$settings->update(['public_ipv4' => $ipv4]);
|
||||
}
|
||||
$ipv6 = $second->output();
|
||||
if ($ipv6) {
|
||||
$ipv6 = trim($ipv6);
|
||||
$validate_ipv6 = filter_var($ipv6, FILTER_VALIDATE_IP);
|
||||
if ($validate_ipv6 == false) {
|
||||
echo "Invalid ipv6: $ipv6\n";
|
||||
return;
|
||||
}
|
||||
$settings->update(['public_ipv6' => $ipv6]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: {$e->getMessage()}\n";
|
||||
}
|
||||
}
|
||||
|
@ -177,27 +177,7 @@ public function run(): void
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$settings = InstanceSettings::get();
|
||||
if (is_null($settings->public_ipv4)) {
|
||||
$ipv4 = Process::run('curl -4s https://ifconfig.io')->output();
|
||||
if ($ipv4) {
|
||||
$ipv4 = trim($ipv4);
|
||||
$ipv4 = filter_var($ipv4, FILTER_VALIDATE_IP);
|
||||
$settings->update(['public_ipv4' => $ipv4]);
|
||||
}
|
||||
}
|
||||
if (is_null($settings->public_ipv6)) {
|
||||
$ipv6 = Process::run('curl -6s https://ifconfig.io')->output();
|
||||
if ($ipv6) {
|
||||
$ipv6 = trim($ipv6);
|
||||
$ipv6 = filter_var($ipv6, FILTER_VALIDATE_IP);
|
||||
$settings->update(['public_ipv6' => $ipv6]);
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: {$e->getMessage()}\n";
|
||||
}
|
||||
get_public_ips();
|
||||
|
||||
$oauth_settings_seeder = new OauthSettingSeeder();
|
||||
$oauth_settings_seeder->run();
|
||||
|
Loading…
Reference in New Issue
Block a user