1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cesium_ynh.git synced 2024-09-03 18:06:25 +02:00
cesium_ynh/scripts/upgrade

52 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# Source YunoHost helpers
source /usr/share/yunohost/helpers
# 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)
### 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)
# Remove trailing "/" for next commands
path=${path%/}
# Retreive sources and install them
src_path=/var/www/$app
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_secure_remove $src_path
mkdir -p $src_path
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
chown -R www-data: $src_path
fi
# 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
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
service nginx reload