You are not logged in.

#1 2016-10-22 20:47:06

thePhysicist8
Member
Registered: 2015-06-25
Posts: 17

[Solved] Informing user services that a system target has been reached

I have a bash script running as a systemd user service that I want to use to mount an sshfs share automatically whenever the network comes online. I was originally intending to use network-online.target to accomplish this, but that is a system target which can only be used to trigger system services (services running as root).

I was wondering if there is a way that I could create a system service that activates with network-online.target and sends any instances of the user service a signal telling them to mount.

The users running this service will not have root privileges, so on-demand mounting via the fstab isn't an option. Something like afuse isn't an option either, as I don't want to bring in any extra dependencies, especially ones that aren't in the repos.

Last edited by thePhysicist8 (2016-10-25 13:08:04)

Offline

#2 2016-10-22 21:03:13

ukhippo
Member
From: Non-paged pool
Registered: 2014-02-21
Posts: 366

Re: [Solved] Informing user services that a system target has been reached

A quick and dirty way would be to have the system service create a file (e.g. /tmp/networkonline) and the user instance has a .path unit for that file which activates the user mount service.

Offline

#3 2016-10-23 15:23:10

Stebalien
Member
Registered: 2010-04-27
Posts: 1,237
Website

Re: [Solved] Informing user services that a system target has been reached

You can also write a user service that connects to the system manager over dbus.


Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#4 2016-10-25 13:06:47

thePhysicist8
Member
Registered: 2015-06-25
Posts: 17

Re: [Solved] Informing user services that a system target has been reached

I tested ukhippo's suggestion and I think it will work for me. Thank you both for the responses.

Offline

Board footer

Powered by FluxBB