LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 07-07-2013, 01:34 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,255

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
NetworkManager dispatcher scripts


In another thread I was prompted to use NM dispatcher scripts. I am unable to get them to execute.

I am seeing a message in /var/log/syslog "could not get dispatcher proxy" but have not found anything helpful on the web. My non scientific wild guess is the dispatcher is not running, which would explain why the scripts don't run.

I've read the NM man page and all scripts are owned by root:root and are executable. I've tried permissions of 755, 711, 700. None of the scripts are SUID.

I'm missing something but what?

Thanks

Slackware 14.0, NetworkManager-0.9.4.0-i486-2.

Last edited by Woodsman; 07-07-2013 at 01:40 PM.
 
Old 07-07-2013, 02:35 PM   #2
manwichmakesameal
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 800

Rep: Reputation: 99
Can you post an example of one of your scripts? Here's one of mine for comparison:
Code:
#!/bin/sh
SERVER='myserver'
NAME='-n clientname'

interface=$1 status=$2
if [ "$CONNECTION_UUID" = "mynetworkuuid" ]; then
  case $status in
    up)
      su -c 'squeezelite $NAME $SERVER -z' user
      ;;
    down)
      killall squeezelite
      ;;
  esac
fi
Here is the output of ls -l on my script:
Code:
-rwxr-xr-x 1 root root
Just checked my syslog, I have those same proxy errors. No problems here.

Last edited by manwichmakesameal; 07-07-2013 at 02:36 PM.
 
Old 07-07-2013, 02:46 PM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,255

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
I found this script online:

Code:
#!/bin/sh

# Override /etc/resolv.conf and tell
# NetworkManagerDispatcher to go pluck itself.

# Scripts in the /etc/NetworkManager/dispatcher.d/ directory
# are called alphabetically and are passed two parameters:
# $1 is the interface name, and $2 is "up" or "down" as the
# case may be.

# Here, no matter what interface or state, override the
# created resolver config with my config.

echo "Restoring resolv.conf modified by NetworkManager."
cp -a /etc/resolv.conf.bak /etc/resolv.conf
 
Old 07-07-2013, 02:51 PM   #4
manwichmakesameal
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 800

Rep: Reputation: 99
If you look at my script, you'll be able to make out how these scripts have to be formed. It calls the interface and the status as arg1 and arg2, respectively, to the script. You would have to have at least that in your script. You cat get your network uuid with
Code:
nmcli con
Basically, you can check against your network uuid, then run your conditionals. I'm no expert in this, so this is horribly incomplete.
 
Old 07-07-2013, 06:22 PM   #5
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,255

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
I'm still not doing something correctly. I added the following to the beginning of my script:

IFACE=$1
STATUS=$2

echo "IFACE: $IFACE"
echo "STATUS: $STATUS"

No output.

Then I added an if/else statement to wipe /etc/resolv.conf with /dev/null when STATUS != up. Nothing.

I even tried a test for $1: if [ "$1" = "" ]; then.... Nothing.
 
Old 07-07-2013, 06:39 PM   #6
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,255

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
I get the feeling from reading the dispatcher.d scripts execute only on a state change (up or down) of an interface. The scripts do not execute when NM first initializes, which is what I'm trying to do. Is that true?
 
Old 07-07-2013, 06:41 PM   #7
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 836

Rep: Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620
Might this work?

Code:
chattr +i /etc/resolv.conf
 
Old 07-07-2013, 07:04 PM   #8
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,255

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Yes, that sledge hammer works. Already tried that.

Yet I also want to rerun my firewall script whenever the active interface changes. I want to delay the boot process until NM get its act going because I run some network related scripts in rc.local (NM needs several seconds to initialize fully and my system finishes booting before NM finishes cleaning the lint out if its navel. Yet Another RedHat Marvel.).

Otherwise NM is working for me and recognizes when I pull the cable. Unfortunately pulling the cable changes the active interface and I need to rerun my firewall script. Currently I have to do that manually. I'm no iptables expert and perhaps a script can be written to cover both interfaces on-the-fly. Right now I just want to solve the great mystery of getting dispatcher.d scripts to run. I am missing something obvious to everybody but me.
 
Old 07-07-2013, 07:20 PM   #9
manwichmakesameal
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 800

Rep: Reputation: 99
Quote:
Originally Posted by Woodsman View Post
I get the feeling from reading the dispatcher.d scripts execute only on a state change (up or down) of an interface. The scripts do not execute when NM first initializes, which is what I'm trying to do. Is that true?
That is exactly true. If you disable wireless, it will run the case in the script for wlan0 down. Bring it back up and the case for wlan0 up runs. You can test it by giving the interface and the status as arguments to the script before putting it in dispatcher.d. If I'm gathering correctly, you want to change your resolv.conf and run your firewall when you connect to a certain network? That can be done by doing something like this:

Code:
#!/bin/sh

interface=$1 status=$2
if [ "$CONNECTION_UUID" = "yournetworkuuid" ]; then
  case $status in
    up)
      echo "208.67.222.222" > (or if you want to add, ">>") /etc/resolv.conf
      /etc/rc.d/rc.firewall_yourinterface start
      ;;
    down)
      /etc/rc.d/rc.firewall_yourinterface stop
      ;;
  esac
fi
Then you have to name it similar to udev rules, i.e. /etc/NetworkManager/dispatcher.d/10_yourfirewallscript.sh.

Hope this helps.
 
Old 07-07-2013, 07:46 PM   #10
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,255

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Thanks. Are you saying that during the initial boot I need to run my scripts from some place other than dispatcher.d, such as at the beginning of rc.local? Further, to correctly configure my iptables firewall on-the-fly to add only that one script to dispatcher.d?
 
Old 07-07-2013, 07:50 PM   #11
manwichmakesameal
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 800

Rep: Reputation: 99
You can have an /etc/rc.d/rc.firewall for default rules, then NM can run a script for a certain interface and add rules when it connects if you want to do it that way. Mine just flushes the rules and starts with a new ruleset. You don't have to manually call anything from anywhere or use rc.local. Dispatcher will run anything in dispatcher.d in the order that you name them, i.e. 10_, 20_, etc... So if you have different interfaces, like eth0 and wlan0, just make the script depend on the status of that particular interface.

Last edited by manwichmakesameal; 07-07-2013 at 07:52 PM.
 
Old 07-07-2013, 08:25 PM   #12
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,255

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
I copied your script and that is the only script in dispatcher.d. In my case I wrote 'rc.firewall start' for both up and down because I have a comprehensive script that covers multiple uses. When I boot with the cable connected, I run the firewall script after NM is launched, and the firewall script correctly configures for eth0.

After booting, when I pull the cable and wait 10 to 15 seconds, I can't access the network until I manually run the firewall script, which correctly reconfigures for wlan0. That tells me the script in dispatcher.d is not running.

Further evidence is every script I have tried in dispatcher.d that has an echo statement has failed to display the echo statement. Even a simple if [ "$2" = "up" ] || [ "$2" = "down" ] fails to produce the echo statement.

All I can guess is I have something configured incorrectly that prevents the dispatcher from running.
 
Old 07-07-2013, 08:29 PM   #13
manwichmakesameal
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 800

Rep: Reputation: 99
Can you post the exact script you have in dispatcher.d along with the name of it? My script above is just some psuedocode/example. You'll have to edit it quite a bit.
 
Old 07-07-2013, 08:46 PM   #14
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,255

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
Let's keep this simple. The following script is root:root and 755;

Code:
#! /bin/sh

if [ "$2" = "up" ] || [ "$2" = "down" ]; then
  echo "NM test is SAT."
fi
Even if NM does not send echo statements to stdout, I would think they would still go to /var/log/syslog or /var/log/messages.
 
Old 07-07-2013, 08:55 PM   #15
manwichmakesameal
Member
 
Registered: Aug 2006
Distribution: Slackware
Posts: 800

Rep: Reputation: 99
Try doing this:
Code:
#!/bin/sh

CONNECTION_UUID="yournetworkuuid"

interface=$1 status=$2
if [ "$CONNECTION_UUID" = "younetworkuuid" ]; then
  case $status in
    up)
      echo $interface" is up." > /tmp/int-status
      ;;
    down)
      echo $interface" is down." > /tmp/int-status
      ;;
  esac
fi
Replace the "yournetworkuuid" with your actual uuid, a la
Code:
nmcli con
You absolutely have to have your uuid in the script as that is how it know to run the script. You can have it match the uuid, or !uuid. You have to have the script syntax like the above. Your posted one will not run since it doesn't check the network uuid.

edit: You can test this by naming it something like 10_testscript.sh and running ./10_testscript.sh eth0 down

Last edited by manwichmakesameal; 07-07-2013 at 09:49 PM. Reason: Horrible advice. And updated script to actually work....So, the same thing
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NetworkManager and Custom scripts Pratt Slackware 2 12-23-2012 05:35 PM
Libre Network Dispatcher elalexluna83 Linux - Server 1 11-29-2012 05:45 PM
Getting Dispatcher Initialization ERR 11 Davskel1 Linux - Newbie 1 10-17-2012 12:38 AM
Dispatcher initialisation error 05 Ninett Linux - Newbie 1 07-12-2012 04:38 PM
dispatcher initialisation error 01 ... access denied maheshwar49 Linux - Newbie 1 05-24-2012 08:13 PM


All times are GMT -5. The time now is 03:39 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration