mirror of
https://github.com/YunoHost-Apps/my_webapp_ynh.git
synced 2024-09-03 19:46:26 +02:00
Cleaning
This commit is contained in:
parent
59e321b398
commit
dafc95ba31
3 changed files with 7 additions and 119 deletions
|
@ -14,7 +14,7 @@ license = "GPL-3.0-only"
|
||||||
code = "https://github.com/YunoHost-Apps/my_webapp_ynh"
|
code = "https://github.com/YunoHost-Apps/my_webapp_ynh"
|
||||||
|
|
||||||
[integration]
|
[integration]
|
||||||
yunohost = ">= 11.1.7"
|
yunohost = ">= 11.1.12"
|
||||||
architectures = "all"
|
architectures = "all"
|
||||||
multi_instance = true
|
multi_instance = true
|
||||||
ldap = "not_relevant"
|
ldap = "not_relevant"
|
||||||
|
|
|
@ -9,65 +9,12 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RETRIEVE ARGUMENTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
|
||||||
old_path=$YNH_APP_OLD_PATH
|
|
||||||
|
|
||||||
new_domain=$YNH_APP_NEW_DOMAIN
|
|
||||||
new_path=$YNH_APP_NEW_PATH
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..."
|
|
||||||
|
|
||||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=5
|
|
||||||
|
|
||||||
# Backup the current version of the app
|
|
||||||
ynh_backup_before_upgrade
|
|
||||||
ynh_clean_setup () {
|
|
||||||
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
|
|
||||||
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
|
|
||||||
# restore it if the upgrade fails
|
|
||||||
ynh_restore_upgradebackup
|
|
||||||
}
|
|
||||||
# Exit if an error occurs during the execution of the script
|
|
||||||
ynh_abort_if_errors
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Activating maintenance mode..."
|
|
||||||
|
|
||||||
path_url=$old_path
|
|
||||||
domain=$old_domain
|
|
||||||
ynh_maintenance_mode_ON
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK WHICH PARTS SHOULD BE CHANGED
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
change_domain=0
|
|
||||||
if [ "$old_domain" != "$new_domain" ]
|
|
||||||
then
|
|
||||||
change_domain=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
change_path=0
|
|
||||||
if [ "$old_path" != "$new_path" ]
|
|
||||||
then
|
|
||||||
change_path=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -75,57 +22,12 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
|
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
ynh_change_url_nginx_config
|
||||||
|
|
||||||
# Prepare nginx.conf
|
|
||||||
if [ $phpversion != "none" ]
|
|
||||||
then
|
|
||||||
cp ../conf/nginx{_with_php,}.conf
|
|
||||||
else
|
|
||||||
cp ../conf/nginx{_no_php,}.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change the path in the NGINX config file
|
|
||||||
if [ $change_path -eq 1 ]
|
|
||||||
then
|
|
||||||
# Make a backup of the original NGINX config file if modified
|
|
||||||
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
|
|
||||||
|
|
||||||
# Set global variables for NGINX helper
|
|
||||||
domain="$old_domain"
|
|
||||||
path_url="$new_path"
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change the domain for NGINX
|
|
||||||
if [ $change_domain -eq 1 ]
|
|
||||||
then
|
|
||||||
# Delete file checksum for the old conf file location
|
|
||||||
ynh_delete_file_checksum --file="$nginx_conf_path"
|
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
|
||||||
|
|
||||||
# Store file checksum for the new config file location
|
|
||||||
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALISATION
|
|
||||||
#=================================================
|
|
||||||
# RELOAD NGINX
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reloading NGINX web server..."
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEACTIVE MAINTENANCE MODE
|
# DEACTIVE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Disabling maintenance mode..."
|
|
||||||
|
|
||||||
path_url=$old_path
|
|
||||||
domain=$old_domain
|
|
||||||
ynh_maintenance_mode_OFF
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -9,20 +9,6 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# LOAD SETTINGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=2
|
|
||||||
|
|
||||||
with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
|
|
||||||
with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
|
|
||||||
|
|
||||||
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
|
|
||||||
|
|
||||||
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
|
||||||
fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
|
|
||||||
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -35,31 +21,31 @@ upgrade_type=$(ynh_check_app_version_changed)
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
||||||
|
|
||||||
# If admin_mail_html doesn't exist, create it
|
# If admin_mail_html doesn't exist, create it
|
||||||
if [ -z "$admin_mail_html" ]; then
|
if [ -z "${admin_mail_html:-}" ]; then
|
||||||
admin_mail_html=1
|
admin_mail_html=1
|
||||||
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If fpm_footprint doesn't exist, create it
|
# If fpm_footprint doesn't exist, create it
|
||||||
if [ -z "$fpm_footprint" ]; then
|
if [ -z "${fpm_footprint:-}" ]; then
|
||||||
fpm_footprint=low
|
fpm_footprint=low
|
||||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If fpm_free_footprint doesn't exist, create it
|
# If fpm_free_footprint doesn't exist, create it
|
||||||
if [ -z "$fpm_free_footprint" ]; then
|
if [ -z "${fpm_free_footprint:-}" ]; then
|
||||||
fpm_free_footprint=0
|
fpm_free_footprint=0
|
||||||
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If fpm_usage doesn't exist, create it
|
# If fpm_usage doesn't exist, create it
|
||||||
if [ -z "$fpm_usage" ]; then
|
if [ -z "${fpm_usage:-}" ]; then
|
||||||
fpm_usage=low
|
fpm_usage=low
|
||||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If with_sftp doesn't exist, create it
|
# If with_sftp doesn't exist, create it
|
||||||
if [ -z "$with_sftp" ]; then
|
if [ -z "${with_sftp:-}" ]; then
|
||||||
with_sftp=1
|
with_sftp=1
|
||||||
ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp
|
ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue