feat: add cloud-config for user setup and update setup script for compatibility checks
Some checks failed
Nix Format Check / check-format (push) Failing after 38s

This commit is contained in:
Menno van Leeuwen 2025-03-11 10:35:19 +01:00
parent a7b9dd4102
commit 7e1094dd7c
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
2 changed files with 30 additions and 5 deletions

22
cloud-config Normal file
View File

@ -0,0 +1,22 @@
#cloud-config
# Create a user named menno with sudo privileges
users:
- name: menno
sudo: ALL=(ALL) NOPASSWD:ALL
groups: sudo, adm
shell: /bin/bash
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM+sKpcREOUjwMMSzEWAso6830wbOi8kUxqpuXWw5gHr menno_1password
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE22Hfx8wgkc57TXX1TCMHcNrCdjbfog5QeHFJfl7IeD menno_fallback
# Update package lists and install latest updates
package_update: true
package_upgrade: true
# Configure system to preserve hostname
preserve_hostname: false
hostname: mennos-vm
# Final message when cloud-init completes
final_message: "Cloud-init has finished setting up the system with user 'menno'. System boot completed after $UPTIME seconds."

View File

@ -213,12 +213,10 @@ warning_prompt() {
log_error "Please ensure you have a backup of your data before proceeding."
log_error "This script will modify system files and may require sudo permissions.\n"
log_info "This script works best on a fresh Fedora, Ubuntu or Arch Linux installation."
log_info "Type 'continue' to continue or Ctrl+C to exit."
read -r -p "> " continue < /dev/tty
if [ "$continue" != "continue" ]; then
die "Exiting..."
fi
log_info "Setup starts in 5 seconds, to abort use Ctrl+C to exit NOW."
sleep 5
echo ""
log_info "Starting setup..."
}
@ -304,6 +302,11 @@ check_compatibility() {
attempt_package_install "tail"
attempt_package_install "git"
# Check if we are a user or root
if [ "$EUID" -eq 0 ]; then
die "This script should not be run as root. Please run as a regular user."
fi
local distro
distro=$(awk -F= '/^NAME/{print $2}' /etc/os-release | tr -d '"')