Thanks for your reply. I just tested this again and the journalctl holds no logs or outputs from this hook at all (did exactly as you told me on a fresh install). I can see audit and other messages inside the journal, but nothing from the hook bashcript. The bashscript is executed, some of the code inside the bashscript works, some of the code not.
By the way it is a gadget snap, and I didnt install it in “–devmode” . I added set +x and set -x inside the script to see what its doing.
Any idea why, do I need to enable something in advance?
oops, yeah, sorry, i kind of assumed “command doesnt work” would result in the hook failing … indeed that doesnt need to be the case …
@aschaepper makes sure to use “set -e”, that will make the hook exit nonzero if a command in it failed (though in case of gadgets that also means the gadget wont get installed … which in turn will drag a bunch of other failures behind it)
I put set -e in the pre-refresh hook, and I put in a a silly command that does not exist. “abc” which will result in a “command not found” error.
Then i listed the changes with:
$ snap changes
gave me the change number, and then I did:
$ snap tasks myschangenumber
As you warned this locked now my snap from beeing uninstalled because the hook fails.
And now I see exactly only the command which failed, which is ok.
But still I’m kind of far away what I would expect:
I would like to have a solution like in CI/CD pipelines or other Toolchains / Environments where I can just view the log.
In Jenkins for example I always get the “build” log, where I can see what it does. If I do the set +x and set -x thing I would also see which commands did actually fire (even with more detail than normal).
Becuase in my case, when doing pre-refresh stuff, you can get kind of “weird” output because this script seems to fire twice and if you would have errors in the first call but no errors in the second call and vise versa the output would look “random”.
So a log like in jenkins where you see which command did run and which did cause errors would be great…
But as from judging your responses its simply not possible to have this for the hooks.