Add wireless client for RED to startup process.
[ipfire-2.x.git] / src / initscripts / init.d / networking / wpa_supplicant.exe
1 #!/bin/bash
2 ########################################################################
3 # Begin
4 #
5 # Description : wpa_supplicant Script
6 #
7 # Authors     : IPFire Development Team <developers@ipfire.org>
8 #
9 # Version     : 01.00
10 #
11 # Notes       : This script starts/stops the dhclient if a WPA/WPA2
12 #               connection to an AP successfull has been established
13 #               or disconnected.
14 #
15 ########################################################################
16  
17 . /etc/sysconfig/rc 
18 . ${rc_functions}
19 . /etc/init.d/networking/functions.network
20
21 # Gather required information from wpa_cli.
22 device="$1"
23 wpa_state="$2"
24
25 # Check if the RED device has been configured to use DHCP or exit immediately.
26 eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
27 if [ ! "${RED_TYPE}" == "DHCP" ] ; then
28         exit 0
29 fi
30
31 case "${wpa_state}" in
32         CONNECTED)
33                 # Start dhcpcd.
34                 dhcpcd_start "${device}"
35
36                 exit 0
37                 ;;
38
39         DISCONNECTED)
40                 # Stop dhcpcd.
41                 dhcpcd_stop "${device}"
42
43                 exit 0
44                 ;;
45
46         *)
47                 # When we ever got here, there is a really big problem.
48                 exit 1
49                 ;;
50 esac