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..e03a266 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -87,6 +87,13 @@ then
yunohost firewall disallow TCP $port 2>&1
fi
+#Restore Imagick policy
+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
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
#=================================================