@meleu said in ensuring ES gracefully finish ... annother approach:
@caver01 it wouldn't work for any shutdown. And I'm afraid it wouldn't work in any case. And you guessed the reason: "those files created by ES too short-lived".
edit: as you can see in emulation.sh script, those files are removed right before calling reboot|poweroff, then killes.sh won't be able to see them.
Correct - the files are not living to long to check via testcommand fileexistance!
Therefore the incron job triggers existance of files and gives feedback to script!
This works in any cases!
I did long testing with this and all files ... even if they were created and removed like
touch /tmp/testfile.dat && rm /tmp/testfile.dat
The script was always triggered. So YES this solution is working as else. But I was in need to use two more files... that give "feedback" what was triggered now?
Is it a shutdown via software? >> action_software-file is created and checked
Is it a shutdown via hardware? >> action_hardware-file is created and checked
So how does a software shutdown + GPIO triggering works?
Quit Menu -- ES Shutdown
ES creates file /tmp/es-shutdown
incron triggers script and realizes "action_software"
/tmp/es-shutdown is removed by ES shutdown script .... incron trigger is still active
incronscript triggers GPIO and set transistor to high
Now... the button shutdown script from Mausberry, bash, python... as you like is triggered (as a button press is recognizes)
This button shutdown script calls again the incron script /home/pi/incrontrol.sh button-shutdown
in the
incrontrol.sh is a check for file ... "action_software" for usecase button-shutdown > Exit
in background the ES shutdown is still performed
GPIO is triggered, mausberry is off, regular shutdown performed
@meleu said in ensuring ES gracefully finish ... annother approach:
@caver01 the simplest solution I can think is to use a systemd trick again. Let's discuss on your thread to not mess this one.
As I said in OP ... the systemd trick is a general solution and seems easier to maintain.
But there are always many roads that leads to rome: Let us collect experience