make in to sibling project
This commit is contained in:
+49
-159
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Purpose : HamPack installer
|
||||
# Purpose : Install HamPackServer (run by CoreDesktop's `sibling add`)
|
||||
|
||||
# Print the logo
|
||||
print_logo() {
|
||||
@@ -25,128 +25,18 @@ print_logo() {
|
||||
EOF
|
||||
}
|
||||
|
||||
# --- Main ---
|
||||
# Install Wavelog in Docker, once; its database password is generated here
|
||||
install_wavelog() {
|
||||
WAVELOG_DIR="$HOME/.local/bin/wavelog"
|
||||
|
||||
set -e
|
||||
if [ -d "$WAVELOG_DIR" ]; then
|
||||
echo "Wavelog is already installed, skipping."
|
||||
return
|
||||
fi
|
||||
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
if ! grep -q 'LOCAL_BIN_PATH' "$HOME/.bashrc"; then
|
||||
echo '' >> "$HOME/.bashrc"
|
||||
echo '# HamPack: 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-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"
|
||||
cp "$HOME/.local/share/HamPackServer/hampackservercheck" "$HOME/.local/bin/hampackservercheck"
|
||||
|
||||
mkdir -p "$HOME/.local/share/hamclock"
|
||||
# Remove old user-level service if present
|
||||
if [ -f "$HOME/.config/systemd/user/hamclock.service" ]; then
|
||||
systemctl --user disable --now hamclock 2>/dev/null || true
|
||||
rm "$HOME/.config/systemd/user/hamclock.service"
|
||||
systemctl --user daemon-reload
|
||||
fi
|
||||
sed -e "s/__HAMCLOCK_USER__/$USER/g" -e "s|__HAMCLOCK_HOME__|$HOME|g" "$HOME/.local/share/HamPackServer/servicefiles/hamclock.service" | sudo tee /etc/systemd/system/hamclock.service > /dev/null
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable hamclock
|
||||
bash "$HOME/.local/share/HamPackServer/scripts/hamclock-cleanup.sh"
|
||||
|
||||
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[@]}"
|
||||
|
||||
if ! command -v pm2 &> /dev/null; then
|
||||
npm install pm2 -g --prefix "$HOME/.local"
|
||||
fi
|
||||
|
||||
cd ~/.local/share/HamPackServer
|
||||
|
||||
# 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
|
||||
|
||||
# Install Wavelog
|
||||
|
||||
WAVELOG_DIR="$HOME/.local/bin/wavelog"
|
||||
|
||||
if [ ! -d "$WAVELOG_DIR" ]; then
|
||||
echo "Installing Wavelog..."
|
||||
mkdir -p "$WAVELOG_DIR"
|
||||
cp "$HOME/.local/share/HamPackServer/wavelog/docker-compose.yaml" "$WAVELOG_DIR/docker-compose.yaml"
|
||||
cp "$SELF/wavelog/docker-compose.yaml" "$WAVELOG_DIR/docker-compose.yaml"
|
||||
|
||||
WAVELOG_DB_PASS=$(openssl rand -base64 32 | tr -d '=/+' | cut -c1-24)
|
||||
sed -i "s|MARIADB_PASSWORD: wavelog # <- Insert a strong password here|MARIADB_PASSWORD: ${WAVELOG_DB_PASS}|" "$WAVELOG_DIR/docker-compose.yaml"
|
||||
@@ -157,14 +47,14 @@ if [ ! -d "$WAVELOG_DIR" ]; then
|
||||
fi
|
||||
|
||||
echo "Waiting for Docker socket..."
|
||||
timeout=30
|
||||
local timeout=30
|
||||
while [ ! -S /var/run/docker.sock ] && [ $timeout -gt 0 ]; do
|
||||
sleep 1
|
||||
timeout=$((timeout - 1))
|
||||
done
|
||||
if [ ! -S /var/run/docker.sock ]; then
|
||||
echo "Error: Docker socket not available after 30 seconds."
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
|
||||
sudo usermod -aG docker "$USER"
|
||||
@@ -172,37 +62,54 @@ if [ ! -d "$WAVELOG_DIR" ]; then
|
||||
sudo chmod 660 /var/run/docker.sock
|
||||
sg docker -c "docker compose -f '$WAVELOG_DIR/docker-compose.yaml' up -d"
|
||||
echo "Wavelog installed. Access it at http://localhost:8086"
|
||||
else
|
||||
echo "Wavelog is already installed, skipping."
|
||||
}
|
||||
|
||||
# --- Main ---
|
||||
|
||||
set -e
|
||||
|
||||
SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
COREDESKTOP="$HOME/.local/share/coredesktop"
|
||||
LEGACY_DIR="$HOME/.local/share/HamPackServer"
|
||||
SUDOERS_FILE=/etc/sudoers.d/99-hampack-install
|
||||
|
||||
clear || true
|
||||
print_logo
|
||||
|
||||
if [ ! -d "$COREDESKTOP" ]; then
|
||||
echo "HamPackServer requires CoreDesktop to be installed first."
|
||||
echo "Please install CoreDesktop: https://coredesktop.federated.computer"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install openhamclock
|
||||
# HamPackServer used to clone itself to ~/.local/share/HamPackServer. It now
|
||||
# lives wherever `sibling` cloned it.
|
||||
if [ -d "$LEGACY_DIR/.git" ] && [ "$LEGACY_DIR" != "$SELF" ]; then
|
||||
echo "Removing the old HamPackServer install at $LEGACY_DIR..."
|
||||
rm -rf "$LEGACY_DIR"
|
||||
fi
|
||||
|
||||
sudo -v
|
||||
|
||||
# Grant passwordless sudo for the duration of the install, revoke on exit
|
||||
echo "$USER ALL=(ALL) NOPASSWD: ALL" | sudo tee "$SUDOERS_FILE" > /dev/null
|
||||
sudo chmod 440 "$SUDOERS_FILE"
|
||||
trap 'sudo rm -f "$SUDOERS_FILE"' EXIT
|
||||
|
||||
echo "Installing openhamclock..."
|
||||
INSTALL_SUCCESS=true
|
||||
|
||||
if ! bash install-openhamclock.sh; then
|
||||
echo "Warning: install-openhamclock.sh encountered errors. openhamclock may not have installed correctly."
|
||||
# Let install-compiled.sh ask before building apps whose version it can't tell
|
||||
if ! HAMPACKSERVER_INTERACTIVE=1 bash "$SELF/update.sh"; then
|
||||
INSTALL_SUCCESS=false
|
||||
fi
|
||||
|
||||
# Fix networking (Avahi mDNS)
|
||||
|
||||
echo "Configuring networking..."
|
||||
|
||||
if ! bash fix-networking.sh; then
|
||||
echo "Warning: fix-networking.sh encountered errors. mDNS may not be configured correctly."
|
||||
if ! install_wavelog; then
|
||||
echo "Warning: Wavelog may not have installed correctly."
|
||||
INSTALL_SUCCESS=false
|
||||
fi
|
||||
|
||||
# Install Compiled Servers
|
||||
|
||||
echo "Installing compiled servers..."
|
||||
|
||||
if ! bash install-compiled.sh; then
|
||||
echo "Warning: install-compiled.sh encountered errors. Some applications may not have installed correctly."
|
||||
INSTALL_SUCCESS=false
|
||||
fi
|
||||
# Revoke passwordless sudo now, before a possible reboot skips the trap
|
||||
sudo rm -f "$SUDOERS_FILE"
|
||||
|
||||
echo ""
|
||||
if [ "$INSTALL_SUCCESS" = true ]; then
|
||||
@@ -227,21 +134,4 @@ case "$response" in
|
||||
;;
|
||||
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
|
||||
[ "$INSTALL_SUCCESS" = true ]
|
||||
|
||||
Reference in New Issue
Block a user