2016-12-21 18:46:36 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-08-04 12:23:13 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2016-12-21 18:46:36 +01:00
|
|
|
|
2021-08-04 12:23:13 +02:00
|
|
|
source _common.sh
|
2016-12-21 18:46:36 +01:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2021-08-04 12:23:13 +02:00
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2021-08-04 13:17:27 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
2021-08-04 12:23:13 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
2024-01-05 18:46:20 +01:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]; then
|
2021-08-04 13:17:27 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2021-08-04 12:23:13 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-01-05 18:46:20 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2016-12-21 18:46:36 +01:00
|
|
|
fi
|
|
|
|
|
2024-01-05 18:46:20 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2023-01-22 12:26:54 +01:00
|
|
|
|
2021-12-09 16:07:56 +01:00
|
|
|
#=================================================
|
|
|
|
# RESTORE THE DATA DIRECTORY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Creating a calibre directory..." --weight=1
|
|
|
|
|
2024-01-05 18:46:20 +01:00
|
|
|
# build multimedia directory
|
2021-12-09 16:07:56 +01:00
|
|
|
ynh_multimedia_build_main_dir
|
2024-01-05 18:46:20 +01:00
|
|
|
ynh_multimedia_addaccess "$app"
|
2021-12-09 16:07:56 +01:00
|
|
|
|
|
|
|
calibre_dir="/home/yunohost.multimedia/share/eBook"
|
|
|
|
ynh_app_setting_set --app=$app --key=calibre_dir --value=$calibre_dir
|
|
|
|
|
2024-01-05 18:46:20 +01:00
|
|
|
# Check if metadata.db file exists. If not create it (empty library)
|
|
|
|
if [ ! -e "$calibre_dir/metadata.db" ]; then
|
|
|
|
cp -a ../conf/metadata.db.empty "$calibre_dir/metadata.db"
|
|
|
|
fi
|
|
|
|
|
2021-12-09 16:07:56 +01:00
|
|
|
chmod 750 "$calibre_dir"
|
|
|
|
chmod -R o-rwx "$calibre_dir"
|
|
|
|
chown -R $app:www-data "$calibre_dir"
|
|
|
|
|
2021-08-04 12:23:13 +02:00
|
|
|
#=================================================
|
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2021-08-04 13:17:27 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
2021-08-04 12:23:13 +02:00
|
|
|
|
2024-01-05 18:46:20 +01:00
|
|
|
timezone="$(cat /etc/timezone)"
|
|
|
|
|
|
|
|
ynh_add_config --template="../conf/config_local.php" --destination="$install_dir/config_local.php"
|
2021-08-04 12:23:13 +02:00
|
|
|
|
2024-01-05 18:46:20 +01:00
|
|
|
chmod 400 "$install_dir/config_local.php"
|
|
|
|
chown $app "$install_dir/config_local.php"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config
|
2021-08-04 12:23:13 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2024-01-05 18:46:20 +01:00
|
|
|
ynh_script_progression --message="Reloading $app's service..." --weight=1
|
2021-08-04 12:23:13 +02:00
|
|
|
|
2024-01-05 18:46:20 +01:00
|
|
|
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
|
2021-08-04 12:23:13 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-08-04 13:17:27 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|