From 16baeffe6571fe5d3ccdbb4ff094e45918ee50f5 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 20 Feb 2021 19:51:44 +0100 Subject: [PATCH 1/2] Imagemagick Policy --- .gitignore | 3 ++- scripts/install | 7 +++++++ scripts/remove | 5 +++++ scripts/restore | 7 +++++++ scripts/upgrade | 6 ++++++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e8d0a97..8a5784c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ -*.sw[op] \ No newline at end of file +*.sw[op] +/check_process diff --git a/scripts/install b/scripts/install index 0cd23a0..133e47a 100755 --- a/scripts/install +++ b/scripts/install @@ -191,6 +191,13 @@ eval sqlite3 $final_path/app.db "$conf" conf="\"UPDATE user SET $(. <(echo -E echo $(<../conf/init_calibre_db_user))) WHERE ID=1\"" eval sqlite3 $final_path/app.db "$conf" +#Update Imagick policy as per https://github.com/janeczku/calibre-web/wiki/FAQ#what-to-do-if-cover-pictures-are-not-extracted-from-pdf-files +ynh_replace_string --match_string="" \ + --replace_string="" \ + --target_file="/etc/ImageMagick-6/policy.xml" + + + #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE #================================================= diff --git a/scripts/remove b/scripts/remove index d3c1e5a..388fde0 100755 --- a/scripts/remove +++ b/scripts/remove @@ -87,6 +87,11 @@ then yunohost firewall disallow TCP $port 2>&1 fi +#Restore Imagick policy +ynh_replace_string --match_string="" \ + --replace_string="" \ + --target_file="/etc/ImageMagick-6/policy.xml" + # Remove the log files ynh_script_progression --message="Removing log file..." --weight=1 ynh_secure_remove "/var/log/$app/" diff --git a/scripts/restore b/scripts/restore index d88612c..1940d75 100755 --- a/scripts/restore +++ b/scripts/restore @@ -146,6 +146,13 @@ else chown $app:$app $calibre_dir/* fi fi + +#Update Imagick policy as per https://github.com/janeczku/calibre-web/wiki/FAQ#what-to-do-if-cover-pictures-are-not-extracted-from-pdf-files +ynh_replace_string --match_string="" \ + --replace_string="" \ + --target_file="/etc/ImageMagick-6/policy.xml" + + # Remove the option backup_core_only if it's in the settings.yml file ynh_app_setting_delete $app backup_core_only diff --git a/scripts/upgrade b/scripts/upgrade index 3989ca1..de73656 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -191,9 +191,15 @@ ynh_systemd_action --service_name=$app --action="stop" conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))), $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" eval sqlite3 $final_path/app.db "$conf" +#Update Imagick policy as per https://github.com/janeczku/calibre-web/wiki/FAQ#what-to-do-if-cover-pictures-are-not-extracted-from-pdf-files +ynh_replace_string --match_string="" \ + --replace_string="" \ + --target_file="/etc/ImageMagick-6/policy.xml" + # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/app.db" + #================================================= # SETUP LOGROTATE #================================================= From 864a5143805880217e98d49f9406c96c2ba4a35c Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 20 Feb 2021 21:01:30 +0100 Subject: [PATCH 2/2] check imagemagick before removing --- scripts/remove | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/remove b/scripts/remove index 388fde0..e03a266 100755 --- a/scripts/remove +++ b/scripts/remove @@ -88,9 +88,11 @@ then fi #Restore Imagick policy -ynh_replace_string --match_string="" \ - --replace_string="" \ - --target_file="/etc/ImageMagick-6/policy.xml" +if [ -z /etc/ImageMagick-6/policy.xml ]; then + ynh_replace_string --match_string="" \ + --replace_string="" \ + --target_file="/etc/ImageMagick-6/policy.xml" +fi # Remove the log files ynh_script_progression --message="Removing log file..." --weight=1