#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS source /usr/share/yunohost/helpers # Exit if an error occurs during the execution of the script ynh_abort_if_errors # Import common cmd source ./experimental_helper.sh source ./_common.sh # 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) db_user=$app 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") ynh_script_progression --message="Checking backware compatibility..." --weight=10 # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name=$(ynh_sanitize_dbid "$app") ynh_app_setting_set --app $app --key db_name --value "$db_name" fi # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/opt/yunohost/$app ynh_app_setting_set --app $app --key final_path --value "$final_path" fi # If path_url doesn't exist, create it if [ -z "$path_url" ]; then path_url=$(ynh_app_setting_get --app $app --key path) ynh_app_setting_set --app $app --key path --value "$path_url" ynh_app_setting_delete "$app" path fi # Detect old installation style if [ -e /etc/init.d/ffsync ]; then service ffsync stop update-rc.d -f ffsync remove ynh_secure_remove --file=/etc/init.d/ffsync ynh_secure_remove --file=/var/log/ffsync.log ynh_secure_remove --file=/opt/yunohost/ffsync yunohost service remove "$app" fi # Backup the current version of the ap ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=10 ynh_backup_before_upgrade ynh_clean_setup () { # restore it if the upgrade fails ynh_restore_upgradebackup } #================================================= # STANDARD UPGRADE STEPS #================================================= # Check depends installation ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $dependances # Download, check integrity, uncompress and patch the source from app.src ynh_script_progression --message="Upgrading source files..." --weight=6 install_sources # NGINX CONFIGURATION ynh_script_progression --message="Configuring nginx..." ynh_add_nginx_config if [ "$path_url" == "/" ] then # $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" fi ynh_store_file_checksum --file "$finalnginxconf" systemctl reload nginx # Create a system user ynh_system_user_create "$app" # SETUP UWSGI ynh_script_progression --message="Configuring application..." # 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 #================================================= # SECURE FILES AND DIRECTORIES ynh_script_progression --message="Protecting directory..." set_permissions # SETUP SSOWAT ynh_app_setting_set --app $app --key skipped_uris --value "/" ynh_script_progression --message="Upgrade of $app completed" --last