2015-05-31 13:46:25 +02:00
|
|
|
#!/bin/bash
|
2018-03-13 21:49:11 +01:00
|
|
|
|
|
|
|
#=================================================
|
2021-07-12 12:16:32 +02:00
|
|
|
# GENERIC START
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2017-02-06 23:40:55 +01:00
|
|
|
source _common.sh
|
2021-07-12 12:16:32 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2015-05-31 13:46:25 +02:00
|
|
|
|
2022-06-15 23:45:27 +02:00
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
2021-07-12 12:11:43 +02:00
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
2021-07-12 12:16:32 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
2021-07-12 12:11:43 +02:00
|
|
|
|
2022-06-16 00:33:32 +02:00
|
|
|
# If prefix doesn't exist, create it
|
2024-01-23 16:40:33 +01:00
|
|
|
if [ -z "${prefix:-}" ]; then
|
|
|
|
prefix="lime_"
|
|
|
|
ynh_app_setting_set --app=$app --key=prefix --value=$prefix
|
2022-06-16 00:33:32 +02:00
|
|
|
fi
|
|
|
|
|
2024-01-23 16:40:33 +01:00
|
|
|
# if install_dir/upload is not a symlink, moving data...
|
|
|
|
if [ ! -L "$install_dir/upload" ]; then
|
|
|
|
if [ -z "$(ls -A "$data_dir/upload")" ]; then
|
|
|
|
rmdir "$data_dir/upload"
|
|
|
|
else
|
2024-07-04 22:31:02 +02:00
|
|
|
ynh_print_warn "$data_dir/upload is not empty, moving to $data_dir/upload_backup. You can decide to remove it or merge it with the new upload dir."
|
2024-01-23 16:40:33 +01:00
|
|
|
mv "$data_dir/upload" "$data_dir/upload_backup"
|
|
|
|
fi
|
|
|
|
mv "$install_dir/upload" "$data_dir/upload"
|
2021-07-12 12:11:43 +02:00
|
|
|
fi
|
|
|
|
|
2024-01-23 23:54:37 +01:00
|
|
|
# Legacy permission setting
|
2024-01-24 08:57:59 +01:00
|
|
|
if [ -n "${is_admin_public:-}" ]; then
|
2024-01-23 23:54:37 +01:00
|
|
|
if [ "$is_admin_public" -eq 1 ]; then
|
2024-01-24 09:35:22 +01:00
|
|
|
# Small trick to clear package linter...
|
|
|
|
"ynh"_permission_update --permission="admin" --add="visitors"
|
2024-01-23 23:54:37 +01:00
|
|
|
fi
|
|
|
|
ynh_app_setting_delete --app="$app" --key=is_admin_public
|
|
|
|
fi
|
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2024-01-23 16:40:33 +01:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2018-03-13 21:49:11 +01:00
|
|
|
|
2024-01-23 16:40:33 +01:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-01-23 23:54:37 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="plugins/ application/config/config.php"
|
|
|
|
|
|
|
|
ynh_secure_remove --file="$install_dir/upload"
|
|
|
|
ln -s "$data_dir/upload" "$install_dir/upload"
|
2018-03-14 03:32:46 +01:00
|
|
|
|
2024-01-23 16:40:33 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2018-03-13 21:49:11 +01:00
|
|
|
|
2024-01-23 18:30:28 +01:00
|
|
|
# Set permissions just in case
|
2024-01-23 16:40:33 +01:00
|
|
|
chmod 750 "$data_dir"
|
|
|
|
chown -R "$app:www-data" "$data_dir"
|
2022-06-15 23:45:27 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
2022-01-14 02:52:48 +01:00
|
|
|
|
2024-01-23 16:40:33 +01:00
|
|
|
ynh_add_config --template="../conf/config.php" --destination="$install_dir/application/config/config.php"
|
2022-01-14 02:52:48 +01:00
|
|
|
|
2024-01-23 16:40:33 +01:00
|
|
|
chmod 400 "$install_dir/application/config/config.php"
|
|
|
|
chown "$app:$app" "$install_dir/application/config/config.php"
|
2022-06-15 23:45:27 +02:00
|
|
|
|
2018-03-13 21:49:11 +01:00
|
|
|
#=================================================
|
|
|
|
# UPGRADE DB
|
|
|
|
#=================================================
|
2024-01-23 16:40:33 +01:00
|
|
|
ynh_script_progression --message="Running Database migrations..."
|
2015-06-01 00:00:38 +02:00
|
|
|
|
2017-02-06 23:40:55 +01:00
|
|
|
# Migrate DB
|
2024-01-23 16:40:33 +01:00
|
|
|
ynh_exec_as "$app" "php$phpversion" "$install_dir/application/commands/console.php" updatedb
|
2021-07-12 12:11:43 +02:00
|
|
|
|
2022-06-15 23:45:27 +02:00
|
|
|
#=================================================
|
2024-01-23 16:40:33 +01:00
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
2021-07-12 12:11:43 +02:00
|
|
|
#=================================================
|
2024-01-23 16:40:33 +01:00
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config
|
2021-07-12 12:11:43 +02:00
|
|
|
|
2024-01-23 16:40:33 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2021-07-12 12:11:43 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-07-12 12:16:32 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|