1

I've recently started using syncthing, and I've run into a challenge:

I have my home folder encrypted on my laptop, and I want to sync folders from inside my home-folder. The folder is encrypted using ecryptfs (using the defaul Ubuntu "Do you want to encrypt your home-folder?" option), and, as far as I can tell it is mounted on log-in and unmounted on log-out.

So I cannot run syncthing as a boot-up service (f.ex. using supervisor).

It would need to start up on first login, and the last log-out process would have to send SIGINT to the process, wait for it to shut down and then finish the log-out process.

I've been thinking about using .bashrc and .bash_logout, but that seems finnicky to ensure it only runs on first and last logout. So I would opt-out of that.

Another option I had in mind was using kdm (which I use to log-in to the WM. KDE in this case). But that would mean it would only run during graphical log-ins. That's okay though as I only use non-graphical log-ins to troubleshoot the system. Yet, I don't know how I would do that with kdm :\

Maybe there's also an option to maybe write udev triggers? But I doubt those can be used to properly shut-down syncthing as it would trigger after the device gets unmounted.

Maybe ecryptfs offers an option? But I can't find anything.

What would be the proper way to solve this? And how?

0

According to the KDE documentation you can configure KDE to run a script whenever a user logs off. You can check the USER environment variable to check if the user that logged out is the user you want to process. If the logged out ueer is you, you can stop the service.

When a user logs in, you should run another script to ensure that the service is running. Do the same checks here.

KDE should run the file /etc/kde3/kdm/Xstartup when logging on and /etc/kde3/kdm/Xreset when logging off, but if that doesn't work it might be set to a different location. Check /etc/kde3/kdm/kdmrc to see if the file location changed.

More alternatives can be found here: Create a logoff script/task for Linux

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.