You are not logged in.

#1 2014-08-01 21:49:14

reannual
Member
From: Denmark
Registered: 2013-04-11
Posts: 21
Website

NetworkManager 0.9.10: New dispatcher 'pre-down' - cant get it working

I've been anticipating the release of NetworkManager 0.9.10 as it was going to support the pre'down action in dispatcher. In other words: You could write scripts that would be triggered as Network Manager is about to close down a connection. The version left testing about a weeek ago and the man page confirms the promise of the pre-down action. So far it's been no joy, though. The following simple test script is located in /etc/NetworkManager/dispatcher.d/pre-down.d/ and only writable by root.

#! /bin/sh

echo "Going (pre)down..." >> /root/pre-down-test.txt

The test file is never created, though. Has anybody made this work? Or can spot my error?

Offline

#2 2014-08-01 22:20:13

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: NetworkManager 0.9.10: New dispatcher 'pre-down' - cant get it working

what if you write it to /tmp/predown? maybe it's a permission problem?


This silver ladybug at line 28...

Offline

#3 2014-08-02 11:42:20

reannual
Member
From: Denmark
Registered: 2013-04-11
Posts: 21
Website

Re: NetworkManager 0.9.10: New dispatcher 'pre-down' - cant get it working

I put the file in root as I only thought of actions when turning on and shutting down the computer (the latter case making /tmp a bad choice). But I can just as well just turn wifi on and off. However I have no more luck with /tmp. dispatcher is up and running and working as proven by the ordinary up/down test script  I have in /etc/NetworkManager/dispatcher.d which writes date, device and action to a file in /tmp:

 Sat Aug  2 13:32:00 CEST 2014
 enp0s29u1u8u3
 up
 58d89b68-328b-4a7f-9809-cd4362feb5c0
----
 Sat Aug  2 13:33:02 CEST 2014
 enp0s29u1u8u3
 down
 58d89b68-328b-4a7f-9809-cd4362feb5c0
----
 Sat Aug  2 13:33:34 CEST 2014
 enp0s29u1u8u3
 up
 58d89b68-328b-4a7f-9809-cd4362feb5c0
----

Systemctl status reports as follows on dispatcher:

aug 02 13:32:00 CIRCUSCIRCUS systemd[1]: Starting Network Manager Script Dispatcher Service...
aug 02 13:32:00 CIRCUSCIRCUS systemd[1]: Started Network Manager Script Dispatcher Service.
aug 02 13:32:00 CIRCUSCIRCUS nm-dispatcher[658]: Dispatching action 'up' for enp0s29u1u8u3
aug 02 13:33:02 CIRCUSCIRCUS systemd[1]: Starting Network Manager Script Dispatcher Service...
aug 02 13:33:02 CIRCUSCIRCUS systemd[1]: Started Network Manager Script Dispatcher Service.
aug 02 13:33:02 CIRCUSCIRCUS nm-dispatcher[783]: Dispatching action 'down' for enp0s29u1u8u3
aug 02 13:33:34 CIRCUSCIRCUS systemd[1]: Starting Network Manager Script Dispatcher Service...
aug 02 13:33:34 CIRCUSCIRCUS systemd[1]: Started Network Manager Script Dispatcher Service.
aug 02 13:33:34 CIRCUSCIRCUS nm-dispatcher[828]: Dispatching action 'up' for enp0s29u1u8u3

As can be seen: The up/down notices are being dispatched perfectly but no mention of pre-down/pre-up?
And just to prove that the package is updated:

Name           : networkmanager
Version        : 0.9.10.0-2
Description    : Network Management daemon
Architecture   : x86_64
URL            : http://www.gnome.org/projects/NetworkManager/
....
Packager       : Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Build Date     : søn 27 jul 2014 20:55:38 CEST
Install Date   : tir 29 jul 2014 18:20:32 CEST

EDIT: I have noticed that the dispatcher.service goes dead when there are no changes and then is supposedly revived for about ten seconds by Network Manager as needed. But I suppose that is as it should be?

Last edited by reannual (2014-08-02 11:47:24)

Offline

#4 2014-08-08 07:41:12

fungle
Member
Registered: 2014-05-01
Posts: 81

Re: NetworkManager 0.9.10: New dispatcher 'pre-down' - cant get it working

It seems to me that NetworkManager's dispatcher doesn't allow pre-up/pre-down to write out. The scripts work, but echoing things don't seem to work. Here's what I did:
Pick a benign service to start, I chose haveged.service which fills entropy for /dev/random/.

Script in pre-up.d/

#!/bin/bash
systemctl start haveged.service

Script in pre-down.d/p

#!/bin/bash
systemctl stop haveged.service

Make them executable

Testing

+$:> systemctl status haveged.service 
● haveged.service - Entropy Harvesting Daemon
   Loaded: loaded (/usr/lib/systemd/system/haveged.service; disabled)
   Active: failed (Result: exit-code) since Fri 2014-08-08 00:31:50 PDT; 20s ago
     Docs: man:haveged(8)
  Process: 12672 ExecStart=/usr/bin/haveged -w 1024 -v 1 (code=exited, status=0/SUCCESS)
 Main PID: 12673 (code=exited, status=143)
+$:> nmcli con up id MOTOROLA-8A643 
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
+$:> systemctl status haveged.service 
● haveged.service - Entropy Harvesting Daemon
   Loaded: loaded (/usr/lib/systemd/system/haveged.service; disabled)
   Active: active (running) since Fri 2014-08-08 00:33:21 PDT; 9s ago
     Docs: man:haveged(8)
  Process: 13010 ExecStart=/usr/bin/haveged -w 1024 -v 1 (code=exited, status=0/SUCCESS)
 Main PID: 13011 (haveged)
   CGroup: /system.slice/haveged.service
           └─13011 /usr/bin/haveged -w 1024 -v 1
+$:> nmcli con down id MOTOROLA-8A643 
+[evfung|/etc/NetworkManager/dispatcher.d/pre-down.d]$:> systemctl status haveged.service 
● haveged.service - Entropy Harvesting Daemon
   Loaded: loaded (/usr/lib/systemd/system/haveged.service; disabled)
   Active: failed (Result: exit-code) since Fri 2014-08-08 00:34:12 PDT; 7s ago
     Docs: man:haveged(8)
  Process: 13010 ExecStart=/usr/bin/haveged -w 1024 -v 1 (code=exited, status=0/SUCCESS)
 Main PID: 13011 (code=exited, status=143)

So if dispatcher is suppose to be allowed to echo stuff, maybe its a bug?

Offline

Board footer

Powered by FluxBB