159 lines
4.7 KiB
Bash
Executable File
159 lines
4.7 KiB
Bash
Executable File
#!/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/tty
|
|
case "$response" in
|
|
[yY][eE][sS]|[yY])
|
|
echo "Rebooting..."
|
|
sudo reboot
|
|
;;
|
|
*)
|
|
echo "Reboot skipped. Please reboot when convenient."
|
|
;;
|
|
esac
|
|
|
|
# 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 |