2016-06-13 22:03:33 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
2016-06-15 23:35:36 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2016-06-13 22:03:33 +02:00
|
|
|
|
|
|
|
# Retrieve app settings
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
|
|
|
|
|
|
# Remove trailing "/" for next commands
|
|
|
|
path=${path%/}
|
|
|
|
|
2016-06-14 10:23:29 +02:00
|
|
|
# Retreive sources and install them
|
2016-06-13 22:03:33 +02:00
|
|
|
src_path=/var/www/$app
|
|
|
|
sudo rm -rf $src_path
|
|
|
|
sudo mkdir -p $src_path
|
2016-08-20 17:01:34 +02:00
|
|
|
url=$(curl -s https://api.github.com/repos/duniter/cesium/releases | grep "browser_" | grep "web" | head -1 | cut -d\" -f4)
|
2016-07-03 09:43:39 +02:00
|
|
|
wget -nc --quiet $url -P /tmp
|
2016-08-25 14:22:59 +02:00
|
|
|
|
|
|
|
sudo unzip -q /tmp/cesium-*-web.zip -d $src_path
|
|
|
|
sudo rm -f /tmp/cesium-*-web.zip
|
2016-06-13 22:03:33 +02:00
|
|
|
sudo chown -R www-data: $src_path
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
nginx_conf=../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
|
|
|
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
|
|
|
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
|
|
|
|
# If app is public, add url to SSOWat conf as skipped_uris
|
|
|
|
if [[ $is_public -eq 1 ]]; then
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Reload nginx service
|
|
|
|
sudo service nginx reload
|