2015-05-24 23:01:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-12-02 21:41:55 +01:00
|
|
|
#set -e
|
|
|
|
|
2015-05-24 23:01:16 +02:00
|
|
|
# Retrieve arguments
|
2016-05-02 14:54:52 +02:00
|
|
|
app=duniter
|
2015-05-24 23:01:16 +02:00
|
|
|
domain=$1
|
2015-12-25 21:33:56 +01:00
|
|
|
path=$2
|
|
|
|
port=$3
|
|
|
|
sync_node=$4
|
|
|
|
sync_port=$5
|
|
|
|
salt=$6
|
|
|
|
password=$7
|
2015-12-29 19:45:24 +01:00
|
|
|
cpu=`bc -l <<< "scale=2; $8/100"`
|
2016-05-31 19:38:57 +02:00
|
|
|
version="v0.20.0a84"
|
2015-12-25 21:33:56 +01:00
|
|
|
|
2016-05-31 15:26:06 +02:00
|
|
|
# Source app helpers
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2015-12-25 21:33:56 +01:00
|
|
|
# Check domain/path availability
|
2015-12-29 19:40:53 +01:00
|
|
|
sudo yunohost app checkurl $domain$path -a $app
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-12-25 21:33:56 +01:00
|
|
|
|
|
|
|
# Check port availability
|
|
|
|
sudo yunohost app checkport $port
|
|
|
|
if [[ ! $? -eq 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-12-29 14:03:44 +01:00
|
|
|
# Check node availability
|
|
|
|
if curl --output /dev/null --silent --head --fail "$sync_node:$sync_port/node/summary"; then
|
2015-12-29 20:15:33 +01:00
|
|
|
echo "Node $sync_node:$sync_port is available"
|
2015-12-29 14:03:44 +01:00
|
|
|
else
|
2016-05-31 15:26:06 +02:00
|
|
|
ynh_die "Node $sync_node:$sync_port is not available" 2
|
2015-12-29 14:03:44 +01:00
|
|
|
fi
|
|
|
|
|
2015-12-25 21:33:56 +01:00
|
|
|
# Open port on firewall
|
|
|
|
sudo yunohost firewall allow TCP $port > /dev/null 2>&1
|
|
|
|
|
|
|
|
# Store config on YunoHost instance
|
2016-05-31 15:26:06 +02:00
|
|
|
ynh_app_setting_set $app port $port
|
2015-05-24 23:01:16 +02:00
|
|
|
|
2016-05-02 14:54:52 +02:00
|
|
|
# Install Duniter
|
2016-05-02 16:14:50 +02:00
|
|
|
cd /tmp
|
|
|
|
arch=$(uname -m)
|
|
|
|
if [ $arch == "x86_64" ]; then
|
2016-05-31 19:38:57 +02:00
|
|
|
arch="x64"
|
|
|
|
wget https://github.com/duniter/duniter/releases/download/$version/duniter-$version-linux-$arch.deb
|
|
|
|
#elif [ $arch == "armv7l" ]; then
|
|
|
|
# wget https://github.com/duniter/duniter/releases/download/$version/duniter-$version-linux-$arch.deb
|
2016-05-02 16:14:50 +02:00
|
|
|
else
|
2016-05-31 19:38:57 +02:00
|
|
|
ynh_die "$arch is not currently supported." 2
|
2016-05-02 16:14:50 +02:00
|
|
|
fi
|
2016-05-31 19:38:57 +02:00
|
|
|
sudo dpkg -i duniter-$version-linux-$arch.deb
|
|
|
|
#sudo rm -f /tmp/duniter-$version-linux-$arch.deb
|
2016-05-02 16:14:50 +02:00
|
|
|
#source ~/.bashrc
|
2015-05-24 23:01:16 +02:00
|
|
|
|
2016-05-02 14:54:52 +02:00
|
|
|
# Configure Duniter node
|
|
|
|
$app init --autoconf
|
|
|
|
$app config --remoteh $domain --port $port --remotep $port --salt $salt --passwd $password --cpu $cpu
|
2015-12-25 21:33:56 +01:00
|
|
|
|
2016-05-02 14:54:52 +02:00
|
|
|
# Synchronize Duniter node
|
2015-12-29 20:15:33 +01:00
|
|
|
echo "Synchronizing with $sync_node:$sync_port. It may take a while."
|
2016-05-02 14:54:52 +02:00
|
|
|
$app sync $sync_node $sync_port --nointeractive
|
2015-12-27 13:07:02 +01:00
|
|
|
|
2016-05-02 14:54:52 +02:00
|
|
|
# Launch Duniter node
|
|
|
|
$app start
|
2015-12-31 15:24:30 +01:00
|
|
|
|
2016-05-02 14:54:52 +02:00
|
|
|
# Add Duniter service to the YunoHost monitoring
|
|
|
|
sudo yunohost service add $app --log /home/admin/.config/$app/"$app"_default/"$app".log
|
2015-12-25 21:33:56 +01:00
|
|
|
|
|
|
|
# SSOwat Configuration
|
|
|
|
sudo yunohost app setting $app skipped_uris -v "/"
|
|
|
|
|
|
|
|
# Add proxy_pass
|
2015-12-29 11:26:10 +01:00
|
|
|
sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf
|
2015-12-25 21:33:56 +01:00
|
|
|
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
|