mirror of
https://github.com/YunoHost-Apps/duniter_ynh.git
synced 2024-09-03 18:26:35 +02:00
80 lines
2 KiB
Bash
Executable file
80 lines
2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#set -e
|
|
|
|
# Retrieve arguments
|
|
app=duniter
|
|
domain=$1
|
|
path=$2
|
|
port=$3
|
|
sync_node=$4
|
|
sync_port=$5
|
|
salt=$6
|
|
password=$7
|
|
cpu=`bc -l <<< "scale=2; $8/100"`
|
|
|
|
# Source app helpers
|
|
source /usr/share/yunohost/helpers
|
|
|
|
# Check domain/path availability
|
|
sudo yunohost app checkurl $domain$path -a $app
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
# Check port availability
|
|
sudo yunohost app checkport $port
|
|
if [[ ! $? -eq 0 ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
# Check node availability
|
|
if curl --output /dev/null --silent --head --fail "$sync_node:$sync_port/node/summary"; then
|
|
echo "Node $sync_node:$sync_port is available"
|
|
else
|
|
ynh_die "Node $sync_node:$sync_port is not available" 2
|
|
fi
|
|
|
|
# Open port on firewall
|
|
sudo yunohost firewall allow TCP $port > /dev/null 2>&1
|
|
|
|
# Store config on YunoHost instance
|
|
ynh_app_setting_set $app port $port
|
|
|
|
# Install Duniter
|
|
cd /tmp
|
|
arch=$(uname -m)
|
|
if [ $arch == "x86_64" ]; then
|
|
wget https://github.com/duniter/duniter/releases/download/v0.20.0a52/duniter-v0.20.0a52-linux-x64.deb
|
|
elif [ $arch == "armv7l" ]; then
|
|
wget https://github.com/duniter/duniter/releases/download/v0.20.0a45/duniter-v0.20.0a45-linux-armv7l.deb
|
|
else
|
|
echo "$arch is not currently supported."
|
|
exit;
|
|
fi
|
|
sudo dpkg -i duniter-v0.20.0a*-linux-*.deb
|
|
#source ~/.bashrc
|
|
|
|
# Configure Duniter node
|
|
$app init --autoconf
|
|
$app config --remoteh $domain --port $port --remotep $port --salt $salt --passwd $password --cpu $cpu
|
|
|
|
# Synchronize Duniter node
|
|
echo "Synchronizing with $sync_node:$sync_port. It may take a while."
|
|
$app sync $sync_node $sync_port --nointeractive
|
|
|
|
# Launch Duniter node
|
|
$app start
|
|
|
|
# Add Duniter service to the YunoHost monitoring
|
|
sudo yunohost service add $app --log /home/admin/.config/$app/"$app"_default/"$app".log
|
|
|
|
# SSOwat Configuration
|
|
sudo yunohost app setting $app skipped_uris -v "/"
|
|
|
|
# Add proxy_pass
|
|
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
|
|
sudo sed -i "s@YNH_EXAMPLE_PORT@$port@" ../conf/nginx.conf
|
|
sudo sed -i "s@YNH_EXEMPLE_DOMAIN@$domain@" ../conf/nginx.conf
|
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
sudo service nginx reload
|