1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/grocy_ynh.git synced 2024-09-03 19:25:54 +02:00
grocy_ynh/scripts/upgrade

150 lines
4.9 KiB
Text
Raw Normal View History

2020-12-16 19:56:57 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language)
2021-12-09 11:50:09 +01:00
phpversion=$YNH_PHP_VERSION
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
2020-12-16 19:56:57 +01:00
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
2021-11-16 10:39:20 +01:00
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
2020-12-16 19:56:57 +01:00
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi
2021-12-09 11:50:09 +01:00
# If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then
fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
# If fpm_usage doesn't exist, create it
if [ -z "$fpm_usage" ]; then
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
2021-04-11 13:30:58 +02:00
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
2021-11-19 23:02:10 +01:00
# Add /api permission if needed
if ! ynh_permission_exists --permission="api"; then
ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true"
fi
2020-12-16 19:56:57 +01:00
#=================================================
2021-11-16 10:39:20 +01:00
# CREATE DEDICATED USER
2020-12-16 19:56:57 +01:00
#=================================================
2021-11-16 10:39:20 +01:00
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
2020-12-16 19:56:57 +01:00
2021-11-16 10:39:20 +01:00
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
2020-12-16 19:56:57 +01:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=5
Upgrade (#44) * Upgrade to v.3.0.0 * Fix * Fix * Add README_fr * Fix * Update nginx.conf * Fix * Update manifest.json * Update upgrade * Update upgrade * Remove service * Update upgrade * Update config-dist.php * Remove path * Update README_fr.md * Update README_fr.md * Upgrade to 3.0.1 (#4) * Upgrade to 3.0.1 * 3.0.1 (#7) * Upgrade to 3.0.1 * Update manifest.json * add pull request * Cleaning up * Update manifest.json * Cleaning up * Fix * Fix path * Fix * Fix permissions * [autopatch] Update issue and PR templates (#11) * Testing (#9) * Cleaning up * [autopatch] Update issue and PR templates Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> Co-authored-by: Yunohost-Bot <> * Fix * [autopatch] Update issue and PR templates (#12) * Testing (#9) * Cleaning up * [autopatch] Update issue and PR templates Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> Co-authored-by: Yunohost-Bot <> * Add headers (#13) * Cleaning up * Update manifest.json * 3.1.0 (#15) * 3.1.0 * Fix * Auto-update README * Fix * Auto-update README * Set client_max_body_size to 50M * Update manifest.json * Auto-update README * Update manifest.json * 3.1.1 * Auto-update README * Fix * Update manifest.json * Upgrade 3.1.2 (#20) * Auto-update README * Add mbstring * Update manifest.json * Auto-update README * 3.1.3 (#24) * 3.1.3 * Allow api (#27) * Allow API * Update upgrade * Update scripts/upgrade Co-authored-by: tituspijean <tituspijean@outlook.com> Co-authored-by: tituspijean <tituspijean@outlook.com> * Update manifest.json * Auto-update README * remove https * Update DESCRIPTION.md * Auto-update README * Add config panel * Ericgaspar patch 1 (#30) * Testing (#28) * Allow API * Create updater.yml * Auto-update README * Update upgrade * Fix * Auto-update README * version bump * Auto-update README * 3.2.0 * Auto-update README * Update manifest.json * Update manifest.json * Upgrade to v3.2.0 (#36) Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> * Update nginx.conf * 3.3.0 * Auto-update README * Update _common.sh * Update upgrade * Update config-dist.php * Update nginx.conf * Update check_process * Update _common.sh * 3.3.1 * Auto-update README * Auto-update README * Update manifest.json * Update upgrade * Update upgrade * Update manifest.json * Auto-update README Co-authored-by: ericgaspar <junk.eg@free.fr> Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> Co-authored-by: YunoHost Bot <yunohost-bot@users.noreply.github.com> Co-authored-by: Yunohost-Bot <> Co-authored-by: tituspijean <tituspijean@outlook.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org>
2022-10-17 08:33:09 +02:00
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep="data"
2020-12-16 19:56:57 +01:00
fi
2021-05-27 13:19:07 +02:00
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
2020-12-16 19:56:57 +01:00
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
Testing (#40) * Upgrade to v.3.0.0 * Fix * Fix * Add README_fr * Fix * Update nginx.conf * Fix * Update manifest.json * Update upgrade * Update upgrade * Remove service * Update upgrade * Update config-dist.php * Remove path * Update README_fr.md * Update README_fr.md * Upgrade to 3.0.1 (#4) * Upgrade to 3.0.1 * 3.0.1 (#7) * Upgrade to 3.0.1 * Update manifest.json * add pull request * Cleaning up * Update manifest.json * Cleaning up * Fix * Fix path * Fix * Fix permissions * [autopatch] Update issue and PR templates (#11) * Testing (#9) * Cleaning up * [autopatch] Update issue and PR templates Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> Co-authored-by: Yunohost-Bot <> * Fix * [autopatch] Update issue and PR templates (#12) * Testing (#9) * Cleaning up * [autopatch] Update issue and PR templates Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> Co-authored-by: Yunohost-Bot <> * Add headers (#13) * Cleaning up * Update manifest.json * 3.1.0 (#15) * 3.1.0 * Fix * Auto-update README * Fix * Auto-update README * Set client_max_body_size to 50M * Update manifest.json * Auto-update README * Update manifest.json * 3.1.1 * Auto-update README * Fix * Update manifest.json * Upgrade 3.1.2 (#20) * Auto-update README * Add mbstring * Update manifest.json * Auto-update README * 3.1.3 (#24) * 3.1.3 * Allow api (#27) * Allow API * Update upgrade * Update scripts/upgrade Co-authored-by: tituspijean <tituspijean@outlook.com> Co-authored-by: tituspijean <tituspijean@outlook.com> * Update manifest.json * Auto-update README * remove https * Update DESCRIPTION.md * Auto-update README * Add config panel * Ericgaspar patch 1 (#30) * Testing (#28) * Allow API * Create updater.yml * Auto-update README * Update upgrade * Fix * Auto-update README * version bump * Auto-update README * 3.2.0 * Auto-update README * Update manifest.json * Update manifest.json * Upgrade to v3.2.0 (#36) Co-authored-by: yunohost-bot <yunohost-bot@users.noreply.github.com> * Update nginx.conf * 3.3.0 * Auto-update README * Update _common.sh * Update upgrade * Update config-dist.php * Update nginx.conf * Update check_process Co-authored-by: YunoHost Bot <yunohost-bot@users.noreply.github.com> Co-authored-by: Yunohost-Bot <> Co-authored-by: tituspijean <tituspijean@outlook.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: yunohost-bot <yunohost@yunohost.org>
2022-05-03 22:54:55 +02:00
# Create a dedicated NGINX config
2020-12-16 19:56:57 +01:00
ynh_add_nginx_config
#=================================================
2021-11-16 10:39:20 +01:00
# UPGRADE DEPENDENCIES
2020-12-16 19:56:57 +01:00
#=================================================
2021-11-16 10:39:20 +01:00
ynh_script_progression --message="Upgrading dependencies..." --weight=1
2020-12-16 19:56:57 +01:00
2021-11-16 10:39:20 +01:00
ynh_install_app_dependencies $pkg_dependencies
2020-12-16 19:56:57 +01:00
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated php-fpm config
2021-12-09 11:50:09 +01:00
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
2020-12-16 19:56:57 +01:00
#=================================================
# MODIFY A CONFIG FILE
#=================================================
2021-11-16 10:39:20 +01:00
#ynh_add_config --template="../conf/config-dist.php" --destination="$final_path/data/config.php"
2020-12-26 19:51:35 +01:00
2021-11-16 10:39:20 +01:00
#chmod 400 "$final_path/data/config.php"
#chown $app "$final_path/data/config.php"
2020-12-26 19:51:35 +01:00
2020-12-16 19:56:57 +01:00
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last