From 4cd6109627d4ac2c4016beacfe9e6e8404b22162 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 May 2026 14:20:41 -0600 Subject: [PATCH] Various fixes and additions. --- README.md | 1 + fix-networking.sh | 27 ++++++++ install.sh | 159 ++++++++++++++++++++++++++++++++++++++++++++++ miniserverrefresh | 52 +++++++++++++++ miniserverupdate | 78 +++++++++++++++++++++++ packages.conf | 23 +++++++ utils.sh | 28 ++++++++ 7 files changed, 368 insertions(+) create mode 100644 fix-networking.sh create mode 100755 install.sh create mode 100755 miniserverrefresh create mode 100755 miniserverupdate create mode 100644 packages.conf create mode 100755 utils.sh diff --git a/README.md b/README.md index e69de29..2ca5a5f 100644 --- a/README.md +++ b/README.md @@ -0,0 +1 @@ +Installs the bare necessities to turn a newly minted Arch Linux server into something useful. \ No newline at end of file diff --git a/fix-networking.sh b/fix-networking.sh new file mode 100644 index 0000000..1f000ba --- /dev/null +++ b/fix-networking.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Purpose : Configure Avahi mDNS and disable systemd-resolved + +set -e + +echo "Installing Avahi and nss-mdns..." +sudo pacman -S --noconfirm avahi nss-mdns + +echo "Enabling Avahi daemon..." +sudo systemctl enable avahi-daemon.service + +echo "Updating /etc/nsswitch.conf..." +sudo sed -i 's/^hosts:.*/hosts: mymachines mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns/' /etc/nsswitch.conf + +# Verify the change was made +if grep -q "mdns_minimal" /etc/nsswitch.conf; then + echo "nsswitch.conf updated successfully." +else + echo "Error: nsswitch.conf was not updated. Please check the file manually." + exit 1 +fi + +echo "Copying Avahi SSH service file..." +sudo cp /usr/share/doc/avahi/ssh.service /etc/avahi/services/ + +echo "Avahi mDNS configuration complete." diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..2b8ee71 --- /dev/null +++ b/install.sh @@ -0,0 +1,159 @@ +#!/bin/bash +# +# Purpose : MiniServer installer + +# Print the logo +print_logo() { + cat << "EOF" + + ███╗ ███╗██╗███╗ ██╗██╗ + ████╗ ████║██║████╗ ██║██║ + ██╔████╔██║██║██╔██╗ ██║██║ + ██║╚██╔╝██║██║██║╚██╗██║██║ + ██║ ╚═╝ ██║██║██║ ╚████║██║ + ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ + + ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗ + ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗ + ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝ + ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗ + ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║ + ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ + + + +EOF +} + +# --- Main --- + +set -e + +export PATH="$HOME/.local/bin:$PATH" + +if ! grep -q 'LOCAL_BIN_PATH' "$HOME/.bashrc"; then + echo '' >> "$HOME/.bashrc" + echo '# Mini: add user local bin to PATH' >> "$HOME/.bashrc" + echo 'export PATH="$HOME/.local/bin:$PATH" # LOCAL_BIN_PATH' >> "$HOME/.bashrc" +fi + +clear +print_logo + +cd ~ +sudo -v + +# Grant passwordless sudo for the duration of the install, revoke on exit +echo "$USER ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/99-miniserver-install > /dev/null +sudo chmod 440 /etc/sudoers.d/99-miniserver-install +trap "sudo rm -f /etc/sudoers.d/99-miniserver-install" EXIT + +if ! command -v git &> /dev/null; then + echo "Installing git..." + sudo pacman -S --noconfirm git +fi + +if ! pacman -Qi base-devel &> /dev/null; then + echo "Installing base-devel..." + sudo pacman -S --noconfirm base-devel +else + echo "base-devel is already installed, skipping." +fi + +echo "Getting the latest version of MiniServer..." +rm -rf ~/.local/share/MiniServer +git clone https://gitea.young.computer/david/MiniServer.git "$HOME/.local/share/MiniServer" > /dev/null + +mkdir -p "$HOME/.local/bin" +cp "$HOME/.local/share/MiniServer/miniserverrefresh" "$HOME/.local/bin/miniserverrefresh" +cp "$HOME/.local/share/MiniServer/miniserverupdate" "$HOME/.local/bin/miniserverupdate" + +cd ~/.local/share/MiniServer + +echo "Updating system..." +sudo pacman -Syu --noconfirm + +install_yay() { + rm -rf /tmp/yay + git clone https://aur.archlinux.org/yay.git /tmp/yay + cd /tmp/yay + makepkg -si --noconfirm + cd ~/.local/share/MiniServer + rm -rf /tmp/yay +} + +if ! command -v yay &> /dev/null; then + echo "Installing yay AUR helper..." + install_yay +else + echo "yay is already installed, skipping." +fi + +if ! yay --version &> /dev/null; then + echo "yay does not appear to be working, reinstalling..." + install_yay +fi + +# Source utility functions +source utils.sh + +# Source package list +if [ ! -f "packages.conf" ]; then + echo "Error: packages.conf not found!" + exit 1 +fi +source packages.conf + +echo "Installing servers..." +install_packages "${SERVERS[@]}" + +echo "Installing utilities..." +install_packages "${UTILITIES[@]}" + +if ! command -v pm2 &> /dev/null; then + npm install pm2 -g --prefix "$HOME/.local" +fi + +cd ~/.local/share/MiniServer + +# Install Cockpit +if ! pacman -Qi cockpit &> /dev/null; then + echo "Installing Cockpit..." + sudo pacman -S --noconfirm cockpit + sudo systemctl enable --now cockpit.socket + echo "Cockpit installed. Access it at http://localhost:9090" +else + echo "Cockpit is already installed, skipping." +fi + + +echo "" +read -rp "A reboot is required to complete setup. Reboot now? [y/N] " response /dev/null 2>&1; then + echo "A newer kernel has been installed, a reboot is recommended." + read -rp "Reboot now? [y/N] " response + case "$response" in + [yY][eE][sS]|[yY]) + echo "Rebooting..." + sudo reboot + ;; + *) + echo "Reboot skipped. Please remember to reboot when convenient." + exit 0 + ;; + esac +else + echo "Kernel is up to date, no reboot needed. You may want to consider a reboot if other significant software was updated or installed." +fi \ No newline at end of file diff --git a/miniserverrefresh b/miniserverrefresh new file mode 100755 index 0000000..3a3503a --- /dev/null +++ b/miniserverrefresh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Print the logo +print_logo() { + cat << "EOF" + + ███╗ ███╗██╗███╗ ██╗██╗ + ████╗ ████║██║████╗ ██║██║ + ██╔████╔██║██║██╔██╗ ██║██║ + ██║╚██╔╝██║██║██║╚██╗██║██║ + ██║ ╚═╝ ██║██║██║ ╚████║██║ + ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ + + ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗ + ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗ + ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝ + ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗ + ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║ + ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ + + + +EOF +} + +# Clear screen and show logo +clear +print_logo + +echo "Let's get the lastest changes to MiniServer..." + +wget -qO- https://gitea.young.computer/david/MiniServer/raw/branch/main/install.sh | bash + +# Check whether the running kernel matches the installed modules — if not, a +# newer kernel was installed during this run and a reboot is required + +if ! ls /usr/lib/modules/$(uname -r) > /dev/null 2>&1; then + echo "A newer kernel has been installed, a reboot is recommended." + read -rp "Reboot now? [y/N] " response + case "$response" in + [yY][eE][sS]|[yY]) + echo "Rebooting..." + sudo reboot + ;; + *) + echo "Reboot skipped. Please remember to reboot when convenient." + exit 0 + ;; + esac +else + echo "Kernel is up to date, no reboot needed. You may want to consider a reboot if other significant software was updated or installed." +fi diff --git a/miniserverupdate b/miniserverupdate new file mode 100755 index 0000000..5dcecf0 --- /dev/null +++ b/miniserverupdate @@ -0,0 +1,78 @@ +#!/bin/bash + +# Print the logo +print_logo() { + cat << "EOF" + + ███╗ ███╗██╗███╗ ██╗██╗ + ████╗ ████║██║████╗ ██║██║ + ██╔████╔██║██║██╔██╗ ██║██║ + ██║╚██╔╝██║██║██║╚██╗██║██║ + ██║ ╚═╝ ██║██║██║ ╚████║██║ + ╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ + + ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗ + ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗ + ███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝ + ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗ + ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║ + ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ + + + +EOF +} + +# Clear screen and show logo +clear +print_logo + +echo "Updating Arch..." +sudo pacman -Syu + +echo "Updating AUR..." + +if ! yay -Sua 2>/dev/null; then + echo "yay -Sua returned an error. Let's rebuild YAY." + sudo pacman -R yay + cd /tmp + git clone https://aur.archlinux.org/yay.git + cd yay + makepkg -si + cd .. + rm -rf yay + cd + yay -Sua --noconfirm +else + yay -Sua --noconfirm +fi + +# Updating the repo and installing... +echo "Updating MiniServer..." + +REPO_DIR="$HOME/.local/share/MiniServer" + +echo "Pulling latest MiniServer repo..." +git -C "$REPO_DIR" pull + +echo "Running install.sh..." +bash "$REPO_DIR/install.sh" + +# Check whether the running kernel matches the installed modules — if not, a +# newer kernel was installed during this run and a reboot is required +if ! ls /usr/lib/modules/$(uname -r) > /dev/null 2>&1; then + echo "A newer kernel has been installed, a reboot is recommended." + read -rp "Reboot now? [y/N] " response + case "$response" in + [yY][eE][sS]|[yY]) + echo "Rebooting..." + sudo reboot + ;; + *) + echo "Reboot skipped. Please remember to reboot when convenient." + exit 0 + ;; + esac +else + echo "Kernel is up to date, no reboot needed. You may want to consider a reboot if other significant software was updated or installed." +fi diff --git a/packages.conf b/packages.conf new file mode 100644 index 0000000..bb867e5 --- /dev/null +++ b/packages.conf @@ -0,0 +1,23 @@ +# Servers +SERVERS=( + # nothing at this time +) + +# Utilities +UTILITIES=( + cmake + cockpit + cockpit-storaged + curl + docker + docker-compose + firewalld + nano + networkmanager + nodejs + npm + vi + wget + unzip +) + diff --git a/utils.sh b/utils.sh new file mode 100755 index 0000000..62c5d07 --- /dev/null +++ b/utils.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Function to check if a package is installed +is_installed() { + pacman -Qi "$1" &> /dev/null +} + +# Function to check if a package is installed +is_group_installed() { + pacman -Qg "$1" &> /dev/null +} + +# Function to install packages if not already installed +install_packages() { + local packages=("$@") + local to_install=() + + for pkg in "${packages[@]}"; do + if ! is_installed "$pkg" && ! is_group_installed "$pkg"; then + to_install+=("$pkg") + fi + done + + if [ ${#to_install[@]} -ne 0 ]; then + echo "Installing: ${to_install[*]}" + yay -S --noconfirm "${to_install[@]}" + fi +} \ No newline at end of file