1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00
agendav_ynh/scripts/upgrade
Salamandar b18498adc4
Manifestv2 port (#71)
* Testing (#70)

* Fix upgrade

* Bump package version

* Auto-update README

* Upgrade to version 2.6.0 (#67)

* Upgrade to v2.6.0

* Auto-update README

Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>

* Upgrade auto-updater (#69)

* Auto-update README

* [autopatch] Upgrade auto-updater

* Auto-update README

---------

Co-authored-by: tituspijean <titus@pijean.ovh>

* Update _common.sh

* Update _common.sh

* Update manifest.json

* Auto-update README

---------

Co-authored-by: tituspijean <tituspijean@outlook.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: tituspijean <titus@pijean.ovh>

* Manifestv2 port

* Add a final chmod on the install_dir

* Update manifest.toml

* cleaning

---------

Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com>
Co-authored-by: tituspijean <tituspijean@outlook.com>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com>
Co-authored-by: tituspijean <titus@pijean.ovh>
2023-09-27 12:41:57 +02:00

123 lines
4.1 KiB
Bash

#!/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"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# 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"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=2
mkdir -p "/var/log/$app"
chown -R "$app:" "/var/log/$app"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate --non-append
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last