-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathinstall.sh
90 lines (73 loc) · 2.17 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/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 [[ $? -ne 0 ]]; then
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"
echo "Install it with sudo apt-get install bzip2"
exit
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 $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 /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
Environment="PORT=8029"
[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:8029"