alby-hub/scripts/linux-aarch64/update.sh

142 lines
3.5 KiB
Bash
Raw Normal View History

#!/bin/sh
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-aarch64.tar.bz2"
feat: make installation scripts agent-friendly with CLI args (#2144) * feat: make installation scripts agent-friendly with CLI args Add command-line argument support to install.sh and update.sh for both x86_64 and aarch64 architectures: - -d, --install-dir DIR Set installation directory - -s, --systemd Auto-setup systemd service (install only) - --no-systemd Skip systemd setup (install only) - -y, --yes Non-interactive mode (auto-confirm prompts) - -h, --help Show usage information This allows agents and automation tools to run the scripts without interactive prompts, making them suitable for CI/CD pipelines and automated deployments. * fix: add argument validation for --install-dir flag Add validation to ensure -d/--install-dir is provided with a valid value: - Checks that argument exists (not empty) - Checks that argument doesn't start with '-' (not another flag) - Exits with error message if validation fails Fixes CodeRabbit review feedback on PR #2144. * feat: add --skip-verify flag to skip verification step Add --skip-verify flag to install and update scripts: - linux-x86_64/install.sh - linux-x86_64/update.sh - linux-aarch64/install.sh - linux-aarch64/update.sh When --skip-verify is passed, the scripts skip downloading and calling verify.sh entirely. Usage: ./install.sh --skip-verify * fix: ensure install dir does not contain whitespace Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestion from @rolznz * Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestion from @rolznz * Update scripts/linux-aarch64/install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: molty21 <moltbot21@agentmail.to> Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-03-16 19:24:43 +07:00
# Default values
INSTALL_DIR=""
NON_INTERACTIVE=false
SKIP_VERIFY=false
# Parse command-line arguments
while [ $# -gt 0 ]; do
case "$1" in
-d|--install-dir)
if [ -z "$2" ] || [ "${2#-}" != "$2" ]; then
echo "Error: --install-dir requires a non-empty directory path"
exit 1
fi
INSTALL_DIR="$2"
shift 2
;;
-y|--yes)
NON_INTERACTIVE=true
shift
;;
--skip-verify)
SKIP_VERIFY=true
shift
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -d, --install-dir DIR Set installation directory (auto-detected by default)"
echo " -y, --yes Non-interactive mode (skip confirmation prompt)"
echo " --skip-verify Skip package signature verification"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Interactive mode"
echo " $0 -y # Skip confirmation prompt"
echo " $0 -y -d /opt/albyhub # Non-interactive with specific directory"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use -h or --help for usage information"
exit 1
;;
esac
done
echo ""
echo ""
echo "⚡️ Updating Alby Hub"
echo "-----------------------------------------"
echo "This will download the latest version of Alby Hub."
echo "You will have to unlock Alby Hub after the update."
echo ""
echo "Make sure you have your unlock password available and a backup of your seed."
feat: make installation scripts agent-friendly with CLI args (#2144) * feat: make installation scripts agent-friendly with CLI args Add command-line argument support to install.sh and update.sh for both x86_64 and aarch64 architectures: - -d, --install-dir DIR Set installation directory - -s, --systemd Auto-setup systemd service (install only) - --no-systemd Skip systemd setup (install only) - -y, --yes Non-interactive mode (auto-confirm prompts) - -h, --help Show usage information This allows agents and automation tools to run the scripts without interactive prompts, making them suitable for CI/CD pipelines and automated deployments. * fix: add argument validation for --install-dir flag Add validation to ensure -d/--install-dir is provided with a valid value: - Checks that argument exists (not empty) - Checks that argument doesn't start with '-' (not another flag) - Exits with error message if validation fails Fixes CodeRabbit review feedback on PR #2144. * feat: add --skip-verify flag to skip verification step Add --skip-verify flag to install and update scripts: - linux-x86_64/install.sh - linux-x86_64/update.sh - linux-aarch64/install.sh - linux-aarch64/update.sh When --skip-verify is passed, the scripts skip downloading and calling verify.sh entirely. Usage: ./install.sh --skip-verify * fix: ensure install dir does not contain whitespace Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestion from @rolznz * Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestion from @rolznz * Update scripts/linux-aarch64/install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: molty21 <moltbot21@agentmail.to> Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-03-16 19:24:43 +07:00
# Confirmation prompt
if [ "$NON_INTERACTIVE" = false ]; then
printf "Do you want to continue? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) ;;
*) exit ;;
esac
echo ""
fi
if sudo systemctl list-units --type=service --all | grep -Fq albyhub.service; then
echo "Stopping Alby Hub"
sudo systemctl stop albyhub
fi
if pgrep -x "albyhub" > /dev/null; then
echo "Alby Hub process is still running, stopping it now."
pkill -f albyhub
fi
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
feat: make installation scripts agent-friendly with CLI args (#2144) * feat: make installation scripts agent-friendly with CLI args Add command-line argument support to install.sh and update.sh for both x86_64 and aarch64 architectures: - -d, --install-dir DIR Set installation directory - -s, --systemd Auto-setup systemd service (install only) - --no-systemd Skip systemd setup (install only) - -y, --yes Non-interactive mode (auto-confirm prompts) - -h, --help Show usage information This allows agents and automation tools to run the scripts without interactive prompts, making them suitable for CI/CD pipelines and automated deployments. * fix: add argument validation for --install-dir flag Add validation to ensure -d/--install-dir is provided with a valid value: - Checks that argument exists (not empty) - Checks that argument doesn't start with '-' (not another flag) - Exits with error message if validation fails Fixes CodeRabbit review feedback on PR #2144. * feat: add --skip-verify flag to skip verification step Add --skip-verify flag to install and update scripts: - linux-x86_64/install.sh - linux-x86_64/update.sh - linux-aarch64/install.sh - linux-aarch64/update.sh When --skip-verify is passed, the scripts skip downloading and calling verify.sh entirely. Usage: ./install.sh --skip-verify * fix: ensure install dir does not contain whitespace Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestion from @rolznz * Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestion from @rolznz * Update scripts/linux-aarch64/install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: molty21 <moltbot21@agentmail.to> Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-03-16 19:24:43 +07:00
# Determine install directory
if [ -z "$INSTALL_DIR" ]; then
if [ "$NON_INTERACTIVE" = true ]; then
INSTALL_DIR="$SCRIPT_DIR"
else
printf "Absolute install directory path (default: %s): " "$SCRIPT_DIR"
read USER_INSTALL_DIR
echo ""
INSTALL_DIR="${USER_INSTALL_DIR:-$SCRIPT_DIR}"
fi
fi
if ! test -f "$INSTALL_DIR/data/nwc.db"; then
echo "Could not find Alby Hub in this directory"
exit 1
fi
echo "Running in $INSTALL_DIR"
# make sure we run this in the install directory
cd "$INSTALL_DIR" || exit 1
echo "Cleaning up old backup"
rm -rf albyhub-backup
mkdir albyhub-backup
echo "Creating current backup"
if command -v rsync > /dev/null 2>&1; then
rsync -a data bin lib albyhub-backup/
else
mv bin albyhub-backup
mv lib albyhub-backup
cp -r data albyhub-backup
fi
echo "Downloading latest version"
wget -q "$ALBYHUB_URL"
feat: make installation scripts agent-friendly with CLI args (#2144) * feat: make installation scripts agent-friendly with CLI args Add command-line argument support to install.sh and update.sh for both x86_64 and aarch64 architectures: - -d, --install-dir DIR Set installation directory - -s, --systemd Auto-setup systemd service (install only) - --no-systemd Skip systemd setup (install only) - -y, --yes Non-interactive mode (auto-confirm prompts) - -h, --help Show usage information This allows agents and automation tools to run the scripts without interactive prompts, making them suitable for CI/CD pipelines and automated deployments. * fix: add argument validation for --install-dir flag Add validation to ensure -d/--install-dir is provided with a valid value: - Checks that argument exists (not empty) - Checks that argument doesn't start with '-' (not another flag) - Exits with error message if validation fails Fixes CodeRabbit review feedback on PR #2144. * feat: add --skip-verify flag to skip verification step Add --skip-verify flag to install and update scripts: - linux-x86_64/install.sh - linux-x86_64/update.sh - linux-aarch64/install.sh - linux-aarch64/update.sh When --skip-verify is passed, the scripts skip downloading and calling verify.sh entirely. Usage: ./install.sh --skip-verify * fix: ensure install dir does not contain whitespace Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestion from @rolznz * Apply suggestion from @coderabbitai[bot] Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Apply suggestion from @rolznz * Update scripts/linux-aarch64/install.sh Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: molty21 <moltbot21@agentmail.to> Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-03-16 19:24:43 +07:00
if [ "$SKIP_VERIFY" = false ]; then
if ! ./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi
fi
tar -xf server-linux-aarch64.tar.bz2
rm server-linux-aarch64.tar.bz2
if sudo systemctl list-units --type=service --all | grep -Fq albyhub.service; then
echo "Starting Alby Hub"
sudo systemctl start albyhub
fi
echo ""
echo ""
echo "✅ Update finished! Please unlock your wallet."
echo ""