Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.)


share|improve this question
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!

share|improve this answer

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

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

exec /path/to/my/script
share|improve this answer
What should the user do with the above? – waltinator Nov 18 '11 at 17:58
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 posting your answer, you agree to the privacy policy and terms of service.

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