Making shell scripts POSIX compliant (#2015)

* feat: usage of rsync for backups

* refactor: making scripts POSIX compliant
This commit is contained in:
Sergey B. 2026-02-26 08:19:30 +03:00 committed by GitHub
parent c64f31f3f7
commit 9701c726ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 184 additions and 162 deletions

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-aarch64.tar.bz2"
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
@ -8,18 +8,19 @@ echo "⚡️ Welcome to Alby Hub"
echo "-----------------------------------------"
echo "Installing Alby Hub"
echo ""
read -p "Absolute install directory path (default: $HOME/albyhub): " USER_INSTALL_DIR
printf "Absolute install directory path (default: %s/albyhub): " "$HOME"
read USER_INSTALL_DIR
INSTALL_DIR="${USER_INSTALL_DIR:-$HOME/albyhub}"
# create installation directory
mkdir -p $INSTALL_DIR
cd $INSTALL_DIR
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR" || exit 1
# download and extract the Alby Hub executable
wget $ALBYHUB_URL
wget "$ALBYHUB_URL"
if [[ ! -f "verify.sh" ]]; 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
@ -28,37 +29,35 @@ if [[ ! -f "verify.sh" ]]; then
chmod +x verify.sh
fi
./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2
if [[ $? -ne 0 ]]; then
if ! ./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi
tar xvf server-linux-aarch64.tar.bz2
if [[ $? -ne 0 ]]; then
if ! tar xvf server-linux-aarch64.tar.bz2; then
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"
echo "Install it with sudo apt-get install bzip2"
exit
exit 1
fi
rm server-linux-aarch64.tar.bz2
# prepare the data directory. this is pesistent and will hold all important data
mkdir -p $INSTALL_DIR/data
mkdir -p "$INSTALL_DIR/data"
# create a simple start script that sets the default configuration variables
tee $INSTALL_DIR/start.sh > /dev/null << EOF
#!/bin/bash
tee "$INSTALL_DIR/start.sh" > /dev/null << EOF
#!/bin/sh
echo "Starting Alby Hub"
WORK_DIR="$INSTALL_DIR/data" LDK_GOSSIP_SOURCE="" $INSTALL_DIR/bin/albyhub
EOF
chmod +x $INSTALL_DIR/start.sh
chmod +x "$INSTALL_DIR/start.sh"
# add an update script to keep the Hub up to date
# run this to update the hub
wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-aarch64/update.sh
chmod +x $INSTALL_DIR/update.sh
chmod +x "$INSTALL_DIR/update.sh"
echo ""
echo ""
@ -66,15 +65,18 @@ echo "✅ Installation done."
echo ""
# optionally create a systemd service to start alby hub
read -p "Do you want to setup a systemd service (requires sudo permission)? (y/n): " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo ""
echo ""
echo "Run $INSTALL_DIR/start.sh to start Alby Hub"
echo "✅ DONE"
exit
fi
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
sudo tee /etc/systemd/system/albyhub.service > /dev/null << EOF
[Unit]

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-aarch64.tar.bz2"
echo ""
@ -10,32 +10,32 @@ 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."
read -p "Do you want continue? (y/n):" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit
fi
printf "Do you want continue? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) ;;
*) exit ;;
esac
echo ""
sudo systemctl list-units --type=service --all | grep -Fq albyhub.service
if [[ $? -eq 0 ]]; then
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
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")")
read -p "Absolute install directory path (default: $SCRIPT_DIR): " USER_INSTALL_DIR
printf "Absolute install directory path (default: %s): " "$SCRIPT_DIR"
read USER_INSTALL_DIR
echo ""
INSTALL_DIR="${USER_INSTALL_DIR:-$SCRIPT_DIR}"
if ! test -f $INSTALL_DIR/data/nwc.db; then
if ! test -f "$INSTALL_DIR/data/nwc.db"; then
echo "Could not find Alby Hub in this directory"
exit 1
fi
@ -43,23 +43,26 @@ fi
echo "Running in $INSTALL_DIR"
# make sure we run this in the install directory
cd $INSTALL_DIR
cd "$INSTALL_DIR" || exit 1
echo "Cleaning up old backup"
rm -rf albyhub-backup
mkdir albyhub-backup
echo "Creating current backup"
mv bin albyhub-backup
mv lib albyhub-backup
cp -r data albyhub-backup
if command -v rsync > /dev/null 2>&1; then
rsync -av 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 $ALBYHUB_URL
wget "$ALBYHUB_URL"
./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2
if [[ $? -ne 0 ]]; then
if ! ./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi
@ -67,8 +70,7 @@ fi
tar -xvf server-linux-aarch64.tar.bz2
rm server-linux-aarch64.tar.bz2
sudo systemctl list-units --type=service --all | grep -Fq albyhub.service
if [[ $? -eq 0 ]]; then
if sudo systemctl list-units --type=service --all | grep -Fq albyhub.service; then
echo "Starting Alby Hub"
sudo systemctl start albyhub
fi

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
@ -8,18 +8,19 @@ echo "⚡️ Welcome to Alby Hub"
echo "-----------------------------------------"
echo "Installing Alby Hub"
echo ""
read -p "Absolute install directory path (default: $HOME/albyhub): " USER_INSTALL_DIR
printf "Absolute install directory path (default: %s/albyhub): " "$HOME"
read USER_INSTALL_DIR
INSTALL_DIR="${USER_INSTALL_DIR:-$HOME/albyhub}"
# create installation directory
mkdir -p $INSTALL_DIR
cd $INSTALL_DIR
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR" || exit 1
# download and extract the Alby Hub executable
wget $ALBYHUB_URL
wget "$ALBYHUB_URL"
if [[ ! -f "verify.sh" ]]; 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
@ -28,37 +29,35 @@ if [[ ! -f "verify.sh" ]]; then
chmod +x verify.sh
fi
./verify.sh server-linux-x86_64.tar.bz2 albyhub-Server-Linux-x86_64.tar.bz2
if [[ $? -ne 0 ]]; 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
tar xvf server-linux-x86_64.tar.bz2
if [[ $? -ne 0 ]]; then
if ! tar xvf server-linux-x86_64.tar.bz2; then
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"
echo "Install it with sudo apt-get install bzip2"
exit
exit 1
fi
rm server-linux-x86_64.tar.bz2
# prepare the data directory. this is pesistent and will hold all important data
mkdir -p $INSTALL_DIR/data
mkdir -p "$INSTALL_DIR/data"
# create a simple start script that sets the default configuration variables
tee $INSTALL_DIR/start.sh > /dev/null << EOF
#!/bin/bash
tee "$INSTALL_DIR/start.sh" > /dev/null << EOF
#!/bin/sh
echo "Starting Alby Hub"
WORK_DIR="$INSTALL_DIR/data" LDK_GOSSIP_SOURCE="" $INSTALL_DIR/bin/albyhub
EOF
chmod +x $INSTALL_DIR/start.sh
chmod +x "$INSTALL_DIR/start.sh"
# add an update script to keep the Hub up to date
# run this to update the hub
wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/update.sh
chmod +x $INSTALL_DIR/update.sh
chmod +x "$INSTALL_DIR/update.sh"
echo ""
echo ""
@ -66,15 +65,18 @@ echo "✅ Installation done."
echo ""
# optionally create a systemd service to start alby hub
read -p "Do you want to setup a systemd service (requires sudo permission)? (y/n): " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo ""
echo ""
echo "Run $INSTALL_DIR/start.sh to start Alby Hub"
echo "✅ DONE"
exit
fi
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
sudo tee /etc/systemd/system/albyhub.service > /dev/null << EOF
[Unit]

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
PHOENIX_VERSION="0.1.5"
@ -10,43 +10,43 @@ echo "⚡️ Welcome to AlbyHub"
echo "-----------------------------------------"
echo "Installing AlbyHub with phoenixd"
echo ""
read -p "Absolute install directory path (default: $HOME/albyhub-phoenixd): " USER_INSTALL_DIR
printf "Absolute install directory path (default: %s/albyhub-phoenixd): " "$HOME"
read USER_INSTALL_DIR
INSTALL_DIR="${USER_INSTALL_DIR:-$HOME/albyhub-phoenixd}"
echo "Installing phoenixd $PHOENIX_VERSION into $INSTALL_DIR"
mkdir -p $INSTALL_DIR
mkdir -p "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR/phoenixd"
cd $INSTALL_DIR
cd "$INSTALL_DIR" || exit 1
wget $PHOENIX_URL
unzip -j phoenix-$PHOENIX_VERSION-linux-x64.zip -d phoenixd
wget "$PHOENIX_URL"
unzip -j "phoenix-$PHOENIX_VERSION-linux-x64.zip" -d phoenixd
mkdir -p "$INSTALL_DIR/albyhub"
wget $ALBYHUB_URL
tar xvf server-linux-x86_64.tar.bz2 --directory=albyhub
if [[ $? -ne 0 ]]; then
wget "$ALBYHUB_URL"
if ! tar xvf server-linux-x86_64.tar.bz2 --directory=albyhub; then
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"
echo "Install it with sudo apt-get install bzip2"
exit
exit 1
fi
rm server-linux-x86_64.tar.bz2
rm phoenix-$PHOENIX_VERSION-linux-x64.zip
rm "phoenix-$PHOENIX_VERSION-linux-x64.zip"
### Create start scripts
tee $INSTALL_DIR/phoenixd/start.sh > /dev/null << EOF
#!/bin/bash
tee "$INSTALL_DIR/phoenixd/start.sh" > /dev/null << EOF
#!/bin/sh
echo "Starting phoenixd"
echo "Make sure to backup your phoenixd data in $INSTALL_DIR/phoenixd/data"
PHOENIX_DATADIR="$INSTALL_DIR/phoenixd/data" $INSTALL_DIR/phoenixd/phoenixd --agree-to-terms-of-service --http-bind-ip=0.0.0.0
EOF
tee $INSTALL_DIR/albyhub/start.sh > /dev/null << EOF
#!/bin/bash
tee "$INSTALL_DIR/albyhub/start.sh" > /dev/null << EOF
#!/bin/sh
echo "Starting Alby Hub"
phoenix_config_file=$INSTALL_DIR/phoenixd/data/phoenix.conf
@ -54,8 +54,8 @@ PHOENIXD_AUTHORIZATION=\$(awk -F'=' '/^http-password/{print \$2}' "\$phoenix_con
WORK_DIR="$INSTALL_DIR/albyhub/data" LN_BACKEND_TYPE=PHOENIX PHOENIXD_ADDRESS="http://localhost:9740" PHOENIXD_AUTHORIZATION=\$PHOENIXD_AUTHORIZATION LDK_GOSSIP_SOURCE="" $INSTALL_DIR/albyhub/bin/albyhub
EOF
tee $INSTALL_DIR/start.sh > /dev/null << EOF
#!/bin/bash
tee "$INSTALL_DIR/start.sh" > /dev/null << EOF
#!/bin/sh
$INSTALL_DIR/phoenixd/start.sh &
# wait a bit until phoenixd is started
@ -65,22 +65,25 @@ $INSTALL_DIR/albyhub/start.sh &
echo "Started..."
EOF
chmod +x $INSTALL_DIR/start.sh
chmod +x $INSTALL_DIR/phoenixd/start.sh
chmod +x $INSTALL_DIR/albyhub/start.sh
chmod +x "$INSTALL_DIR/start.sh"
chmod +x "$INSTALL_DIR/phoenixd/start.sh"
chmod +x "$INSTALL_DIR/albyhub/start.sh"
echo ""
echo ""
echo "Installation done."
echo ""
read -p "Do you want to setup a systemd service? (y/n): " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Run $INSTALL_DIR/start.sh to start phoenixd and Alby Hub"
echo "DONE"
exit
fi
printf "Do you want to setup a systemd service? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) ;;
*)
echo "Run $INSTALL_DIR/start.sh to start phoenixd and Alby Hub"
echo "DONE"
exit
;;
esac
sudo tee /etc/systemd/system/albyhub.service > /dev/null << EOF
[Unit]

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
echo ""
@ -10,32 +10,32 @@ 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."
read -p "Do you want continue? (y/n):" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit
fi
printf "Do you want continue? (y/n): "
read REPLY
case "$REPLY" in
[Yy]*) ;;
*) exit ;;
esac
echo ""
sudo systemctl list-units --type=service --all | grep -Fq albyhub.service
if [[ $? -eq 0 ]]; then
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
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")")
read -p "Absolute install directory path (default: $SCRIPT_DIR): " USER_INSTALL_DIR
printf "Absolute install directory path (default: %s): " "$SCRIPT_DIR"
read USER_INSTALL_DIR
echo ""
INSTALL_DIR="${USER_INSTALL_DIR:-$SCRIPT_DIR}"
if ! test -f $INSTALL_DIR/data/nwc.db; then
if ! test -f "$INSTALL_DIR/data/nwc.db"; then
echo "Could not find Alby Hub in this directory"
exit 1
fi
@ -43,23 +43,26 @@ fi
echo "Running in $INSTALL_DIR"
# make sure we run this in the install directory
cd $INSTALL_DIR
cd "$INSTALL_DIR" || exit 1
echo "Cleaning up old backup"
rm -rf albyhub-backup
mkdir albyhub-backup
echo "Creating current backup"
mv bin albyhub-backup
mv lib albyhub-backup
cp -r data albyhub-backup
if command -v rsync > /dev/null 2>&1; then
rsync -av 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 $ALBYHUB_URL
wget "$ALBYHUB_URL"
./verify.sh server-linux-x86_64.tar.bz2 albyhub-Server-Linux-x86_64.tar.bz2
if [[ $? -ne 0 ]]; 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
@ -67,8 +70,7 @@ fi
tar -xvf server-linux-x86_64.tar.bz2
rm server-linux-x86_64.tar.bz2
sudo systemctl list-units --type=service --all | grep -Fq albyhub.service
if [[ $? -eq 0 ]]; then
if sudo systemctl list-units --type=service --all | grep -Fq albyhub.service; then
echo "Starting Alby Hub"
sudo systemctl start albyhub
fi

View file

@ -1,3 +1,5 @@
#!/bin/sh
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
echo ""
@ -8,8 +10,8 @@ echo "Installing..."
sudo mkdir -p /opt/albyhub
sudo chown -R $USER:$USER /opt/albyhub
cd /opt/albyhub
sudo chown -R "$USER:$USER" /opt/albyhub
cd /opt/albyhub || exit 1
wget https://getalby.com/install/hub/server-linux-aarch64.tar.bz2
# add an update script to keep the Hub up to date
@ -17,7 +19,7 @@ wget https://getalby.com/install/hub/server-linux-aarch64.tar.bz2
wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/pi-aarch64/update.sh
chmod +x update.sh
if [[ ! -f "verify.sh" ]]; 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
@ -26,17 +28,16 @@ if [[ ! -f "verify.sh" ]]; then
chmod +x verify.sh
fi
./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2
if [[ $? -ne 0 ]]; then
if ! ./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi
# Extract archives
tar -xvf server-linux-aarch64.tar.bz2
if [[ $? -ne 0 ]]; then
if ! tar -xvf server-linux-aarch64.tar.bz2; then
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"
echo "Install it with sudo apt-get install bzip2"
exit 1
fi
# Cleanup

View file

@ -1,20 +1,24 @@
#!/bin/bash
#!/bin/sh
echo "🔃 Updating Alby Hub..."
sudo systemctl stop albyhub
# Download new artifacts
cd /opt/albyhub
cd /opt/albyhub || exit 1
rm -rf albyhub-backup
mkdir albyhub-backup
mv bin albyhub-backup
mv lib albyhub-backup
cp -r data albyhub-backup
if command -v rsync > /dev/null 2>&1; then
rsync -av data bin lib albyhub-backup/
else
mv bin albyhub-backup
mv lib albyhub-backup
cp -r data albyhub-backup
fi
wget https://getalby.com/install/hub/server-linux-aarch64.tar.bz2
./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2
if [[ $? -ne 0 ]]; then
if ! ./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi

View file

@ -1,3 +1,5 @@
#!/bin/sh
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
echo ""
@ -8,8 +10,8 @@ echo "Installing..."
sudo mkdir -p /opt/albyhub
sudo chown -R $USER:$USER /opt/albyhub
cd /opt/albyhub
sudo chown -R "$USER:$USER" /opt/albyhub
cd /opt/albyhub || exit 1
wget https://getalby.com/install/hub/server-linux-armv6.tar.bz2
# add an update script to keep the Hub up to date
@ -17,7 +19,7 @@ wget https://getalby.com/install/hub/server-linux-armv6.tar.bz2
wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/pi-arm/update.sh
chmod +x update.sh
if [[ ! -f "verify.sh" ]]; 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
@ -26,17 +28,16 @@ if [[ ! -f "verify.sh" ]]; then
chmod +x verify.sh
fi
./verify.sh server-linux-armv6.tar.bz2 albyhub-Server-Linux-armv6.tar.bz2
if [[ $? -ne 0 ]]; then
if ! ./verify.sh server-linux-armv6.tar.bz2 albyhub-Server-Linux-armv6.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi
# Extract archives
tar -xvf server-linux-armv6.tar.bz2
if [[ $? -ne 0 ]]; then
if ! tar -xvf server-linux-armv6.tar.bz2; then
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"
echo "Install it with sudo apt-get install bzip2"
exit 1
fi
# Cleanup

View file

@ -1,20 +1,24 @@
#!/bin/bash
#!/bin/sh
echo "🔃 Updating Alby Hub..."
sudo systemctl stop albyhub
# Download new artifacts
cd /opt/albyhub
cd /opt/albyhub || exit 1
rm -rf albyhub-backup
mkdir albyhub-backup
mv bin albyhub-backup
mv lib albyhub-backup
cp -r data albyhub-backup
if command -v rsync > /dev/null 2>&1; then
rsync -av data bin lib albyhub-backup/
else
mv bin albyhub-backup
mv lib albyhub-backup
cp -r data albyhub-backup
fi
wget https://getalby.com/install/hub/server-linux-armv6.tar.bz2
./verify.sh server-linux-armv6.tar.bz2 albyhub-Server-Linux-armv6.tar.bz2
if [[ $? -ne 0 ]]; then
if ! ./verify.sh server-linux-armv6.tar.bz2 albyhub-Server-Linux-armv6.tar.bz2; then
echo "❌ Verification failed, aborting installation"
exit 1
fi

View file

@ -1,24 +1,28 @@
#!/bin/bash
#!/bin/sh
MANIFEST_URL="https://getalby.com/install/hub/manifest.txt"
SIGNATURE_URL="https://getalby.com/install/hub/manifest.txt.asc"
verify_package() {
local archive_file="${1}"
local filename_in_manifest="${2}"
local response=""
archive_file="${1}"
filename_in_manifest="${2}"
response=""
while true; do
read -r -p "Verify package signature and integrity? (Y/N): " response
printf "Verify package signature and integrity? (Y/N): "
read response
case "$response" in
[Yy]) break ;;
[Nn]) echo "Verification skipped." ; return 0 ;;
[Yy]*) break ;;
[Nn]*)
echo "Verification skipped."
return 0
;;
*) echo "Invalid input. Please enter Y or N." ;;
esac
done
for cmd in gpg sha256sum; do
if ! command -v "$cmd" &>/dev/null; then
if ! command -v "$cmd" > /dev/null 2>&1; then
echo "❌ Required command '$cmd' is not available." >&2
return 1
fi
@ -42,17 +46,15 @@ verify_package() {
return 1
fi
local expected_hash
expected_hash=$(grep "${filename_in_manifest}" "manifest.txt" | awk '{print $1}') || true
if [[ -z "$expected_hash" ]]; then
if [ -z "$expected_hash" ]; then
echo "❌ No hash entry found for ${filename_in_manifest} in the manifest." >&2
return 1
fi
local actual_hash
actual_hash=$(sha256sum "$archive_file" | awk '{print $1}')
if [[ "$expected_hash" != "$actual_hash" ]]; then
if [ "$expected_hash" != "$actual_hash" ]; then
echo "❌ SHA256 hash mismatch! The file may be corrupted or tampered with." >&2
return 1
fi
@ -61,12 +63,11 @@ verify_package() {
return 0
}
if [[ $# -ne 2 ]]; then
if [ $# -ne 2 ]; then
echo "Usage: $0 <archive_file> <filename_in_manifest>"
exit 1
fi
verify_package "$1" "$2"
if [[ $? -ne 0 ]]; then
if ! verify_package "$1" "$2"; then
exit 1
fi