You are not logged in.

#1 2008-05-20 12:34:08

lloeki
Member
From: France
Registered: 2007-02-20
Posts: 456
Website

netcfg2 + ifplugd

iphitus seems disillusioned by people not writing scripts for netcfg2.

to counter that fact, and as I've had this on my todo list for so long, here's an /etc/ifplugd/ifplugd.action:

#!/bin/sh

case "$2" in
  up)
    # case'd for excluding special cases interfaces as one may want
    case "$1" in
        *)
            # guess which profile to use
            net_profile=$(grep "INTERFACE=$1" /etc/network.d/* | sed 's#:.*##' | sed 's#/etc/network.d/##')
            netcfg2 $net_profile
        ;;
    esac
  ;;
  down)
    # bring down profile associated with the given interface
    netcfg2 -i $1
  ;;
  *)
    echo "Wrong arguments" > /dev/stderr
  ;;
esac

To know recursion, you must first know recursion.

Offline

#2 2008-05-21 14:20:00

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,221
Website

Re: netcfg2 + ifplugd

I would like to be able to help out with stuff like this, but reading this small piece of code is enough to make me stand in awe. Maybe I should look into (bash-)scripting instead of PHP...

On-topic: I had never heard of ifplugd, but it could come in very handy, especially with this netcfg2-action... THX!

Zl.

Offline

Board footer

Powered by FluxBB