You are not logged in.

#1 2014-09-13 14:05:38

cris9288
Member
Registered: 2013-01-07
Posts: 348

run services on device plug-in

I have an external USB drive which contains media used by plex and samba. I would like to configure the mount unit such that when I plug in the device, plexmediaserver, smbd, and nmbd services are automatically started. I have already configured those services to depend on the mount unit using the RequiresMountsFor directive and everything works as expected if I call

 # systemctl stop my-mount-unit.mount 

or if I boot up with the device disconnected, but I would also like for those services to be automatically started once the device is plugged in and mounted. I can see the drive is mounted correctly after I plug it in by viewing the mount command's output, so there is only this piece left to get the functionality I desire. If you're curious, the reason I wants this is because I use my laptop as a "desktop" in my basement since its battery has run out of capacity. Lately I've been using it upstairs and don't really feel like bringing the usb drive along. I realize I could probably write a udev rule but wanted to see if I could just configure the service or mount files to behave this way. I've already read the systemd.{mount,service,unit} files and have googled various terms, but haven't come across anything useful. Thanks!

Last edited by cris9288 (2014-09-13 14:06:48)

Offline

Board footer

Powered by FluxBB