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>
This commit is contained in:
molty21 2026-03-16 19:24:43 +07:00 committed by GitHub
parent 15ef0fb68e
commit e963d6a2bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 384 additions and 82 deletions

View file

@ -2,36 +2,113 @@
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-aarch64.tar.bz2"
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
# Default values
INSTALL_DIR=""
SYSTEMD=""
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
if printf '%s' "$2" | grep -q '[[:space:]]'; then
echo "Error: --install-dir must not contain whitespace"
exit 1
fi
INSTALL_DIR="$2"
shift 2
;;
-s|--systemd)
SYSTEMD="yes"
shift
;;
--no-systemd)
SYSTEMD="no"
shift
;;
-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 (default: \$HOME/albyhub)"
echo " -s, --systemd Setup systemd service (auto-yes)"
echo " --no-systemd Skip systemd service setup (auto-no)"
echo " -y, --yes Non-interactive mode (auto-confirm all prompts)"
echo " --skip-verify Skip package signature verification"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Interactive mode"
echo " $0 -y -d /opt/albyhub -s # Non-interactive with systemd"
echo " $0 --yes --install-dir /app/albyhub # Non-interactive, no systemd"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use -h or --help for usage information"
exit 1
;;
esac
done
echo ""
echo ""
echo "⚡️ Welcome to Alby Hub"
echo "-----------------------------------------"
echo "Installing Alby Hub"
echo ""
printf "Absolute install directory path (default: %s/albyhub): " "$HOME"
read USER_INSTALL_DIR
INSTALL_DIR="${USER_INSTALL_DIR:-$HOME/albyhub}"
# Determine install directory
if [ -z "$INSTALL_DIR" ]; then
if [ "$NON_INTERACTIVE" = true ]; then
INSTALL_DIR="$HOME/albyhub"
else
printf "Absolute install directory path (default: %s/albyhub): " "$HOME"
read USER_INSTALL_DIR
INSTALL_DIR="${USER_INSTALL_DIR:-$HOME/albyhub}"
fi
fi
echo "Installing to: $INSTALL_DIR"
# create installation directory
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR" || exit 1
# download and extract the Alby Hub executable
wget "$ALBYHUB_URL"
if [ ! -f "verify.sh" ]; then
echo "Downloading the verification script..."
if ! wget -q "$VERIFIER_URL"; then
echo "❌ Failed to download the verification script." >&2
exit 1
fi
chmod +x verify.sh
if ! wget "$ALBYHUB_URL"; then
echo "❌ Failed to download Alby Hub package." >&2
exit 1
fi
if ! ./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
if [ "$SKIP_VERIFY" = false ]; then
if [ ! -f "verify.sh" ]; then
echo "Downloading the verification script..."
if ! wget -q "$VERIFIER_URL"; then
echo "❌ Failed to download the verification script." >&2
exit 1
fi
chmod +x verify.sh
fi
if ! ./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi
fi
if ! tar xvf server-linux-aarch64.tar.bz2; then
@ -65,18 +142,32 @@ echo "✅ Installation done."
echo ""
# optionally create a systemd service to start alby hub
printf "Do you want to setup a systemd service (requires sudo permission)? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) ;;
*)
echo ""
echo ""
echo "Run $INSTALL_DIR/start.sh to start Alby Hub"
echo "✅ DONE"
exit
;;
esac
SETUP_SYSTEMD=""
if [ -n "$SYSTEMD" ]; then
if [ "$SYSTEMD" = "yes" ]; then
SETUP_SYSTEMD="y"
else
SETUP_SYSTEMD="n"
fi
elif [ "$NON_INTERACTIVE" = true ]; then
# Default to no systemd in non-interactive mode unless explicitly requested
SETUP_SYSTEMD="n"
else
printf "Do you want to setup a systemd service (requires sudo permission)? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) SETUP_SYSTEMD="y" ;;
*) SETUP_SYSTEMD="n" ;;
esac
fi
if [ "$SETUP_SYSTEMD" = "n" ]; then
echo ""
echo ""
echo "Run $INSTALL_DIR/start.sh to start Alby Hub"
echo "✅ DONE"
exit 0
fi
sudo tee /etc/systemd/system/albyhub.service > /dev/null << EOF
[Unit]

View file

@ -1,6 +1,54 @@
#!/bin/sh
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-aarch64.tar.bz2"
# 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"
@ -10,13 +58,16 @@ 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."
printf "Do you want continue? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) ;;
*) exit ;;
esac
echo ""
# 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"
@ -29,11 +80,18 @@ if pgrep -x "albyhub" > /dev/null; then
fi
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
printf "Absolute install directory path (default: %s): " "$SCRIPT_DIR"
read USER_INSTALL_DIR
echo ""
INSTALL_DIR="${USER_INSTALL_DIR:-$SCRIPT_DIR}"
# 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"
@ -62,9 +120,11 @@ fi
echo "Downloading latest version"
wget "$ALBYHUB_URL"
if ! ./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
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 -xvf server-linux-aarch64.tar.bz2

View file

@ -2,36 +2,113 @@
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
# Default values
INSTALL_DIR=""
SYSTEMD=""
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
if printf '%s' "$2" | grep -q '[[:space:]]'; then
echo "Error: --install-dir must not contain whitespace"
exit 1
fi
INSTALL_DIR="$2"
shift 2
;;
-s|--systemd)
SYSTEMD="yes"
shift
;;
--no-systemd)
SYSTEMD="no"
shift
;;
-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 (default: \$HOME/albyhub)"
echo " -s, --systemd Setup systemd service (auto-yes)"
echo " --no-systemd Skip systemd service setup (auto-no)"
echo " -y, --yes Non-interactive mode (auto-confirm all prompts)"
echo " --skip-verify Skip package signature verification"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 # Interactive mode"
echo " $0 -y -d /opt/albyhub -s # Non-interactive with systemd"
echo " $0 --yes --install-dir /app/albyhub # Non-interactive, no systemd"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use -h or --help for usage information"
exit 1
;;
esac
done
echo ""
echo ""
echo "⚡️ Welcome to Alby Hub"
echo "-----------------------------------------"
echo "Installing Alby Hub"
echo ""
printf "Absolute install directory path (default: %s/albyhub): " "$HOME"
read USER_INSTALL_DIR
INSTALL_DIR="${USER_INSTALL_DIR:-$HOME/albyhub}"
# Determine install directory
if [ -z "$INSTALL_DIR" ]; then
if [ "$NON_INTERACTIVE" = true ]; then
INSTALL_DIR="$HOME/albyhub"
else
printf "Absolute install directory path (default: %s/albyhub): " "$HOME"
read USER_INSTALL_DIR
INSTALL_DIR="${USER_INSTALL_DIR:-$HOME/albyhub}"
fi
fi
echo "Installing to: $INSTALL_DIR"
# create installation directory
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR" || exit 1
# download and extract the Alby Hub executable
wget "$ALBYHUB_URL"
if [ ! -f "verify.sh" ]; then
echo "Downloading the verification script..."
if ! wget -q "$VERIFIER_URL"; then
echo "❌ Failed to download the verification script." >&2
exit 1
fi
chmod +x verify.sh
if ! wget "$ALBYHUB_URL"; then
echo "❌ Failed to download Alby Hub" >&2
exit 1
fi
if ! ./verify.sh server-linux-x86_64.tar.bz2 albyhub-Server-Linux-x86_64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
if [ "$SKIP_VERIFY" = false ]; then
if [ ! -f "verify.sh" ]; then
echo "Downloading the verification script..."
if ! wget -q "$VERIFIER_URL"; then
echo "❌ Failed to download the verification script." >&2
exit 1
fi
chmod +x verify.sh
fi
if ! ./verify.sh server-linux-x86_64.tar.bz2 albyhub-Server-Linux-x86_64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi
fi
if ! tar xvf server-linux-x86_64.tar.bz2; then
@ -65,18 +142,32 @@ echo "✅ Installation done."
echo ""
# optionally create a systemd service to start alby hub
printf "Do you want to setup a systemd service (requires sudo permission)? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) ;;
*)
echo ""
echo ""
echo "Run $INSTALL_DIR/start.sh to start Alby Hub"
echo "✅ DONE"
exit
;;
esac
SETUP_SYSTEMD=""
if [ -n "$SYSTEMD" ]; then
if [ "$SYSTEMD" = "yes" ]; then
SETUP_SYSTEMD="y"
else
SETUP_SYSTEMD="n"
fi
elif [ "$NON_INTERACTIVE" = true ]; then
# Default to no systemd in non-interactive mode unless explicitly requested
SETUP_SYSTEMD="n"
else
printf "Do you want to setup a systemd service (requires sudo permission)? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) SETUP_SYSTEMD="y" ;;
*) SETUP_SYSTEMD="n" ;;
esac
fi
if [ "$SETUP_SYSTEMD" = "n" ]; then
echo ""
echo ""
echo "Run $INSTALL_DIR/start.sh to start Alby Hub"
echo "✅ DONE"
exit 0
fi
sudo tee /etc/systemd/system/albyhub.service > /dev/null << EOF
[Unit]

View file

@ -1,6 +1,54 @@
#!/bin/sh
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
# 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"
@ -10,13 +58,16 @@ 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."
printf "Do you want continue? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) ;;
*) exit ;;
esac
echo ""
# 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"
@ -29,11 +80,18 @@ if pgrep -x "albyhub" > /dev/null; then
fi
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
printf "Absolute install directory path (default: %s): " "$SCRIPT_DIR"
read USER_INSTALL_DIR
echo ""
INSTALL_DIR="${USER_INSTALL_DIR:-$SCRIPT_DIR}"
# 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"
@ -62,9 +120,11 @@ fi
echo "Downloading latest version"
wget "$ALBYHUB_URL"
if ! ./verify.sh server-linux-x86_64.tar.bz2 albyhub-Server-Linux-x86_64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
if [ "$SKIP_VERIFY" = false ]; then
if ! ./verify.sh server-linux-x86_64.tar.bz2 albyhub-Server-Linux-x86_64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi
fi
tar -xvf server-linux-x86_64.tar.bz2