1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/duniter_ynh.git synced 2024-09-03 18:26:35 +02:00
duniter_ynh/scripts/install

70 lines
1.7 KiB
Text
Raw Normal View History

2015-05-24 23:01:16 +02:00
#!/bin/bash
#set -e
2015-05-24 23:01:16 +02:00
# Retrieve arguments
app=ucoin
2015-05-24 23:01:16 +02:00
domain=$1
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"`
# 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
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
2015-12-29 20:15:33 +01:00
echo "Node $sync_node:$sync_port is not available"
2015-12-29 14:03:44 +01:00
exit 1
fi
# Open port on firewall
sudo yunohost firewall allow TCP $port > /dev/null 2>&1
# Store config on YunoHost instance
sudo yunohost app setting $app port -v $port
2015-05-24 23:01:16 +02:00
2015-12-27 13:07:02 +01:00
# Install uCoin
bash ../sources/install.sh
UCOIN_DIR="/home/admin/.ucoin"
[ -s "$UCOIN_DIR/ucoin.sh" ] && . "$UCOIN_DIR/ucoin.sh"
2015-05-24 23:01:16 +02:00
# Configure uCoin node
2015-12-27 13:07:02 +01:00
ucoind init --autoconf
2015-12-29 19:45:24 +01:00
ucoind config --remoteh $domain --port $port --remotep $port --salt $salt --passwd $password --cpu $cpu
# Synchronize uCoin node
2015-12-29 20:15:33 +01:00
echo "Synchronizing with $sync_node:$sync_port. It may take a while."
2015-12-27 13:07:02 +01:00
ucoind sync $sync_node $sync_port --nointeractive > /dev/null 2>&1
# Launch uCoin node
ucoind start
2015-05-24 23:01:16 +02:00
# Add uCoin service to the YunoHost monitoring
2015-12-29 13:11:22 +01:00
sudo yunohost service add $app --log /home/admin/.config/ucoin/ucoin_default/ucoin.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