#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # CHECK VERSION #================================================= ynh_script_progression --message="Checking version..." --weight=1 upgrade_type=$(ynh_check_app_version_changed) #================================================= # STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 #================================================= # GET THE CALDAV APP #================================================= caldav_info=$(_ynh_agendav_find_caldav_app) caldav_app="$(cut -d " " -f 1 <<< "$caldav_info")" caldav_baseurl="$(cut -d " " -f 2 <<< "$caldav_info")" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --keep="web/config/settings.php" fi chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config mkdir -p "/var/log/$app" chown -R "$app:" "/var/log/$app" # Use logrotate to manage application logfile(s) ynh_use_logrotate --non-append #================================================= # SPECIFIC UPGRADE #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=2 # Copy and set AgenDAV configuration timezone=$(cat /etc/timezone) caldav_domain=$(ynh_app_setting_get --app="$caldav_app" --key=domain) caldav_path=$(ynh_app_setting_get --app="$caldav_app" --key=path) caldav_url="https://${caldav_domain}${caldav_path%/}" caldav_baseurl="${caldav_url}${caldav_baseurl}" ynh_add_config --template="../conf/settings.php" --destination="${install_dir}/web/config/settings.php" #================================================= # RUN DATABASE MIGRATIONS (INCLUDES INITIALIZATION) #================================================= ynh_script_progression --message="Upgrading AgenDAV..." --weight=1 ( cd "$install_dir" || ynh_die "php$phpversion" agendavcli migrations:migrate --no-interaction ) chown -R "$app:www-data" "$install_dir" # Only agendav user should write here chown -R "$app" "$install_dir/web/var/cache/"{profiler,twig} # The agendav user should read here, but does not need to write # Other users should not be able to read as it stores passwords. chown -R "$app:www-data" "$install_dir/web/config/" chmod -R 750 "$install_dir/web/config/" # FIXME: Should cleanup all the chmods. chmod 750 "$install_dir" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Upgrade of $app completed" --last