Hello, I need to launch a script before the network is shut-down (for instance when suspending the system via systemctl suspend).
Inside the man pages for NetworkManager, it is indicated that: ... DISPATCHER SCRIPTS NetworkManager will execute scripts in the /etc/NetworkManager/dispatcher.d directory or subdirectories in alphabetical order in response to network events. Each script should be a regular executable file owned by root. Furthermore, it must not be writable by group or other, and not setuid. Each script receives two arguments, the first being the interface name of the device an operation just happened on, and second the action. The actions are: pre-up The interface is connected to the network but is not yet fully activated. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-up.d directory, and NetworkManager will wait for script execution to complete before indicating to applications that the interface is fully activated. up The interface has been activated. pre-down The interface will be deactivated but has not yet been disconnected from the network. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher. d/pre-down.d directory, and NetworkManager will wait for script execution to complete before disconnecting the interface from its network. Note that this event is not emitted for forced disconnections, like when carrier is lost or a wireless signal fades. It is only emitted when there is an opportunity to cleanly handle a network disconnection event. down The interface has been deactivated. ... First of all: on my distro there are no directories such as /etc/NetworkManager/dispatcher.d/pre-up.d and /etc/NetworkManager/dispatcher.d/pre-down.d. There are also some other issues. As a reproducible test, let's consider the following script (to be chmod 755 and put inside /etc/NetworkManager/dispatcher. d): --- > cat netStatusScript #! /bin/sh echo "$(date) netStatusScript: [$0]:[$1]:[$2]" >> /tmp/netStatusScript.log --- If I issue (as root): --- > systemctl stop network.service > systemctl start network.service --- I get the following: --- > tail /tmp/netStatusScript.log Tue Jan 5 15:54:30 CET 2016 netStatusScript: [/etc/NetworkManager/dispatcher.d/netStatusScript]:[eth0]:[up] --- This signifies that only during "up" the script is executed: all other events (down, pre-down, and pre-up) do not trigger the custom script. If I put the system to sleep (systemctl suspend) and then resume, both [down] and [up] events are triggered (but also in this case, no "pre-" events). Moreover, if I manually create the /etc/NetworkManager/dispatcher.d/pre-down.d directory and put the script into it, as indicated in the man page, no action is triggered on stop/start of the network. I need to launch a script before the network is shut-down (for instance when suspending the system via systemctl suspend). I think that the pre-down may be the state to consider: how can I do that? Thanks in advance for your suggestions. _______________________________________________ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list