server_init/init.sh
Nelis c34d2b4849 Initial server init setup with Ansible playbook
Automated server provisioning with Pangolin reverse proxy, Forgejo git
server with SSH passthrough, and OpenCode dev environment. Includes
server hardening (UFW, fail2ban, SSH lockdown), Docker, Rust, Python/uv,
and unattended security upgrades.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-28 10:34:20 +00:00

43 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "=== Server Init ==="
echo ""
read -p "Username [ubuntu]: " OLD_USER
OLD_USER="${OLD_USER:-ubuntu}"
read -p "Host: " HOST
read -p "SSH public key path [~/.ssh/id_ed25519.pub]: " PUBKEY_PATH
PUBKEY_PATH="${PUBKEY_PATH:-$HOME/.ssh/id_ed25519.pub}"
read -p "New username: " NEW_USER
SSH_TARGET="${OLD_USER}@pangolin.${HOST}"
echo ""
echo "Set a password for '$NEW_USER' (used for sudo):"
read -s -p "Password: " USER_PASSWORD
echo
read -s -p "Confirm: " USER_PASSWORD_CONFIRM
echo
if [ "$USER_PASSWORD" != "$USER_PASSWORD_CONFIRM" ]; then
echo "Error: Passwords do not match"
exit 1
fi
if [ ! -f "$PUBKEY_PATH" ]; then
echo "Error: Public key file not found: $PUBKEY_PATH"
exit 1
fi
PUBKEY=$(cat "$PUBKEY_PATH")
export SCRIPT_DIR HOST OLD_USER NEW_USER SSH_TARGET PUBKEY USER_PASSWORD
source "$SCRIPT_DIR/scripts/01_create_user.sh"
source "$SCRIPT_DIR/scripts/02_remove_old_user.sh"
source "$SCRIPT_DIR/scripts/03_run_playbook.sh"
source "$SCRIPT_DIR/scripts/04_show_setup_info.sh"