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

dbus-service interface="org.opensuse.Network.Scripts" not working #986

Open
rnissl opened this issue Oct 9, 2023 · 4 comments
Open

dbus-service interface="org.opensuse.Network.Scripts" not working #986

rnissl opened this issue Oct 9, 2023 · 4 comments

Comments

@rnissl
Copy link

rnissl commented Oct 9, 2023

Documentation and implementation (extensions/dispatch) look promising, but for any reason, no one triggers these events mentioned in server.xml.

Am I missing any component which provides and serves dbus-service interface="org.opensuse.Network.Scripts"?

@mtomaschewski
Copy link
Member

mtomaschewski commented Oct 12, 2023

See man 5 ifcfg:

       PRE_UP_SCRIPT, POST_UP_SCRIPT, PRE_DOWN_SCRIPT and POST_DOWN_SCRIPT
              Here  you can hook a script (better: an executable) or systemd service name to per-
              form individual actions before/after the interface is set up  or  before/after  the
              interface is set down by specifying the script names in a space separated list.

              Wicked supports multiple schemes for the scripts.

                  - systemd:<service.name>" scheme:
                      Permits  a  service name or template which will be completed with interface
                      name as its argument, e.g.:

                           POST_UP_SCRIPT="systemd:my-eth-post-up.service"
                           POST_UP_SCRIPT="systemd:[email protected]"

                      On pre-up and post-up actions the service is started, on pre-down and post-
                      down the service will be stopped.

                      The  service should make use of an device service unit binding BindsTo=sys-
                      subsystem-net-devices-%i.device so it gets stopped, when  the  device  sud-
                      denly disappears.  See also man systemd.unit(5).

                  - wicked:<script> scheme:
                      Permits  to specify a script or script directory either as an absolute path
                      or relative to the /etc/wicked/scripts directory, e.g.:

                           POST_UP_SCRIPT="wicked:post-up"
                           POST_UP_SCRIPT="wicked:post-up/script1"
                           POST_UP_SCRIPT="wicked:/path/to/my-script-or-dir"

                      The script is executed as "$script $action  $interface"  with  the  pre-up,
                      post-up, pre-down, post-down actions corresponding with the variable name.

                  - compat:suse:<script> scheme:
                      Permits  to specify a script or script directory either as an absolute path
                      or relative to the /etc/sysconfig/network/scripts directory, e.g.:

                           POST_UP_SCRIPT="compat:suse:post-up-script1"
                           POST_UP_SCRIPT="compat:suse:/path/to/my-script-or-dir"

                      The script is executed as "$script $interface $interface -o  $action"  with
                      the  pre-up,  post-up,  pre-down,  post-down actions corresponding with the
                      variable name.

              Note: The script scheme must be specified as a safeguard to not execute any old and
              not-compatible  sysconfig ifup scripts (which may depend on different files, inter-
              nal state, ...). Once the script has been adopted, prepend e.g. the  "compat:suse:"
              scheme to activate.

So when you add e.g. POST_UP_SCRIPT="systemd:[email protected]" to ifcfg-dummy0, a wicked show-config dummy0 shows you the xml representation (usable in xml config /etc/wicked/ifconfig/*.xml):

  <scripts>
    <post-up>
      <script>systemd:[email protected]</script>
    </post-up>
  </scripts>

As this is a systemd template service name containing an "@", the dispatcher will instantiate it / add the dummy0 interface name to it and start the [email protected] as the post-up hook, that is in the last step/state when the leases are already applied, e.g. to trigger some interface setup depending service start.

@mtomaschewski
Copy link
Member

mtomaschewski commented Oct 12, 2023

Am I missing any component which provides and serves dbus-service interface="org.opensuse.Network.Scripts"?

It's triggered by the config, see scripts service scheme definition. The

<meta:mapping document-node="/scripts/post-up"  skip-unless-present="true" />

causes that wickedd-nanny serializes the content of the <scripts><post-up> xml node as script-config dict type and pass to the dispatcher commands implementing the org.opensuse.Network.Scripts service as specified in the server.xml config.

@mtomaschewski
Copy link
Member

BTW: Easier to understand is the <dbus-service interface="org.opensuse.Network.Firewall">, see schema/firewall.xml.
The /etc/wicked/extensions/firewall up command defined in server.xml will get the <firewall> node contents (zone here).

Note: there is no config node passed to any down actions as they don't act on config (which may be replaced by a new/different different config already, e.g. while wicked ifreload), but always on state of the interface or some "non-kernel" state created somewhere (/run/wicked/extension/<name>) during some up action triggered by the config.

@boomer41
Copy link
Contributor

Thanks for your info!

We added POST_UP_SCRIPTs to the respective interface configurations and it seems to work.

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