I'd like to run a script on shut down, which interrupts the logout process and and pops up a window with zenity
. My target is to get autofsck working with lightdm. It seems to work with 12.04 after installing the old *.deb file, if one runs the check script manually. In order to use it, it should run automatically on log out and ask the user if she/he wants to check the disc on shutdown.
There is the option session-cleanup-script
in the file /etc/lightdm/lightdm.conf
which seems to work, if a bash file with full path is used (I can't place the command directly there). But if I press shutdown, there is no time for a user choice.
Is there any other option to solve this problem?
Edit: It seems as if there are also other problems specificially with AutoFsck. The session clean up script runs, but the check command for AutoFsck does not run.
I believe your shutdown/powerdown question is (more-or-less) answered here:
When looking at the answer(s) provided there, I would like to tweak/elaborate/summarize you probably need both, to use the session-cleanup-script such that X will not die before you can respond and run the job, and a new, smallish
/etc/init.d/
script at a high enough run level to 'block' shut down until your session-cleanup-script invoked AutoFsck script completes.Thus:
Add to session-cleanup-script setting a flag via '
touch /etc/noreboot
' (or similar) that is cleared by your AutoFsck calling script (i.e. remove /etc/noreboot file when answered no, or, if yes, removed only after AutoFsck is completed).Your new
/etc/init.d
script must check for existence of /etc/noreboot and if it exists, check again every second or two in a while loop until the file is removed. Once/etc/noreboot
is not existed, the script can complete and allow the rest of the shutdown process to continue. Again, the key here is to make sure the init.d script runs before the lightdm shutdown or any other X shutdown runs.Since X should still be running while the
/etc/noreboot
check script in init.d is running, you can also send an X message to the screen saying that shutdown is blocked awaiting removal of the file. This little nuisance message might come in handy if the/etc/noreboot
file is not cleared for some reason, preventing your system from a graceful shutdown.