What app is this about, and its version: 2.20.8~ynh1
What YunoHost version are you running: 12.1.39
What type of hardware are you using: Virtual machine
Describe your issue
I recently upgraded paperless-ngx, and again, saw my modifications to the file /var/www/paperless-ngx/paperless.conf to circumvent a longstanding bug (OSError: image file is truncated (X bytes not processed)) overwritten ![]()
To my pleasant surprise, I discovered the hook system (docs). However, initial experiments did not turn out as expected, so I wondered:
(1) How you test a hook without rerunning the whole update? Just by setting the environment variables and executing the script?
(2) How a more experienced user might go about adding the modifications to paperless.conf, instead of using ynh_write_var_in_file.
(3) Comments on my (failing) attempt to hook into the process after the upgrade:
#!/bin/bash
source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
if [[ "$app" == "paperless-ngx" ]]; then
chmod 640 /var/www/paperless-ngx/paperless.conf
ynh_write_var_in_file --file=/var/www/paperless-ngx/paperless.conf --key=PAPERLESS_OCR_USE>
ynh_write_var_in_file --file=/var/www/paperless-ngx/paperless.conf --key=PILLOW_LOAD_TRU>
chmod 400 /var/www/paperless-ngx/paperless.conf
yunohost service reload_or_restart paperless-ngx paperless-ngx-consumer paperless-ngx-sc>
fi
Share relevant logs or error messages
/etc/yunohost/hooks.d/post_app_upgrade# ./10-paperless-ngx
+ return 1
+ ynh_write_var_in_file --file=/var/www/paperless-ngx/paperless.conf --key=PILLOW_LOAD_TRUNCATED_IMAGES --value=1 --after=PAPERLESS_OCR_USER_ARGS
+ local legacy_args=fkva
+ args_array=(['f']='file=' ['k']='key=' ['v']='value=' ['a']='after=')
+ local -A args_array
+ local file
+ local key
+ local value
+ local after
+ ynh_handle_getopts_args --file=/var/www/paperless-ngx/paperless.conf --key=PILLOW_LOAD_TRUNCATED_IMAGES --value=1 --after=PAPERLESS_OCR_USER_ARGS
++ set +o
++ grep xtrace
+ local 'xtrace_enable=set -o xtrace'
+ set +o xtrace
+ after=PAPERLESS_OCR_USER_ARGS
+ [[ -f /var/www/paperless-ngx/paperless.conf ]]
+ set +o xtrace
+ return 1
+ chmod 400 /var/www/paperless-ngx/paperless.conf
+ yunohost service reload_or_restart paperless-ngx paperless-ngx-consumer paperless-ngx-scheduler paperless-ngx-task-queue