refactor: Update PrivateKey model to improve code readability and maintainability
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\PrivateKey;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PopulateSshKeysDirectorySeeder extends Seeder
|
||||
{
|
||||
@@ -12,11 +13,17 @@ class PopulateSshKeysDirectorySeeder extends Seeder
|
||||
{
|
||||
Storage::disk('ssh-keys')->deleteDirectory('');
|
||||
Storage::disk('ssh-keys')->makeDirectory('');
|
||||
Storage::disk('ssh-mux')->deleteDirectory('');
|
||||
Storage::disk('ssh-mux')->makeDirectory('');
|
||||
|
||||
PrivateKey::chunk(100, function ($keys) {
|
||||
foreach ($keys as $key) {
|
||||
echo 'Storing key: '.$key->name."\n";
|
||||
$key->storeInFileSystem();
|
||||
}
|
||||
});
|
||||
|
||||
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/keys'));
|
||||
Process::run('chown -R 9999:9999 '.storage_path('app/ssh/mux'));
|
||||
}
|
||||
}
|
||||
|
@@ -123,6 +123,7 @@ class ProductionSeeder extends Seeder
|
||||
]);
|
||||
$server->update(['user' => $user]);
|
||||
echo "SSH key found for the Coolify host machine (localhost).\n";
|
||||
|
||||
} else {
|
||||
PrivateKey::create(
|
||||
[
|
||||
|
Reference in New Issue
Block a user