provision script fixes, flash the server creds to the user on server create
This commit is contained in:
@@ -94,6 +94,10 @@ class ServerController extends Controller
|
||||
sudoPassword: $sudoPassword,
|
||||
))->delay(now()->addSeconds(30));
|
||||
|
||||
session()->flash('server-credentials', [
|
||||
'sudo_password' => $sudoPassword,
|
||||
]);
|
||||
|
||||
return redirect()->route('servers.show', ['organisation' => $organisation->id, 'server' => $server->id]);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ class HandleInertiaRequests extends Middleware
|
||||
'name' => config('app.name'),
|
||||
'organisation' => $request->route('organisation') ? Organisation::with('applications')->findOrFail($request->route('organisation')) : null,
|
||||
'application' => $request->route('application') ? Application::with('environments')->findOrFail($request->route('application')) : null,
|
||||
'flash' => [
|
||||
'server_credentials' => $request->session()->has('sudo_password') ? [
|
||||
'sudo_password' => $request->session()->get('sudo_password'),
|
||||
] : null,
|
||||
],
|
||||
'auth' => [
|
||||
'user' => $request->user()?->load('organisations'),
|
||||
],
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# [!hostname!] - server hostname
|
||||
# [!sudo_password!] - the sudo password to set
|
||||
# [!server_id!] - the servers id
|
||||
# [!keystonepublickey!] - keystone's public key
|
||||
|
||||
apt_wait() {
|
||||
while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
|
||||
@@ -74,7 +75,7 @@ usermod --password $PASSWORD keystone
|
||||
# Build Formatted Keys & Copy Keys To Keystone
|
||||
cat >/root/.ssh/authorized_keys <<EOF
|
||||
# Keystone
|
||||
@TODO INJECT KEY HERE
|
||||
[!keystonepublickey!]
|
||||
EOF
|
||||
|
||||
cp /root/.ssh/authorized_keys /home/keystone/.ssh/authorized_keys
|
||||
|
||||
@@ -18,6 +18,13 @@ const props = defineProps({
|
||||
<AppLayout>
|
||||
<div class="flex h-full flex-1 flex-col gap-4 rounded-xl p-4">
|
||||
{{ server }}
|
||||
|
||||
<div v-if="$page.props.flash?.server_credentials" class="p-5">
|
||||
<div class="mb-4 text-sm font-medium text-gray-900 dark:text-white">
|
||||
WILL NOT BE SHOWN AGAIN:
|
||||
{{ $page.props.flash.server_credentials }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
||||
@@ -46,9 +46,12 @@ Route::get('/provision-script', function (Request $request) {
|
||||
|
||||
$script = file_get_contents(base_path('provision.sh'));
|
||||
|
||||
$keystonePublicKey = file_get_contents(storage_path('app/private/ssh/id_ed25519.pub'));
|
||||
|
||||
$script = str_replace('[!hostname!]', $validated['hostname'], $script);
|
||||
$script = str_replace('[!sudo_password!]', $validated['sudo_password'], $script);
|
||||
$script = str_replace('[!server_id!]', $validated['server_id'], $script);
|
||||
$script = str_replace('[!keystonepublickey!]', $keystonePublicKey, $script);
|
||||
|
||||
return response($script)
|
||||
->header('Content-Type', 'text/plain');
|
||||
|
||||
Reference in New Issue
Block a user