Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreUp/PostDown #12

Closed
dkasak opened this issue Feb 10, 2013 · 4 comments
Closed

PreUp/PostDown #12

dkasak opened this issue Feb 10, 2013 · 4 comments

Comments

@dkasak
Copy link

dkasak commented Feb 10, 2013

netcfg had PreUp and PostDown which netctl seems to be missing (in the man pages, I only found mention of ExecStartPost and ExecDownPre). Would it be possible to implement these? It seems it would be very easy to do so by adding ExecStartPre and ExecStopPost options in the corresponding systemd service file for a profile.

My concrete use case for this in netcfg was a Bluetooth tethering profile. I used the PreUp to set up a Bluetooth bnep interface through pand and the PostDown to tear the Bluetooth connection down after the profile was brought down. Can this perhaps be implemented in netctl in another way?

@joukewitteveen
Copy link
Owner

This can be done using systemd units directly. Just specify Before= in a custom systemd unit that takes care of the StartPre/StopPost actions.

@dkasak
Copy link
Author

dkasak commented Feb 11, 2013

I can see how this would solve the ExecStartPre problem, but wouldn't ExecStopPost also be executed immediately, and not AFTER netctl@<profile>.service is stopped, like it is supposed to? That would mean I'd have to have two custom unit files, one for Pre actions and one for Post actions. But since After/Before only specify ordering, wouldn't I also need a Requires somewhere too?

This seems fairly complicated for such a simple procedure. Theoretically, would there be a problem with the approach I mentioned in the first post (ExecStart{Pre,Post} in the netctl@<profile>.service)? If not, would you consider accepting a patch that adds the relevant ExecUpPre and ExecDownPost directives to netctl which are implemented in that way?

EDIT: I guess my suggestion might not work after all since the device of the interface doesn't exist at the time netctl@<profile>.service is started and it has an After directive which specifies the device of the interface. Is this correct?

@joukewitteveen
Copy link
Owner

Whatever you want to do is possible using systemd logic, read systemd.unit and systemd.service for all the details. The only parts where it is non-trivial to use systemd logic is covered by netctl's ExecUpPost and ExecDownPre. Unless you come up with some very convincing use-case, patches to add back ExecUpPre and ExecDownPost will not be merged.

I'm sorry for being so brief, but I'm a bit busy at the moment.

@lerouxju
Copy link

I think there might be a use-case when ExecUpPre and ExecDownPost are requested: when using netctl-ifplugd. In my case I need to restart my firewall (Shorewall) when netctl-ifplugd detects that a link goes down. And from what I understand it is not possible to do it with systemd as the different netctl-ifplugd@..service do not stop by themself when interfaces go down. They just exec netctl stop on the relevant interfaces.
So unless you know another way to do what I like to do could you please consider merging the patches?

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants