You are not logged in.

#1 2009-05-20 20:17:50

fgrano
Member
Registered: 2006-10-25
Posts: 29

Networkmanager dispatcher

Hello again,
long time - no arching.. heheh tongue
I went back to ubuntuland for a while, but now I'm back!

I'm having a little trouble with networkmanager though, how are the scripts in /etc/NetworkManager/dispatcher.d/ supposed to work?
I tried something like this:

#!/bin/sh
/etc/rc.d/openntpd start

and it does start the openntpd daemon, but what happens at shutdown?? It's obviously not an issue with ntp but what about other services, will they get stopped properly?
This might just be me being paranoid again, but it actually bothers me.. hmm

Offline

#2 2009-05-20 21:17:10

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,941
Website

Re: Networkmanager dispatcher

i have something like this:

#!/bin/bash

case "$2" in
        up)
                if [ /etc/rc.d/ntpdate ]; then
                   /etc/rc.d/ntpdate start
                fi
        ;;
        down)
                if [ /var/run/daemons/ntpdate ]; then
                        /etc/rc.d/ntpdate stop
                fi
        ;;
esac

Last edited by wonder (2009-05-20 21:17:25)


Give what you have. To someone, it may be better than you dare to think.

Offline

#3 2009-05-21 19:51:01

fgrano
Member
Registered: 2006-10-25
Posts: 29

Re: Networkmanager dispatcher

Works great,
Thank you! smile

Offline

#4 2009-05-26 23:21:48

jordz
Member
Registered: 2006-02-01
Posts: 248

Re: Networkmanager dispatcher

I'm trying to do something simular running netfs to mount some nfs when I'm at home.
When I run the script manually it runs fine, but my nfs doesn't get mounted at login/connect.
When do the the scripts in dispatcher.d run?

#!/bin/bash

ESSID=$(iwconfig wlan0 | awk '
 /ESSID/{if( $NF ~ /ESSID:/ ){split($NF,a,"\"");if( a[2] )ssid=a[2]}}
 END{if( ssid ){print ssid} else {print "config"}}
')

if [ "$1" = "wlan0" ]; then
    if [ "$ESSID" = "jordz-wireless" ]; then
        case "$2" in
                up)
                if [ ! -e /var/run/daemons/netfs ]; then
                    /etc/rc.d/netfs start
                fi
                ;;
                down)
                if [ -e /var/run/daemons/netfs ]; then
                    /etc/rc.d/netfs stop
                fi
                 ;;
        esac
    fi
fi

Last edited by jordz (2009-05-26 23:35:08)

Offline

#5 2009-06-05 11:21:23

jordz
Member
Registered: 2006-02-01
Posts: 248

Re: Networkmanager dispatcher

I fixed it smile I needed to give the full path of the binaries, $PATH wasn't set.

#!/bin/bash

ESSID=$(/usr/sbin/iwconfig wlan0 | /bin/awk '
 /ESSID/{if( $NF ~ /ESSID:/ ){split($NF,a,"\"");if( a[2] )ssid=a[2]}}
 END{if( ssid ){print ssid} else {print "config"}}
')

if [ "$1" = "wlan0" ]; then
    if [ "$ESSID" = "jordz-wireless" ]; then
        case "$2" in
                up)
                if [ ! -e /var/run/daemons/netfs ]; then
                    /etc/rc.d/netfs start
                fi
                ;;
                down)
                if [ -e /var/run/daemons/netfs ]; then
                    /etc/rc.d/netfs stop
                fi
                 ;;
        esac
    fi
fi

Last edited by jordz (2009-06-05 11:22:41)

Offline

Board footer

Powered by FluxBB