I have an encrypted homedir (ecryptfs) and I'm wanting to run a private mysql daemon with the database files in my homedir. The daemon should be started whenever the homedir is mounted, and stopped before the homedir is unmounted. It seems I have to write an Upstart script, which doesn't seem too hard; the problem is triggering it.

Is there already any Upstart event that is sent on these occasions? Or must I insert an "initctl emit" somewhere? Where? It seems the encrypted homedir is mounted whenever I either open my GUI session or ssh to my account. Is there a common place in these two processes where I might insert code?

(I don't want to patch and compile any C code, just insert maybe a few lines somewere.)


  • I forgot to say. I'm on 10.04 (Irish Ingrid or Lucky Lamppost or something like that, I don't remember the names). – David Olivier Nov 18 '11 at 17:18

I had a similar problem a while ago. Then I found desktop-session-start and desktop-shutdown, both emitted from /etc/init/lightdm.conf


start on desktop-session-start
stop on desktop-shutdown

Good luck!


I don't use ecryptfs, but this should work:

start on mounted MOUNTPOINT=/home
stop on runlevel [016]

exec /path/to/my/script
  • What should the user do with the above? – waltinator Nov 18 '11 at 17:58
  • 1
    Thanks for your answer. But it won't do. The "mounted" event is sent only at startup of the system, when mountall is run. It's not sent when just any mount is done. Furthermore, I want to stop the daemon when the user logs out, which unmounts the ecryptfs file system; that's not the same as stopping the system (runlevel [016]). – David Olivier Nov 18 '11 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.