#!/bin/bash -i # # Purpose : HamPack installer # Print the logo print_logo() { cat << "EOF" ██╗ ██╗ █████╗ ███╗ ███╗██████╗ █████╗ ██████╗██╗ ██╗ ██║ ██║██╔══██╗████╗ ████║██╔══██╗██╔══██╗██╔════╝██║ ██╔╝ ███████║███████║██╔████╔██║██████╔╝███████║██║ █████╔╝ ██╔══██║██╔══██║██║╚██╔╝██║██╔═══╝ ██╔══██║██║ ██╔═██╗ ██║ ██║██║ ██║██║ ╚═╝ ██║██║ ██║ ██║╚██████╗██║ ██╗ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ EOF } # --- Main --- set -e 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-hampack-install > /dev/null sudo chmod 440 /etc/sudoers.d/99-hampack-install trap "sudo rm -f /etc/sudoers.d/99-hampack-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 HamPackServer..." rm -rf ~/.local/share/HamPackServer git clone https://gitea.young.computer/david/HamPackServer.git "$HOME/.local/share/HamPackServer" > /dev/null mkdir -p "$HOME/.local/bin" cp "$HOME/.local/share/HamPackServer/hampackserverrefresh" "$HOME/.local/bin/hampackserverrefresh" cp "$HOME/.local/share/HamPackServer/hampackserverupdate" "$HOME/.local/bin/hampackserverupdate" cd ~/.local/share/HamPackServer 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/HamPackServer 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[@]}" cd ~/.local/share/HamPackServer echo "Enabling PHP extensions in /etc/php/php.ini..." for ext in curl mbstring xml pdo_mysql mysqli; do sudo sed -i "s/^;extension=${ext}$/extension=${ext}/" /etc/php/php.ini done # Install Cloudlog CLOUDLOG_DIR="/srv/http/cloudlog" CLOUDLOG_DB="cloudlog" CLOUDLOG_DB_USER="cloudlog" CLOUDLOG_DB_PASS="cloudlog" if [ ! -d "$CLOUDLOG_DIR" ]; then echo "Installing Cloudlog..." sudo git clone https://github.com/magicbug/Cloudlog.git "$CLOUDLOG_DIR" # Set ownership and permissions (Arch Apache runs as 'http') sudo chown -R http:http "$CLOUDLOG_DIR" sudo chmod -R g+rw "$CLOUDLOG_DIR" # Create MariaDB database and user echo "Creating Cloudlog database..." sudo mysql -u root < /dev/null 2>&1; then echo "HamPack is installed. 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 "Ham Pack is installed. Reboot when convenient." fi