Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: better handle ports on Pi and allow albyhub to run on port 80 #584

Merged
merged 6 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/linux-x86_64/phoenixd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Run your Alby Hub with phoenixd as a backend.

To run Alby Hub with phoenixd use [docker-compose](https://docs.docker.com/compose/) using the [docker-compose.yml file](https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/phoenixd/docker-compose.yml).

$ wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/phoenixd/docker-compose.yml
$ wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/phoenixd/docker-compose.yml # <- edit for your needs, but defaults should work well
$ mkdir -p ./albyhub-phoenixd/phoenixd && mkdir -p ./albyhub-phoenixd/albyhub # <- create the data directories for phoenixd and albyhub. make sure to have backups of this
$ docker-compose up # or docker-compose up --pull=always <- to make sure you get the latest images

It will run on localhost:8080 by default. You can configure the port by editing the docker-compose.yml file.
Expand Down
14 changes: 3 additions & 11 deletions scripts/pi-arm/README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected] '/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 [email protected] '/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)"
```
Expand Down
22 changes: 18 additions & 4 deletions scripts/pi-arm/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,29 @@ 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

# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be optional? like how we ask to setup a service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any option makes it more complicated and more fragile. Those install scripts suck anyway because everybody wants it to be a bit different and systems are often different.

People also need to know a little bit of what they do.

IF we don't run as root then as far as I understand we need this. otherwise we need to run as root or on a different port.


# 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
Expand All @@ -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"
Expand All @@ -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 ""
Loading