# /etc/conf.d/net + postup()

## Strowi

hi,

i am trying to setup wireless for the university on my laptop. They use an unencrypted wifi with a vpn tunnel.

I am trying to run vpnc automatically when the init script runs ( i remember i had it working once, but not how).

So here is my net-config. I have to use wpa_supplicant because at home we have wpa-psk.

/etc/conf.d/net                               

```

modules=( "dhclient" )

config_eth0=( "dhcp" )

mode_ath0="11g"

#WIFI

#

modules_ath0=( "wpa_supplicant" "!netplug" )

wpa_supplicant_ath0="-Dmadwifi"

sleep_scan_ath0="1"

preferred_aps=( "Asgard" "bonnet" )

associate_order="preferredonly"

# Asgard

#

config_Asgard=( "dhcp" )

# Bonnet

#

config_bonnet=( "dhcp" )

postup() {

        if  [[ ${IFACE} == "ath0" ]]; then

                if [[ ${SSID} == "bonnet" ]]; then

                        echo $SSID;

                        ebegin "Starting VPNC";

                        if [[ -a /var/run/vpnc/pid ]] ; then

                                /usr/sbin/vpnc-disconnect && sleep 1 && /usr/sbin/vpnc;

                        else

                                /usr/sbin/vpnc;

                        fi;

                fi;

                ntpdate -s -b -u time.uni-bonn.de;

        fi

}

predown() {

        if [[ ${SSID} == "bonnet" ]]; then

                                /usr/sbin/vpnc-disconnect;

                fi;

        fi;

}

        ebegin "Stopping VPNC";

                if [[ -a /var/run/vpnc/pid ]] ; then

```

But /etc/init.d/net.ath0 restart just runs wpa_supplicant and then backgrounds... vpnc is never started (neither the "echo"-command ist run. Is this a problem with giving control to wpa_supplicant? Should i run the commands fom local or is there another "right" way?

Thx!

strowi

----------

## beatryder

Well first off, you are using an environment variable that is never set. 

You have also made a small syntax error in your code. An honest mistake I have myself.

In Bash,unlike C/C++. Java, PHP or pretty much any other language,  '=' is used for comparison rather than '=='

SSID does not exist AFAIK, however you can try this instead:

```

[code]

postup() {

        if  [[ ${IFACE} = "ath0" ]]; then

                SSID=`iwconfig ${IFACE} | grep ESSID | gawk -F\" '{ print $2}'`

                if [[ ${SSID} = "bonnet" ]]; then

                        ebegin "Starting VPNC";

                        if [[ -a /var/run/vpnc/pid ]] ; then

                                /usr/sbin/vpnc-disconnect && sleep 1 && /usr/sbin/vpnc;

                        else

                                /usr/sbin/vpnc;

                        fi;

                fi;

                ntpdate -s -b -u time.uni-bonn.de;

        fi

}

[/code]

I haven't tested this in an way but it should work for you.

If you want to test it you can very easily:

[code]

# source /etc/conf.d/net

# IFACE=ath0 postup

[/code]

I hope this helps you.
```

----------

## Strowi

hi,

thx for the reply! I really didn't see that "=" typo (and i should've, because i do a lot in java + php).

About the ssid-variable.... it said in net.example "you can use $ESSID", but that didn't work for me, so i tested it with a little "echo "ssid=$SSID essid=$ESSID"" in the postup, and ESSID was empty, and ssid returned the ssid.... weird, i guess i will have to look into it again, when i am back at my laptop.

Thx again!

----------

## beatryder

Lemme know how it works out!

----------

## Strowi

hi,

ok, now i am back at the university. I tested the ssid/essid again, and those were both empty variables. I could have sworn that i saw $ESSID in net.example.....

So i am back to using iwconfig|grep|awk and it works fine... :Wink: 

Thx for the help and a happy new year!

----------

