diff --git a/scripts/pi-arm/README.md b/scripts/pi-arm/README.md index df96d651..a092209f 100644 --- a/scripts/pi-arm/README.md +++ b/scripts/pi-arm/README.md @@ -1,23 +1,15 @@ -### Installation on a Raspberry Pi Zero +### Installation on a Raspberry Pi Zero (arm) Have a look at our [installation guide](https://guides.getalby.com/user-guide/v/alby-account-and-browser-extension/alby-hub/alby-hub-flavors/raspberry-pi-zero) for more details. -```shell - $ ssh albyhub@albyhub.local '/bin/bash -c "$(curl -fsSL https://getalby.com/install/hub/pi-zero-install.sh)"' - ``` - -or on the Pi directly: +SSH into your Pi and run: ```shell /bin/bash -c "$(curl -fsSL https://getalby.com/install/hub/pi-zero-install.sh)" ``` ### Updating a running instance -```shell - $ ssh albyhub@albyhub.local '/bin/bash -c "$(curl -fsSL https://getalby.com/install/hub/pi-zero-install.sh)"' - ``` - -or on the Pi directly: +SSH into your Pi and run: ```shell /bin/bash -c "$(curl -fsSL https://getalby.com/install/hub/pi-zero-update.sh)" ``` diff --git a/scripts/pi-arm/install.sh b/scripts/pi-arm/install.sh index 490369d5..8e456cf6 100644 --- a/scripts/pi-arm/install.sh +++ b/scripts/pi-arm/install.sh @@ -12,7 +12,7 @@ wget https://getalby.com/install/hub/server-linux-armv6.tar.bz2 # Extract archives tar -xvf server-linux-armv6.tar.bz2 -if [[ $? -eq 0 ]]; then +if [[ $? -ne 0 ]]; then echo "Failed to unpack Alby Hub. Potentially bzip2 is missing" echo "Install it with sudo apt-get install bzip2" fi @@ -20,8 +20,21 @@ fi # Cleanup rm server-linux-armv6.tar.bz2 +# allow albyhub to bind on port 80 +sudo setcap CAP_NET_BIND_SERVICE=+eip /opt/albyhub/bin/albyhub + +# Use port 80 if available otherwise 8029 +if sudo lsof -Pi :80 -sTCP:LISTEN -t >/dev/null ; then + PORT=8029 + URL="http://$HOSTNAME.local:8029" +else + PORT=80 + URL="http://$HOSTNAME.local" +fi + ### Create systemd service -sudo tee -a /etc/systemd/system/albyhub.service > /dev/null << EOF +if [[ ! -e /etc/systemd/system/albyhub.service ]]; then + sudo tee -a /etc/systemd/system/albyhub.service > /dev/null << EOF [Unit] Description=Alby Hub After=network-online.target @@ -36,7 +49,7 @@ ExecStart=/opt/albyhub/bin/albyhub # Hack to ensure Alby Hub never uses more than 90% CPU CPUQuota=90% -Environment="PORT=80" +Environment="PORT=$PORT" Environment="WORK_DIR=/opt/albyhub/data" Environment="LDK_ESPLORA_SERVER=https://electrs.getalbypro.com" Environment="LOG_EVENTS=true" @@ -45,11 +58,12 @@ Environment="LDK_GOSSIP_SOURCE=" [Install] WantedBy=multi-user.target EOF +fi sudo systemctl enable albyhub sudo systemctl start albyhub echo "" echo "" -echo "✅ Installation finished! Please visit http://$HOSTNAME.local to configure your new Alby Hub." +echo "✅ Installation finished! Please visit $URL to configure your new Alby Hub." echo ""