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

79 lines
2.1 KiB
Text
Raw Normal View History

2015-05-24 23:01:16 +02:00
#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
2015-05-24 23:01:16 +02:00
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$YNH_APP_ARG_DOMAIN
path="/"
port=10901
sync_node=$YNH_APP_ARG_SYNC_NODE
sync_port=$YNH_APP_ARG_SYNC_PORT
admin=$YNH_APP_ARG_ADMIN
is_cesium_public=$YNH_APP_ARG_IS_CESIUM_PUBLIC
# Source app helpers and functions
source /usr/share/yunohost/helpers
source functions.sh
# Check domain/path availability
2016-06-23 13:12:33 +02:00
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Check port availability
sudo yunohost app checkport $port
if [[ ! $? -eq 0 ]]; then
2017-02-21 14:51:22 +01:00
ynh_die "Port not available: ${port}"
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
ynh_die "Node $sync_node:$sync_port is not available" 2
2015-12-29 14:03:44 +01:00
fi
# Check the admin exists in YunoHost users
ynh_user_exists $admin
# Get CPU architecture and check it
arch=$(uname -m)
if [ $arch == "x86_64" ]; then
arch="x64"
fi
if [[ $arch != "x64" && $arch != "armv7l" ]]; then
ynh_die "$arch is not supported." 2
fi
# Store config on YunoHost instance
ynh_app_setting_set $app port $port
ynh_app_setting_set $app arch $arch
ynh_app_setting_set "$app" admin "$admin"
ynh_app_setting_set "$app" is_cesium_public "$is_cesium_public"
2015-05-24 23:01:16 +02:00
# Open port on firewall
sudo yunohost firewall allow TCP $port > /dev/null 2>&1
INSTALL_DUNITER_DEBIAN_PACKAGE
2015-05-24 23:01:16 +02:00
# Configure Duniter node
sudo duniter config --ipv4 127.0.0.1 --port $port --remoteh $domain --remotep 80 --noupnp
sudo duniter config --addep "BMAS $domain 443"
# Reset Duniter node's existing data (blockchain, not conf)
sudo duniter reset data > /dev/null
# Synchronize Duniter node
2015-12-29 20:15:33 +01:00
echo "Synchronizing with $sync_node:$sync_port. It may take a while."
sudo duniter sync $sync_node $sync_port --nointeractive > /dev/null
2015-12-27 13:07:02 +01:00
# Launch Duniter node
sudo duniter webstart
2015-12-31 15:24:30 +01:00
# Add Duniter service to the YunoHost monitoring
sudo yunohost service add $app --log /home/admin/.config/$app/"$app"_default/"$app".log
2017-03-14 09:41:28 +01:00
CONFIG_SSOWAT
CONFIG_NGINX