Skip to content

Commit cccd05f

Browse files
committed
chore: Refactor code to improve SSH key handling and storage
1 parent 795af8d commit cccd05f

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

bootstrap/helpers/shared.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,8 +1236,6 @@ function parseLineForSudo(string $command, Server $server): string
12361236
function get_public_ips()
12371237
{
12381238
try {
1239-
echo "Refreshing public ips!\n";
1240-
$settings = \App\Models\InstanceSettings::get();
12411239
[$first, $second] = Process::concurrently(function (Pool $pool) {
12421240
$pool->path(__DIR__)->command('curl -4s https://ifconfig.io');
12431241
$pool->path(__DIR__)->command('curl -6s https://ifconfig.io');
@@ -1251,7 +1249,7 @@ function get_public_ips()
12511249

12521250
return;
12531251
}
1254-
$settings->update(['public_ipv4' => $ipv4]);
1252+
InstanceSettings::get()->update(['public_ipv4' => $ipv4]);
12551253
}
12561254
} catch (\Exception $e) {
12571255
echo "Error: {$e->getMessage()}\n";
@@ -1266,7 +1264,7 @@ function get_public_ips()
12661264

12671265
return;
12681266
}
1269-
$settings->update(['public_ipv6' => $ipv6]);
1267+
InstanceSettings::get()->update(['public_ipv6' => $ipv6]);
12701268
}
12711269
} catch (\Throwable $e) {
12721270
echo "Error: {$e->getMessage()}\n";

database/seeders/PopulateSshKeysDirectorySeeder.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public function run()
1919

2020
PrivateKey::chunk(100, function ($keys) {
2121
foreach ($keys as $key) {
22-
echo 'Storing key: '.$key->name."\n";
2322
$key->storeInFileSystem();
2423
}
2524
});

database/seeders/ProductionSeeder.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,13 @@ public function run(): void
101101
}
102102

103103
if (! isCloud() && config('coolify.is_windows_docker_desktop') == false) {
104-
echo "Checking localhost key.\n";
105104
$coolify_key_name = '@host.docker.internal';
106105
$ssh_keys_directory = Storage::disk('ssh-keys')->files();
107106
$coolify_key = collect($ssh_keys_directory)->firstWhere(fn ($item) => str($item)->contains($coolify_key_name));
108107

109108
$server = Server::find(0);
110109
$found = $server->privateKey;
111-
if ($found) {
112-
echo 'Private Key found in database.\n';
113-
if ($coolify_key) {
114-
echo "SSH key found for the Coolify host machine (localhost).\n";
115-
}
116-
} else {
110+
if (! $found) {
117111
if ($coolify_key) {
118112
$user = str($coolify_key)->before('@')->after('id.');
119113
$coolify_key = Storage::disk('ssh-keys')->get($coolify_key);

0 commit comments

Comments
 (0)