Feat: Populate SSH key folder
This commit is contained in:
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use App\Models\PrivateKey;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
public function up()
|
|
||||||
{
|
|
||||||
Storage::disk('ssh-keys')->deleteDirectory('');
|
|
||||||
Storage::disk('ssh-keys')->makeDirectory('');
|
|
||||||
|
|
||||||
Schema::table('private_keys', function (Blueprint $table) {
|
|
||||||
$table->boolean('is_server_ssh_key')->default(true);
|
|
||||||
$table->boolean('is_sftp_key')->default(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
PrivateKey::where('is_server_ssh_key', true)->chunk(100, function ($keys) {
|
|
||||||
foreach ($keys as $key) {
|
|
||||||
$key->storeInFileSystem();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down()
|
|
||||||
{
|
|
||||||
Schema::table('private_keys', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('is_server_ssh_key');
|
|
||||||
$table->dropColumn('is_sftp_key');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use App\Models\PrivateKey;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Storage::disk('ssh-keys')->deleteDirectory('');
|
||||||
|
Storage::disk('ssh-keys')->makeDirectory('');
|
||||||
|
|
||||||
|
PrivateKey::chunk(100, function ($keys) {
|
||||||
|
foreach ($keys as $key) {
|
||||||
|
$key->storeInFileSystem();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Storage::disk('ssh-keys')->deleteDirectory('');
|
||||||
|
Storage::disk('ssh-keys')->makeDirectory('');
|
||||||
|
}
|
||||||
|
};
|
@@ -25,7 +25,6 @@ AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV
|
|||||||
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
||||||
-----END OPENSSH PRIVATE KEY-----
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
',
|
',
|
||||||
'is_server_ssh_key' => true,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
PrivateKey::create([
|
PrivateKey::create([
|
||||||
|
Reference in New Issue
Block a user