Created
May 17, 2025 10:35
-
-
Save projectoperations/d6158cf12097b809749a550b08dfcbc3 to your computer and use it in GitHub Desktop.
fedoradevserver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: Jesse Koch | |
# Date: 2025-04-19 | |
# Description: Runs all of the necessary install scripts for the system. | |
######################################## | |
# RAZMAKAZ SERVER INSTALLER | |
# | |
# This script fully sets up a Fedora-based home server for gaming, | |
# media, and remote management with all the tools needed to make | |
# Linux easy, fast, and fun — even for users transitioning from Windows. | |
# | |
# Features: | |
# - Creates user accounts and sets up SSH keys for secure access | |
# - Installs essential system, networking, and developer tools | |
# - Enables firewall and opens specific ports for game/media servers | |
# - Adds friendly aliases and a MOTD to guide users | |
# - Sets up a shared folder for Windows file access | |
# - Installs Podman, Cockpit, and other GUI/CLI tools for container management | |
# - Configures dynamic DNS (DDNS.net) to make remote access easy | |
# | |
# Run this once on a fresh Fedora system to fully automate your server setup. | |
######################################## | |
# Array to store failed installations | |
errors=() | |
add_error() { | |
local error_message=$1 | |
errors+=("$error_message") | |
} | |
############################################### | |
# 👥 CREATE USERS AND SET UP SSH KEYS | |
############################################### | |
echo "========================================" | |
echo "👥 Creating users and assigning SSH keys" | |
echo "========================================" | |
# Format: username followed by their public key | |
users=( | |
"jesse" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFs4eHPMk8hAnBEmzukWjRJgWz6Hoe1xafb5bB849SFZ [email protected]" | |
"zach" "" | |
) | |
# Loop through users array two at a time | |
for ((i=0; i<${#users[@]}; i+=2)); do | |
username="${users[$i]}" | |
pubkey="${users[$i+1]}" | |
echo "📦 Creating user: $username" | |
# Create the user if they don't exist | |
if ! id "$username" &>/dev/null; then | |
sudo useradd -m -s /usr/bin/zsh "$username" | |
echo "$username ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$username | |
fi | |
# Setup SSH key | |
sudo mkdir -p /home/$username/.ssh | |
echo "$pubkey" | sudo tee /home/$username/.ssh/authorized_keys > /dev/null | |
sudo chown -R $username:$username /home/$username/.ssh | |
sudo chmod 700 /home/$username/.ssh | |
sudo chmod 600 /home/$username/.ssh/authorized_keys | |
echo "✅ $username setup complete." | |
done | |
# Optionally: install the same key to root | |
echo "🔐 Adding key to root authorized_keys (first key in list)" | |
echo "${users[1]}" | sudo tee /root/.ssh/authorized_keys > /dev/null | |
sudo chmod 700 /root/.ssh | |
sudo chmod 600 /root/.ssh/authorized_keys | |
echo "=========================================" | |
echo "✅ All users created and SSH keys configured." | |
echo "=========================================" | |
######################################## | |
# INSTALL APPLICATIONS | |
######################################## | |
# Function to install a package and handle errors | |
install_package() { | |
local package=$1 | |
echo "Installing $package..." | |
if ! sudo dnf install -y "$package"; then | |
echo "Failed to install $package" | |
errors+=("$package failed to install") | |
fi | |
} | |
echo "========================================" | |
echo "📦 Installing applications..." | |
echo "========================================" | |
# SYSTEM TOOLS | |
install_package "zsh" # Z shell, an alternative shell with advanced features | |
install_package "curl" # Command-line tool for transferring data with URLs | |
install_package "wget" # Utility for downloading files from the web | |
install_package "neofetch" # CLI tool to display system information in the terminal | |
install_package "htop" # Interactive process viewer for system monitoring | |
install_package "btop" # Resource monitor with a modern UI | |
install_package "lm_sensors" # Tools for monitoring hardware sensors (e.g., temperature) | |
install_package "smartmontools" # Tools for monitoring and managing hard drive health | |
install_package "ncdu" # Disk usage analyzer with a text-based interface | |
install_package "tldr" # Simplified and community-driven man pages | |
install_package "nmap" # Network scanner for security auditing and discovery | |
install_package "openssh-server" # SSH server for remote access to the system | |
install_package "firewalld" # Firewall management tool | |
install_package "caddy" # Web server with automatic HTTPS | |
install_package "cockpit" # Web-based interface for managing servers | |
install_package "cockpit-podman" # Cockpit plugin for managing Podman containers | |
install_package "cockpit-system" # Cockpit plugin for system monitoring and management | |
install_package "cockpit-networkmanager" # Cockpit plugin for managing network settings | |
install_package "caddy" # Web server with automatic HTTPS | |
install_package "nfs-utils" # Tools for setting up and managing NFS file sharing | |
install_package "samba" # Tools for setting up and managing SMB file sharing | |
install_package "util-linux-user" # Utilities like 'chsh' for managing user accounts | |
install_package "git" # Already in your list, but good to keep | |
install_package "gh" # GitHub CLI for Gist uploads or repo access | |
# OPTIONAL TUI POWER TOOLS | |
install_package "fzf" # Command-line fuzzy finder for searching files and text | |
install_package "bat" # Enhanced 'cat' command with syntax highlighting | |
install_package "duf" # Disk usage utility with a user-friendly interface | |
install_package "fd-find" # Fast and user-friendly alternative to 'find' | |
install_package "ripgrep" # Fast search tool for recursively finding text in files | |
install_package "lf" # Terminal-based file manager | |
# PODMAN (container engine) | |
install_package "podman" # Daemonless container engine for managing containers | |
install_package "podman-compose" # Docker Compose-compatible tool for Podman | |
install_package "podman-docker" # Compatibility layer for Docker CLI with Podman | |
install_package "buildah" # Tool for building OCI-compatible container images | |
install_package "skopeo" # Tool for inspecting and transferring container images | |
# GAMING TOOLS (IF NEEDED) | |
install_package "steam" # Gaming platform for playing and managing games | |
install_package "steamcmd" # Command-line tool for managing Steam game servers | |
# OPTIONAL GUI TOOLS (if KDE is installed) | |
install_package "dolphin" # KDE file manager | |
install_package "ark" # KDE archive manager for compressing and extracting files | |
install_package "konsole" # KDE terminal emulator | |
echo "========================================" | |
echo "📦 Installing Node.js and NVM..." | |
echo "========================================" | |
echo "Installing NVM..." | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | |
# Load NVM into script | |
export NVM_DIR="$HOME/.nvm" | |
source "$NVM_DIR/nvm.sh" | |
nvm install --lts | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh" | |
echo "========================================" | |
echo "🐍 Installing Python and pyenv..." | |
echo "========================================" | |
echo "Installing pyenv..." | |
curl https://pyenv.run | bash | |
# Add to zshrc | |
cat << 'EOF' >> ~/.zshrc | |
# Pyenv | |
export PYENV_ROOT="$HOME/.pyenv" | |
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init --path)" | |
eval "$(pyenv virtualenv-init -)" | |
EOF | |
# Install latest Python | |
export PYENV_ROOT="$HOME/.pyenv" | |
export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init --path)" | |
eval "$(pyenv virtualenv-init -)" | |
pyenv install 3.12.2 | |
pyenv global 3.12.2 | |
echo "========================================" | |
echo "✅ Applications installed!" | |
echo "========================================" | |
############################################### | |
# FIREWALL SETUP | |
############################################### | |
echo "========================================" | |
echo "🔥 Enabling essential services..." | |
echo "========================================" | |
echo "Enabling Cockpit (web-based system manager)" | |
sudo systemctl enable --now cockpit.socket | |
sudo firewall-cmd --permanent --add-service=cockpit | |
sudo firewall-cmd --permanent --add-port=9090/tcp | |
echo "Enabling Firewalld (firewall management daemon)" | |
sudo systemctl enable --now firewalld | |
echo "Enabling SSHd (remote shell access)" | |
sudo systemctl enable --now sshd | |
sudo firewall-cmd --permanent --add-service=ssh | |
echo "========================================" | |
echo "🎮 Opening common game server ports..." | |
echo "========================================" | |
# Minecraft default + 20 more in case of additional worlds/servers | |
echo "Allowing Minecraft ports: 25565-25585/tcp" | |
sudo firewall-cmd --permanent --add-port=25565-25574/tcp | |
# Terraria default + 10 extras (for multi-world or friends) | |
echo "Allowing Terraria ports: 7777-7787/tcp" | |
sudo firewall-cmd --permanent --add-port=7777-7781/tcp | |
echo "========================================" | |
echo "📺 Enabling full Plex Media Server access..." | |
echo "========================================" | |
# Web interface for Plex | |
echo "Allowing Plex Web Interface: 32400/tcp" | |
sudo firewall-cmd --permanent --add-port=32400/tcp | |
# Plex Companion (mobile/tablet control) | |
echo "Allowing Plex Companion Port: 8324/tcp" | |
sudo firewall-cmd --permanent --add-port=8324/tcp | |
# Plex DLNA discovery (SSDP) | |
echo "Allowing DLNA discovery (SSDP): 1900/udp" | |
sudo firewall-cmd --permanent --add-port=1900/udp | |
# Plex DLNA server ports (device discovery and streaming) | |
echo "Allowing Plex DLNA server ports: 32410-32414/udp" | |
sudo firewall-cmd --permanent --add-port=32410-32414/udp | |
# Plex media casting (Chromecast, Smart TVs, etc.) | |
echo "Allowing Plex casting port: 32469/tcp" | |
sudo firewall-cmd --permanent --add-port=32469/tcp | |
# Caddy web server ports: 80/tcp and 443/tcp and 8080/tcp | |
echo "Allowing Caddy web server ports: 80/tcp and 443/tcp and 8080/tcp" | |
sudo firewall-cmd --permanent --add-port=80/tcp | |
sudo firewall-cmd --permanent --add-port=443/tcp | |
sudo firewall-cmd --permanent --add-port=8080/tcp | |
# MinIO S3 interface: default is 9000 | |
echo "Allowing MinIO API port: 9000/tcp" | |
sudo firewall-cmd --permanent --add-port=9000/tcp | |
# Admin UI port (MinIO Console) | |
echo "Allowing MinIO Console port: 9001/tcp" | |
sudo firewall-cmd --permanent --add-port=9001/tcp | |
# Samba for Windows shares | |
echo "Allowing Samba service" | |
sudo firewall-cmd --permanent --add-service=samba | |
# NFS (optional, less common for Windows) | |
echo "Allowing NFS service" | |
sudo firewall-cmd --permanent --add-service=nfs | |
echo "========================================" | |
echo "🔄 Reloading firewall to apply changes..." | |
echo "========================================" | |
sudo firewall-cmd --reload | |
echo "========================================" | |
echo "✅ Firewall configuration complete!" | |
echo "========================================" | |
############################################### | |
# SHARED FOLDER FOR WINDOWS | |
############################################### | |
echo "========================================" | |
echo "📁 Creating Samba share for /srv/shared" | |
echo "========================================" | |
# Create folder | |
sudo mkdir -p /srv/shared | |
sudo chown nobody:nobody /srv/shared | |
sudo chmod 0775 /srv/shared | |
# Configure Samba | |
sudo bash -c 'cat <<EOF >> /etc/samba/smb.conf | |
[Shared] | |
path = /srv/shared | |
browsable = yes | |
read only = no | |
guest ok = yes | |
EOF' | |
echo "========================================" | |
echo "🔄 Restarting Samba and reloading firewall..." | |
echo "========================================" | |
# Restart Samba | |
sudo systemctl restart smb | |
sudo firewall-cmd --permanent --add-service=samba | |
sudo firewall-cmd --reload | |
echo "========================================" | |
echo "✅ Shared folder /srv/shared is now available to your Windows PC." | |
echo "========================================" | |
############################################### | |
# ALIASES FOR ZSH | |
############################################### | |
echo "========================================" | |
echo "📎 Adding helpful aliases to ~/.zshrc" | |
echo "========================================" | |
cat << 'EOF' >> ~/.zshrc | |
# === Custom Aliases === | |
alias cls='clear' | |
alias update='sudo dnf upgrade -y && flatpak update -y' | |
alias port-open='sudo firewall-cmd --permanent --add-port=$1 && sudo firewall-cmd --reload' | |
alias port-close='sudo firewall-cmd --permanent --remove-port=$1 && sudo firewall-cmd --reload' | |
alias port-list='sudo firewall-cmd --list-ports' | |
# === Podman Aliases === | |
alias plex-restart='podman restart plex' | |
# === CraftyController Aliases === | |
alias crafty-up='podman start crafty' | |
alias crafty-down='podman stop crafty' | |
# === Caddy === | |
alias caddy-restart='sudo systemctl restart caddy' | |
alias caddy-status='sudo systemctl status caddy' | |
# === Localtunnel === | |
alias tunnel='npx localtunnel --port' | |
# === System Info === | |
alias usage='btop' | |
alias disk='ncdu /' | |
EOF | |
echo "========================================" | |
echo "✅ Aliases added." | |
echo "========================================" | |
############################################### | |
# MESSAGE OF THE DAY (MOTD) | |
############################################### | |
echo "========================================" | |
echo "🪧 Setting up message of the day..." | |
echo "========================================" | |
cat << 'EOF' | sudo tee /etc/motd | |
Welcome to your Linux-powered game server! 🚀 | |
Helpful commands: | |
- `update` = upgrade all packages | |
- `btop` / `htop` = system resource monitor | |
- `crafty-up` = start CraftyController | |
- `plex-restart` = restart Plex server | |
- `port-open {port}` = open a new port | |
- `port-close {port}` = close an open port | |
- `port-list` = list all open ports | |
Have fun and don’t break stuff 😉 | |
EOF | |
echo "========================================" | |
echo "✅ Message of the day set up." | |
echo "========================================" | |
############################################### | |
# 🌍 DDNS.net Auto-Updater | |
############################################### | |
echo "========================================" | |
echo "🌍 Installing No-IP Dynamic DNS Updater" | |
echo "========================================" | |
# Download and extract | |
cd /usr/local/src | |
sudo curl -LO https://www.noip.com/client/linux/noip-duc-linux.tar.gz | |
sudo tar xf noip-duc-linux.tar.gz | |
cd noip-* | |
# Build | |
sudo make | |
sudo make install | |
# It will prompt for username/password and hostname (do interactively once) | |
# Create systemd service file | |
sudo bash -c 'cat <<EOF > /etc/systemd/system/noip2.service | |
[Unit] | |
Description=No-IP Dynamic DNS Update Client | |
After=network.target | |
[Service] | |
Type=forking | |
ExecStart=/usr/local/bin/noip2 | |
ExecReload=/usr/local/bin/noip2 -S | |
ExecStop=/usr/local/bin/noip2 -K | |
PIDFile=/usr/local/bin/noip2.pid | |
[Install] | |
WantedBy=multi-user.target | |
EOF' | |
# Enable on boot | |
sudo systemctl enable --now noip2 | |
############################################### | |
# 📄 Caddyfile Setup | |
############################################### | |
echo "========================================" | |
echo "📄 Setting up Caddyfile for domains" | |
echo "========================================" | |
# sudo mkdir -p /etc/caddy/sites/steeleegg.ddns.net | |
sudo mkdir -p /etc/caddy/sites/eggzachtly.me | |
sudo mkdir -p /etc/caddy/sites/steeleegg.com | |
# Root Caddyfile | |
sudo tee /etc/caddy/Caddyfile > /dev/null <<EOF | |
import /etc/caddy/sites/eggzachtly.me/* | |
import /etc/caddy/sites/steeleegg.com/* | |
EOF | |
# SteeleEgg (Primary) | |
sudo tee /etc/caddy/sites/steelegg.com/plex > /dev/null <<EOF | |
# Plex reverse proxy | |
plex.steeleegg.ddns.net { | |
reverse_proxy 127.0.0.1:32400 | |
} | |
EOF | |
sudo tee /etc/caddy/sites/steeleegg.com/cockpit > /dev/null <<EOF | |
# Cockpit reverse proxy | |
cockpit.steeleegg.ddns.net { | |
reverse_proxy 127.0.0.1:9090 | |
} | |
EOF | |
sudo tee /etc/caddy/sites/steeleegg.com/root > /dev/null <<EOF | |
# Shared site (drop a future container or static site here) | |
steeleegg.ddns.net { | |
reverse_proxy 127.0.0.1:8080 | |
} | |
EOF | |
# Eggzachtly | |
sudo tee /etc/caddy/sites/eggzachtly.me/root > /dev/null <<EOF | |
# Redirect to primary domain | |
eggzachtly.me { | |
redir https://steeleegg.ddns.net{uri} | |
} | |
EOF | |
# SteeleEgg.com | |
sudo tee /etc/caddy/sites/steeleegg.com/root > /dev/null <<EOF | |
# Redirect to primary domain | |
steeleegg.com { | |
redir https://steeleegg.ddns.net{uri} | |
} | |
EOF | |
# Set correct permissions and reload | |
sudo systemctl enable --now caddy | |
sudo systemctl restart caddy | |
echo "========================================" | |
echo "✅ Caddyfile set up for steeleegg.ddns.net" | |
echo "========================================" | |
############################################### | |
# 💅 ZSH + Powerlevel10k Setup | |
############################################### | |
echo "========================================" | |
echo "🔌 Installing Oh My Zsh + Powerlevel10k + plugins" | |
echo "========================================" | |
# Run only if Powerlevel10k is not already installed | |
if [ ! -d "${HOME}/.oh-my-zsh" ]; then | |
echo "Installing Oh My Zsh..." | |
RUNZSH=no KEEP_ZSHRC=yes sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
fi | |
# Install Powerlevel10k | |
if [ ! -d "${HOME}/.oh-my-zsh/custom/themes/powerlevel10k" ]; then | |
echo "Installing Powerlevel10k theme..." | |
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \ | |
"${HOME}/.oh-my-zsh/custom/themes/powerlevel10k" | |
fi | |
# Set theme to Powerlevel10k in .zshrc | |
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc | |
# Set plugin list | |
echo "Setting ZSH plugins..." | |
cat << 'EOF' >> ~/.zshrc | |
# --- Custom Plugins --- | |
plugins=() | |
plugins+=(git) | |
plugins+=(z) | |
plugins+=(history-substring-search) | |
plugins+=(npm) | |
plugins+=(nvm) | |
plugins+=(oc) | |
plugins+=(podman) | |
plugins+=(pyenv) | |
plugins+=(qrcode) | |
plugins+=(ssh) | |
plugins+=(sudo) | |
plugins+=(vscode) | |
plugins+=(yarn) | |
plugins+=(wd) | |
plugins+=(transfer) | |
plugins+=(command-not-found) | |
plugins+=(stripe) | |
plugins+=(flutter) | |
plugins+=(fzf) | |
plugins+=(aliases) | |
source \$ZSH/oh-my-zsh.sh | |
EOF | |
############################################### | |
# POST INSTALLATION SETUP | |
############################################### | |
echo "========================================" | |
echo "🔄 Setting ZSH as the default shell..." | |
echo "========================================" | |
chsh -s /usr/bin/zsh $USER | |
############################################### | |
# FINISHING UP | |
############################################### | |
# Output failed installations | |
if [ ${#errors[@]} -ne 0 ]; then | |
echo "========================================" | |
echo "⚠️ The following errors occurred during installation:" | |
echo "========================================" | |
for error in "${errors[@]}"; do | |
echo "- $error" | |
done | |
else | |
echo "========================================" | |
echo "✅ No errors occurred during installation!" | |
echo "========================================" | |
# Reload the shell | |
read -p "Press Enter to to complete the setup and reload the shell..." | |
exec zsh | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment