feat: add homelab deployment configs, documentation, and automation scripts
This commit is contained in:
96
snarfnet-game-seeds/scripts/setup-host.sh
Normal file
96
snarfnet-game-seeds/scripts/setup-host.sh
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# SnarfNet Gaming PC Bootstrap Script
|
||||
# MAC: bc:24:11:67:16:cd | IP: 140.44.44.80 (Compute / Game VLAN)
|
||||
# ==============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
echo "======================================================="
|
||||
echo "🌲 Bootstrapping SnarfNet Dedicated Game Server Host"
|
||||
echo "======================================================="
|
||||
|
||||
# 1. System Updates & Essential Tools
|
||||
echo ">>> Installing prerequisites and system tools..."
|
||||
apt-get update && apt-get install -y \
|
||||
curl wget git jq ufw nfs-common ethtool net-tools \
|
||||
python3 python3-yaml python3-pip apt-transport-https \
|
||||
ca-certificates gnupg lsb-release
|
||||
|
||||
# 2. Configure Wake-on-LAN (Persistent via systemd)
|
||||
echo ">>> Configuring Wake-on-LAN for primary interface..."
|
||||
NIC=$(ip route show default | awk '{print $5}' | head -n1)
|
||||
ethtool -s "$NIC" wol g || true
|
||||
|
||||
cat <<EOF > /etc/systemd/system/wol.service
|
||||
[Unit]
|
||||
Description=Enable Wake-on-LAN on $NIC
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/sbin/ethtool -s $NIC wol g
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable wol.service
|
||||
|
||||
# 3. Mount Synology NAS Game Backup Share
|
||||
echo ">>> Configuring Synology NAS NFS Mount (14.10.10.71:/volume1/docker/game-backups)..."
|
||||
mkdir -p /mnt/nas/game-backups
|
||||
if ! grep -qs '/mnt/nas/game-backups' /etc/fstab; then
|
||||
echo "14.10.10.71:/volume1/docker/game-backups /mnt/nas/game-backups nfs rw,hard,intr,nolock,timeo=14 0 0" >> /etc/fstab
|
||||
fi
|
||||
mount -a || true
|
||||
|
||||
# 4. Install Docker & Compose (if not present)
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo ">>> Installing Docker Engine..."
|
||||
curl -fsSL https://get.docker.com | sh
|
||||
systemctl enable docker
|
||||
systemctl start docker
|
||||
fi
|
||||
|
||||
# 5. Prepare Game Directory Structure
|
||||
echo ">>> Creating game server storage paths..."
|
||||
mkdir -p /opt/game-servers/{enshrouded,fs25,stationeers,valheim,vrising}/{savegame,saves,worlds,data}
|
||||
chmod -R 775 /opt/game-servers
|
||||
|
||||
# 6. Setup Seed Manager Service & Daily Cron
|
||||
echo ">>> Installing SnarfNet Seed Reconciler and Backup Timer..."
|
||||
cat <<EOF > /etc/systemd/system/gameseed-backup.service
|
||||
[Unit]
|
||||
Description=SnarfNet Declarative Game Server Save Backup
|
||||
After=network.target docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
WorkingDirectory=/opt/snarfnet-game-seeds
|
||||
ExecStart=/usr/bin/python3 /opt/snarfnet-game-seeds/core/manager.py backup
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cat <<EOF > /etc/systemd/system/gameseed-backup.timer
|
||||
[Unit]
|
||||
Description=Nightly Game Save Backup Timer (04:00 AM)
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 04:00:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
Timers.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable gameseed-backup.timer
|
||||
systemctl start gameseed-backup.timer
|
||||
|
||||
echo "======================================================="
|
||||
echo "✓ Host bootstrap complete!"
|
||||
echo "Run: python3 /opt/snarfnet-game-seeds/core/manager.py compose && docker compose up -d"
|
||||
echo "======================================================="
|
||||
|
||||
Reference in New Issue
Block a user