How to get a script in /etc/sysconfig/network/if-up.d executed

BTW this also applies to Tumbleweed.

I have a need to get a script executed right after the network has come up, so naturally I placed the script in /etc/sysconfig/network/ip-up.d and made it executable. But when I reboot or run ‘systemctl restart network.service’ (or ‘rcnetwork restart’) nothing happens. My script, which right now is a test script, look like this:

#!/bin/bash
#
set -x
/usr/bin/echo "+\$0: $0, \$1:$1, \$2:$2+" | /usr/bin/logger
/sbin/ip route list | /usr/bin/logger

It works when I call it directly, but otherwise there is no trace of the logger lines in any of the system log files in /var/log.

Execution of scripts in /etc/sysconfig/network/ip-up.d appears to be controlled by the value of GLOBAL_POST_UP_EXEC in /etx/sysconfig/network/config which is left at the default value ‘yes’.

What have I missed in this connection?

Bent

There was a bug report dealing with this

907215 – after 13.1 -> 13.2 upgrade, wickedd fails to exec existing if-{up,down}.d/* scripts

It’s been resolved with a fix already. Are you fully-updated?

openSUSE-RU-2015:0820-1: An update that has 8 recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 907215,907694,918662,920070,920889,921218,927065,927616
CVE References:
Sources used:
openSUSE 13.2 (src): wicked-0.6.18-15.1

I believe so. On Tumbleweed I have

$rpm -q wicked
wicked-0.6.20-1.1.i586
$

and om openSUSE 13.2 I have

$rpm -q wicked
wicked-0.6.19-18.1.x86_64
$

My apologies BentBagger. After reading the bug report again and subsequently the man page for ifcfg , I note the following with regards to adding scripts when using wicked

 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  perform  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:my-post-up@.service"

                      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  suddenly  disappears.   See  also  man  sys-
                      temd.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/script 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, internal state, ...). Once the script  has  been  adopted,
              prepend e.g. the "compat:suse:" scheme to activate.

That should be enough to get you up and running. :slight_smile:

Definitely. It works now as I intended it.

Thank you so much for your help

Bent

I’m glad to have been of assistance. :slight_smile: