2016-08-20 02:31:08 +02:00
|
|
|
#/bin/bash
|
|
|
|
|
|
|
|
INSTALL_DUNITER_DEBIAN_PACKAGE () {
|
|
|
|
# Retrieve url of last version and version number
|
2017-03-17 15:53:28 +01:00
|
|
|
url=$(curl -s https://api.github.com/repos/duniter/duniter/releases | grep "browser_" | grep $arch | grep "linux" | grep "server" | sort -r | head -1 | cut -d\" -f4)
|
2016-10-11 19:30:05 +02:00
|
|
|
version=$(echo $url | cut -d/ -f8)
|
2016-08-20 02:31:08 +02:00
|
|
|
|
|
|
|
# Retrieve debian package and install it
|
|
|
|
wget -nc --quiet $url -P /tmp
|
2016-10-11 19:30:05 +02:00
|
|
|
deb="/tmp/duniter-server-$version-linux-$arch.deb"
|
2016-10-14 14:50:13 +02:00
|
|
|
sudo dpkg -i $deb > /dev/null
|
2016-10-11 19:30:05 +02:00
|
|
|
sudo rm -f $deb
|
2017-02-14 11:22:33 +01:00
|
|
|
|
2017-02-20 15:22:42 +01:00
|
|
|
# Patch Cesium to access local instance
|
2017-03-20 21:04:00 +01:00
|
|
|
cesium_conf="/opt/duniter/sources/node_modules/duniter-ui/public/cesium/config.js"
|
|
|
|
sudo sed -i "s@\"host\".*@\"host\": \"$domain\",@" $cesium_conf
|
|
|
|
sudo sed -i "s@\"port\".*@\"port\": \"443\"@" $cesium_conf
|
2016-08-20 02:31:08 +02:00
|
|
|
}
|
|
|
|
|
2017-03-14 09:41:28 +01:00
|
|
|
CONFIG_SSOWAT () {
|
2016-08-20 02:31:08 +02:00
|
|
|
# Add admin to the allowed users
|
|
|
|
sudo yunohost app addaccess $app -u $admin
|
|
|
|
|
|
|
|
# Allow only allowed users to access admin panel
|
2017-03-14 09:41:28 +01:00
|
|
|
if [ "$is_cesium_public" = "Yes" ]; then
|
2017-02-15 10:45:04 +01:00
|
|
|
# Cesium is public, do not protect it
|
|
|
|
ynh_app_setting_set "$app" protected_uris "/webui","/webmin"
|
|
|
|
else
|
|
|
|
# Cesium is not public, protect it
|
|
|
|
ynh_app_setting_set "$app" protected_uris "/webui","/webmin","/cesium"
|
|
|
|
fi
|
2016-08-20 02:31:08 +02:00
|
|
|
|
2017-02-14 11:22:33 +01:00
|
|
|
# Duniter is public app, with only some parts restricted in nginx.conf
|
2017-02-20 15:22:42 +01:00
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
2017-03-05 16:19:13 +01:00
|
|
|
|
|
|
|
# Set URL redirection from root to webadmin
|
|
|
|
ynh_app_setting_set "$app" redirected_urls "{'$domain/':'$domain/webui'}"
|
2016-08-20 02:31:08 +02:00
|
|
|
}
|
|
|
|
|
2017-03-14 09:41:28 +01:00
|
|
|
CONFIG_NGINX () {
|
2016-08-20 02:31:08 +02:00
|
|
|
# Configure Nginx
|
|
|
|
nginx_conf="../conf/nginx.conf"
|
|
|
|
sudo sed -i "s@YNH_EXAMPLE_PORT@$port@" $nginx_conf
|
|
|
|
sudo sed -i "s@YNH_EXAMPLE_DOMAIN@$domain@" $nginx_conf
|
|
|
|
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2017-02-25 12:09:07 +01:00
|
|
|
sudo service nginx reload
|
2016-08-20 02:31:08 +02:00
|
|
|
}
|
2017-03-31 11:33:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
REMOVE_DUNITER () {
|
|
|
|
# Stop duniter daemon
|
|
|
|
sudo duniter stop
|
|
|
|
|
|
|
|
# Remove Duniter package
|
|
|
|
sudo dpkg -r duniter
|
|
|
|
}
|