2015-02-13 18:10:02 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-10-30 17:52:57 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
# IMPORT GENERIC HELPERS
|
2017-10-30 17:52:57 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
# Import common cmd
|
|
|
|
source ./experimental_helper.sh
|
|
|
|
source ./_common.sh
|
2016-12-13 16:12:58 +01:00
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
# LOAD SETTINGS
|
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
|
|
|
domain=$(ynh_app_setting_get --app $app --key domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app $app --key path)
|
|
|
|
db_name=$(ynh_app_setting_get --app $app --key db_name)
|
|
|
|
db_pwd=$(ynh_app_setting_get --app $app --key mysqlpwd)
|
2017-10-30 17:52:57 +01:00
|
|
|
db_user=$app
|
2019-11-01 22:04:11 +01:00
|
|
|
final_path=$(ynh_app_setting_get --app $app --key final_path)
|
|
|
|
secret=$(ynh_app_setting_get --app $app --key secret)
|
|
|
|
path_url=$(ynh_normalize_url_path "$path_url")
|
2017-10-30 17:52:57 +01:00
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Checking backware compatibility..." --weight=10
|
2017-10-30 17:52:57 +01:00
|
|
|
|
|
|
|
# If db_name doesn't exist, create it
|
|
|
|
if [ -z "$db_name" ]; then
|
|
|
|
db_name=$(ynh_sanitize_dbid "$app")
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_app_setting_set --app $app --key db_name --value "$db_name"
|
2016-01-13 21:14:06 +01:00
|
|
|
fi
|
2015-02-13 18:10:02 +01:00
|
|
|
|
2017-10-30 17:52:57 +01:00
|
|
|
# If final_path doesn't exist, create it
|
|
|
|
if [ -z "$final_path" ]; then
|
2018-08-04 00:35:34 +02:00
|
|
|
final_path=/opt/yunohost/$app
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_app_setting_set --app $app --key final_path --value "$final_path"
|
2015-02-13 18:10:02 +01:00
|
|
|
fi
|
|
|
|
|
2018-01-29 22:44:33 +01:00
|
|
|
# If path_url doesn't exist, create it
|
|
|
|
if [ -z "$path_url" ]; then
|
2019-11-01 22:04:11 +01:00
|
|
|
path_url=$(ynh_app_setting_get --app $app --key path)
|
|
|
|
ynh_app_setting_set --app $app --key path --value "$path_url"
|
2018-01-29 22:44:33 +01:00
|
|
|
ynh_app_setting_delete "$app" path
|
|
|
|
fi
|
|
|
|
|
2017-11-16 23:23:51 +01:00
|
|
|
# Detect old installation style
|
2018-08-04 00:35:34 +02:00
|
|
|
if [ -e /etc/init.d/ffsync ]; then
|
2017-11-16 23:23:51 +01:00
|
|
|
service ffsync stop
|
|
|
|
update-rc.d -f ffsync remove
|
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_secure_remove --file=/etc/init.d/ffsync
|
|
|
|
ynh_secure_remove --file=/var/log/ffsync.log
|
|
|
|
ynh_secure_remove --file=/opt/yunohost/ffsync
|
2017-11-16 23:23:51 +01:00
|
|
|
|
2018-07-05 23:21:03 +02:00
|
|
|
yunohost service remove "$app"
|
2017-11-16 23:23:51 +01:00
|
|
|
fi
|
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
# Backup the current version of the ap
|
|
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10
|
2017-10-30 17:52:57 +01:00
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
|
|
|
# restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
|
|
|
}
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Check depends installation
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Upgrading dependencies..."
|
2019-05-08 15:02:14 +02:00
|
|
|
ynh_install_app_dependencies $dependances
|
2017-10-30 17:52:57 +01:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=6
|
|
|
|
install_sources
|
2017-10-30 17:52:57 +01:00
|
|
|
|
|
|
|
# NGINX CONFIGURATION
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Configuring nginx..."
|
2017-10-30 17:52:57 +01:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
if [ "$path_url" == "/" ]
|
2015-02-13 18:10:02 +01:00
|
|
|
then
|
2017-10-30 17:52:57 +01:00
|
|
|
# $finalnginxconf comes from ynh_add_nginx_config
|
|
|
|
# uwsgi_param is only needed for non-root installation
|
|
|
|
ynh_replace_string "uwsgi_param " "#uwsgi_param " "$finalnginxconf"
|
|
|
|
ynh_replace_string "uwsgi_modifier1 " "#uwsgi_modifier1 " "$finalnginxconf"
|
2015-02-13 18:10:02 +01:00
|
|
|
fi
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_store_file_checksum --file "$finalnginxconf"
|
2018-09-06 14:57:35 +02:00
|
|
|
systemctl reload nginx
|
2017-10-30 17:52:57 +01:00
|
|
|
|
|
|
|
# Create a system user
|
|
|
|
ynh_system_user_create "$app"
|
|
|
|
|
2018-09-05 22:23:48 +02:00
|
|
|
# SETUP UWSGI
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Configuring application..."
|
2018-09-05 22:23:48 +02:00
|
|
|
# create config file syncserver.ini
|
|
|
|
rm "$final_path/syncserver.ini"
|
|
|
|
ln -s "/etc/uwsgi/apps-available/$app.ini" "$final_path/syncserver.ini"
|
|
|
|
|
|
|
|
# configure uwsgi
|
|
|
|
ynh_add_uwsgi_service 'domain secret db_user db_pwd db_name'
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
2017-10-30 17:52:57 +01:00
|
|
|
#=================================================
|
2019-11-01 22:04:11 +01:00
|
|
|
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
ynh_script_progression --message="Protecting directory..."
|
|
|
|
set_permissions
|
|
|
|
|
2017-10-30 17:52:57 +01:00
|
|
|
# SETUP SSOWAT
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_app_setting_set --app $app --key skipped_uris --value "/"
|
2017-10-30 17:52:57 +01:00
|
|
|
|
2019-11-01 22:04:11 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|