mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
feat: improve install scripts for linux (#395)
* feat: improve install scripts for linux this adds a default linux installation script to download and run Alby Hub on a plain Linux machine. * chore: download separate update script * chore: add example Caddyfile to setup Alby Hub with a Caddy reverse proxy for TLS * Update scripts/linux-x86_64/README.md Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com> * chore: move pi install scripts in special folder * chore: note about memory * chore: typo --------- Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
This commit is contained in:
parent
5027a05f99
commit
4c18fc5416
10 changed files with 280 additions and 28 deletions
|
|
@ -236,15 +236,17 @@ func (svc *nip47Service) HandleEvent(ctx context.Context, relay nostrmodels.Rela
|
|||
err = svc.publishResponseEvent(ctx, relay, &requestEvent, resp, &app)
|
||||
if err != nil {
|
||||
logger.Logger.WithFields(logrus.Fields{
|
||||
"requestEventNostrId": event.ID,
|
||||
"eventKind": event.Kind,
|
||||
"appId": app.ID,
|
||||
"requestEventNostrId": event.ID,
|
||||
"responseEventNostrId": resp.ID,
|
||||
"eventKind": event.Kind,
|
||||
"appId": app.ID,
|
||||
}).WithError(err).Error("Failed to publish event")
|
||||
requestEvent.State = db.REQUEST_EVENT_STATE_HANDLER_ERROR
|
||||
} else {
|
||||
requestEvent.State = db.REQUEST_EVENT_STATE_HANDLER_EXECUTED
|
||||
logger.Logger.WithFields(logrus.Fields{
|
||||
"requestEventNostrId": event.ID,
|
||||
"responseEventNostrId": resp.ID,
|
||||
"eventKind": event.Kind,
|
||||
"appId": app.ID,
|
||||
}).Info("Published response")
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
### Installation on a Raspberry Pi Zero
|
||||
|
||||
```shell
|
||||
/bin/bash -c "$(curl -fsSL https://getalby.com/install/hub/pi-zero-install.sh)"
|
||||
```
|
||||
|
||||
### Updating a running instance
|
||||
|
||||
```shell
|
||||
/bin/bash -c "$(curl -fsSL https://getalby.com/install/hub/pi-zero-update.sh)"
|
||||
```
|
||||
19
scripts/linux-x86_64/Caddyfile.example
Normal file
19
scripts/linux-x86_64/Caddyfile.example
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Example Caddyfile to run Alby Hub behind a Caddy reverse proxy
|
||||
# Caddy has embedded letsencrypt support and creates HTTPS certificates
|
||||
# learn more: https://caddyserver.com/docs/getting-started
|
||||
|
||||
# Refer to the Caddy docs for more information:
|
||||
# https://caddyserver.com/docs/caddyfile
|
||||
|
||||
|
||||
:80 {
|
||||
# optional additional basic authentication
|
||||
# the password is hashed, see Caddy documentation: https://caddyserver.com/docs/caddyfile/directives/basic_auth
|
||||
#basicauth {
|
||||
# Username "Bob", password "hiccup"
|
||||
# Bob $2a$14$Zkx19XLiW6VYouLHR5NmfOFU0z2GTNmpkT/5qqR7hx4IjWJPDhjvG
|
||||
#}
|
||||
|
||||
# Alby Hub runs on 8080 by default
|
||||
reverse_proxy :8080
|
||||
}
|
||||
53
scripts/linux-x86_64/README.md
Normal file
53
scripts/linux-x86_64/README.md
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Alby Hub on a Linux server
|
||||
|
||||
## Requirements
|
||||
|
||||
- Linux distribution
|
||||
- Runs pretty much on any VPS/server with 512MB RAM or more (+some swap space ideally)
|
||||
|
||||
### Installation (non-Docker)
|
||||
|
||||
We have prepared an installation script that installs Alby Hub for you.
|
||||
We recommend inspecting the install script and if needed adjusting it or taking inspiration from it for your setup.
|
||||
|
||||
As a general good practice we recommend creating a new system user.
|
||||
|
||||
$ adduser albyhub
|
||||
|
||||
Run the installation script on your server:
|
||||
|
||||
$ wget https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/install.sh
|
||||
$ ./install.sh
|
||||
|
||||
Or directly through SSH:
|
||||
$ ssh albyhub@[YOUR IP] '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/getAlby/hub/master/scripts/linux-x86_64/install.sh)"'
|
||||
|
||||
|
||||
The install script will prompt you for an installation folder and will install Alby Hub.
|
||||
|
||||
Optionally it can also create a systemd service for you.
|
||||
|
||||
Alby Hub will run on localhost:8080 by default (configurable using the `PORT` environment variable)
|
||||
To run on a public domain we recommend the use of a reverse proxy using [Caddy](https://caddyserver.com/)
|
||||
|
||||
### Running the services
|
||||
|
||||
Either use systemd:
|
||||
|
||||
$ sudo systemctl [start|stop] albyhub.service
|
||||
|
||||
Or use the start scripts:
|
||||
|
||||
$ [your install path]/start.sh
|
||||
|
||||
### Backup !
|
||||
|
||||
Make sure to backup your data directories:
|
||||
|
||||
- `[your install path]/data`
|
||||
|
||||
### Update
|
||||
|
||||
The install script will add an update.sh script to update Alby Hub. It will download the latest version for you.
|
||||
|
||||
After the update you will have to unlock Alby Hub again.
|
||||
88
scripts/linux-x86_64/install.sh
Normal file
88
scripts/linux-x86_64/install.sh
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
#!/bin/bash
|
||||
|
||||
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
|
||||
echo ""
|
||||
echo ""
|
||||
echo "⚡️ Welcome to Alby Hub"
|
||||
echo "-----------------------------------------"
|
||||
echo "Installing Alby Hub"
|
||||
echo ""
|
||||
read -p "Absolute install directory path (default: $HOME/albyhub): " USER_INSTALL_DIR
|
||||
|
||||
INSTALL_DIR="${USER_INSTALL_DIR:-$HOME/albyhub}"
|
||||
|
||||
# create installation directory
|
||||
mkdir -p $INSTALL_DIR
|
||||
cd $INSTALL_DIR
|
||||
|
||||
# download and extract the Alby Hub executable
|
||||
wget $ALBYHUB_URL
|
||||
tar xvf server-linux-x86_64.tar.bz2
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"
|
||||
echo "Install it with sudo apt-get install bzip2"
|
||||
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
|
||||
|
||||
# create a simple start script that sets the default configuration variables
|
||||
tee -a $INSTALL_DIR/start.sh > /dev/null << EOF
|
||||
#!/bin/bash
|
||||
|
||||
echo "Starting Alby Hub"
|
||||
WORK_DIR="$INSTALL_DIR/data" LOG_EVENTS=true LDK_GOSSIP_SOURCE="" $INSTALL_DIR/bin/albyhub
|
||||
EOF
|
||||
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
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
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
|
||||
|
||||
sudo tee -a /etc/systemd/system/albyhub.service > /dev/null << EOF
|
||||
[Unit]
|
||||
Description=Alby Hub
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
User=$USER
|
||||
ExecStart=$INSTALL_DIR/start.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
sudo systemctl enable albyhub
|
||||
sudo systemctl start albyhub
|
||||
|
||||
echo "Run 'sudo systemctl start/stop albyhub' to start/stop AlbyHub"
|
||||
echo ""
|
||||
echo ""
|
||||
echo " ✅ DONE. Open Alby Hub to get started"
|
||||
echo "Alby Hub runs by default on localhost:8080"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64"
|
||||
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
|
||||
PHOENIX_VERSION="0.1.5"
|
||||
PHOENIX_URL="https://github.com/ACINQ/phoenixd/releases/download/v$PHOENIX_VERSION/phoenix-$PHOENIX_VERSION-linux-x64.zip"
|
||||
|
||||
|
|
@ -26,9 +26,13 @@ unzip -j phoenix-$PHOENIX_VERSION-linux-x64.zip -d phoenixd
|
|||
|
||||
mkdir -p "$INSTALL_DIR/albyhub"
|
||||
wget $ALBYHUB_URL
|
||||
tar xf albyhub-Server-Linux-x86_64.tar.gz --directory=albyhub
|
||||
tar xvf server-linux-x86_64.tar.bz2 --directory=albyhub
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"
|
||||
echo "Install it with sudo apt-get install bzip2"
|
||||
fi
|
||||
|
||||
rm albyhub-Server-Linux-x86_64.tar.gz
|
||||
rm server-linux-x86_64.tar.bz2
|
||||
rm phoenix-$PHOENIX_VERSION-linux-x64.zip
|
||||
|
||||
### Create start scripts
|
||||
|
|
@ -53,9 +57,9 @@ tee -a $INSTALL_DIR/start.sh > /dev/null << EOF
|
|||
#!/bin/bash
|
||||
|
||||
$INSTALL_DIR/phoenixd/start.sh &
|
||||
# wait a but until phoenixd is started
|
||||
# wait a bit until phoenixd is started
|
||||
# especially on the first run to make sure the config is there
|
||||
sleep 7
|
||||
sleep 8
|
||||
$INSTALL_DIR/albyhub/start.sh &
|
||||
echo "Started..."
|
||||
EOF
|
||||
|
|
@ -69,7 +73,7 @@ echo ""
|
|||
echo "Installation done."
|
||||
echo ""
|
||||
|
||||
read -p "Do you want to setup a systemd service? " -n 1 -r
|
||||
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"
|
||||
|
|
@ -87,7 +91,7 @@ Wants=network-online.target
|
|||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
User=root
|
||||
User=$USER
|
||||
ExecStart=$INSTALL_DIR/albyhub/start.sh
|
||||
|
||||
[Install]
|
||||
|
|
@ -104,7 +108,7 @@ Wants=network-online.target
|
|||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
User=root
|
||||
User=$USER
|
||||
ExecStart=$INSTALL_DIR/phoenixd/start.sh
|
||||
|
||||
[Install]
|
||||
|
|
@ -114,9 +118,13 @@ EOF
|
|||
echo ""
|
||||
echo ""
|
||||
|
||||
echo "Run 'sudo systemctl enable albyhub' to enable the Albyhub service"
|
||||
echo "Run 'sudo systemctl enable phoenixd' to enable the phoenixd service"
|
||||
echo "Run 'sudo systemctl start albyhub' to start Albyhub"
|
||||
echo "Run 'sudo systemctl start phoenixd' to start phoenixd"
|
||||
sudo systemctl enable albyhub
|
||||
sudo systemctl enable phoenixd
|
||||
sudo systemctl start phoenixd
|
||||
sudo systemctl start albyhub
|
||||
|
||||
echo "Run 'sudo systemctl start/stop albyhub' to start/stop AlbyHub"
|
||||
echo "Run 'sudo systemctl start/stop phoenixd' to start/stop phoenixd"
|
||||
echo ""
|
||||
echo "DONE."
|
||||
echo "✅ DONE."
|
||||
echo "Alby Hub runs by default on localhost:8080"
|
||||
|
|
|
|||
64
scripts/linux-x86_64/update.sh
Normal file
64
scripts/linux-x86_64/update.sh
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#!/bin/bash
|
||||
|
||||
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
|
||||
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."
|
||||
|
||||
read -p "Do you want continue? (y/n): " -n 1 -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
|
||||
sudo systemctl list-units --type=service --all | grep -Fq albyhub.service
|
||||
if [[ $? -eq 0 ]]; 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 "$0")
|
||||
read -p "Absolute install directory path (default: $SCRIPT_DIR/albyhub): " USER_INSTALL_DIR
|
||||
|
||||
INSTALL_DIR="${USER_INSTALL_DIR:-$SCRIPT_DIR/albyhub}"
|
||||
|
||||
echo "Running in $INSTALL_DIR"
|
||||
# make sure we run this in the install directory
|
||||
cd $INSTALL_DIR
|
||||
|
||||
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
|
||||
|
||||
|
||||
echo "Downloading latest version"
|
||||
wget $ALBYHUB_URL
|
||||
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
|
||||
echo "Starting Alby Hub"
|
||||
sudo systemctl start albyhub
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo "✅ Update finished! Please unlock your wallet."
|
||||
echo ""
|
||||
25
scripts/pi-arm/README.md
Normal file
25
scripts/pi-arm/README.md
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
### Installation on a Raspberry Pi Zero
|
||||
|
||||
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:
|
||||
```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:
|
||||
```shell
|
||||
/bin/bash -c "$(curl -fsSL https://getalby.com/install/hub/pi-zero-update.sh)"
|
||||
```
|
||||
|
||||
And see install.sh and update.sh for details.
|
||||
|
|
@ -12,6 +12,10 @@ wget https://getalby.com/install/hub/server-linux-armv6.tar.bz2
|
|||
|
||||
# Extract archives
|
||||
tar -xvf server-linux-armv6.tar.bz2
|
||||
if [[ $? -eq 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
|
||||
|
|
@ -27,7 +31,7 @@ Wants=network-online.target
|
|||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=1
|
||||
User=root
|
||||
User=$USER
|
||||
ExecStart=/opt/albyhub/bin/albyhub
|
||||
# Hack to ensure Alby Hub never uses more than 90% CPU
|
||||
CPUQuota=90%
|
||||
Loading…
Add table
Add a link
Reference in a new issue