Post command notifications

I’m testing the x86_64 QNAP qpkg, and would like to log events to the QNAP Notification Center. Before switching to the web UI, I used the attached bash script to run CLI commands, capture the command exit status and error message, if any, and log these to the Notification Center.

Can this be done with the web UI and Post Command scripts? If so, how?

duplicacy.sh.txt (1.2 KB)

I planned to add pre/post scripts to schedules but unfortunately that hasn’t been implemented yet.

For now you can place them in .duplicacy/scripts under .duplicacy-web/repositories.

Can the Post Command scripts access the duplicacy command exit status and error message, if any? If so, how?

Unfortuantely the CLI doesn’t pass the exit status and error message to post command scripts.

I’ve written a bash “wrapper” script to log notifications. .../.qpkg/Duplicacy/.duplicacy-web/bin/duplicacy_linux_x64_9.9.9 is linked to this script so that the Web UI calls it instead of the CLI. It works, except that it cannot be stopped from the Web UI. A manual kill -INT <pid> does nothing, but a manual kill -TERM <pid> causes the CLI to exit with status 1 and the notification is logged.

What do I need to do make the wrapper script stoppable from the Web UI? What signal does the Web UI send to the CLI to stop it?

Update: Or maybe this is the problem? https://stackoverflow.com/questions/49091322/cannot-trap-sigint-signal-for-bash-shell

1 Like

The problem is that bash ignores SIGINT, the signal that the Web UI sends to stop the CLI, and I’ve not found a way to enable SIGINT handling in bash.

Implementing the wrapper script in Python solves the problem. I’ll post it to github after further testing.

A wrapper script is currently easier to hook into the Web UI than pre/post scripts, and has access to the CLI command, output, and exit status.

1 Like

Here’s a QNAP qpkg with the Python wrapper script: DuplicacyLog