Getting wpa_action to run dhclient after wpa_supplicant connects

Jouni Malinen j at w1.fi
Fri Apr 15 10:06:09 EDT 2011


On Thu, Apr 14, 2011 at 07:59:42PM -0600, Curtis Larsen wrote:
> Putting a valid statement between "then" and "fi" fixed the
> ..."/sbin/wpa_action.sh: 13: Syntax error: "fi" unexpected" error, but
> I still get two "unexpected operator" errors.  Could someone please
> actually provide a full good wpa_action.sh script that will simply run
> "dhclient wlan2" after wpa_supplicant successfully connects?

#!/bin/sh

IFNAME=$1
CMD=$2

if [ "$CMD" = "CONNECTED" ]; then
    dhclient $IFNAME
fi


If you want to extend that to kill dhclient, there is a more complete
example in wpa_supplicant/examples/p2p-action.sh for the P2P events that
has code for using dhclient pid file to kill it when the P2P group is
removed. It won't work as-is for the non-P2P case, but it should be
simple to extract the needed additions from there if desired.

-- 
Jouni Malinen                                            PGP id EFC895FA


More information about the HostAP mailing list