mirror of
https://github.com/YunoHost-Apps/paheko_ynh.git
synced 2024-09-03 19:56:22 +02:00
90 lines
2.9 KiB
Bash
90 lines
2.9 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
# Load common variables and helpers
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
# If secret_key doesn't exist, create it
|
|
if [ -z "${secret_key:-}" ]; then
|
|
secret_key=$(ynh_string_random --length=50)
|
|
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
ynh_script_progression --message="Upgrading source files..." --weight=5
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir" --keep="config.local.php data/plugins"
|
|
fi
|
|
|
|
if [ ! -f "$data_dir/data/config.local.user.php" ]; then
|
|
ynh_add_config --template="config.local.user.php" --destination="$data_dir/data/config.local.user.php"
|
|
chmod 650 "$data_dir/data/config.local.user.php"
|
|
chown $app:$app "$data_dir/data/config.local.user.php"
|
|
echo'
|
|
/**
|
|
* Chemin vers le fichier pour des configurations personnelles
|
|
* qui ne sera pas écraser lors des mises à jour.
|
|
*/
|
|
require '$data_dir/data/config.local.user.php';' >> $install_dir/config.local.php
|
|
fi
|
|
|
|
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
|
|
|
|
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
|
chown root: "/etc/cron.d/$app"
|
|
chmod 644 "/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
|
|
if ynh_compare_current_package_version --comparison lt --version 1.3.1~ynh1
|
|
then
|
|
ynh_add_config --template="config.local.php" --destination="$install_dir/config.local.php"
|
|
chmod 650 "$install_dir/config.local.php"
|
|
chown $app:$app "$install_dir/config.local.php"
|
|
fi
|
|
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|