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)
|
|
|
|
|
2019-07-30 23:07:10 +02:00
|
|
|
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
|
|
|
### $upgrade_type can have 2 different values
|
|
|
|
### - UPGRADE_APP if the upstream app version has changed
|
|
|
|
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
|
|
|
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
|
|
|
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
2016-06-13 22:03:33 +02:00
|
|
|
# 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
|
2019-07-30 23:07:10 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2020-03-05 20:33:21 +01:00
|
|
|
ynh_secure_remove $src_path
|
2020-03-05 20:27:10 +01:00
|
|
|
mkdir -p $src_path
|
2019-07-30 23:07:10 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir=$src_path
|
2020-03-05 20:27:10 +01:00
|
|
|
chown -R www-data: $src_path
|
2019-07-30 23:07:10 +02:00
|
|
|
fi
|
|
|
|
|
2016-06-13 22:03:33 +02:00
|
|
|
|
|
|
|
# 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
|
2020-03-05 20:27:10 +01:00
|
|
|
cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2016-06-13 22:03:33 +02:00
|
|
|
|
|
|
|
# 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
|
2020-04-16 19:30:37 +02:00
|
|
|
systemctl reload nginx
|