Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat /conf/start_8021x.sh
- ------------------------
- #!/usr/bin/env sh
- INTERFACE="eth4"
- logger -s "WPA (${INTERFACE}): Beginning WPA authorization process."
- WPA_DAEMON_CMD="/usr/sbin/wpa_supplicant -D wired -i ${INTERFACE} -c /conf/wpa_supplicant.conf -B"
- # Kill any existing wpa_supplicant process.
- PID=$(pgrep -f "wpa_supplicant.*${INTERFACE}")
- if [ ${PID} > 0 ];
- then
- logger -s "WPA (${INTERFACE}): Terminating existing supplicant on PID ${PID}."
- RES=$(kill ${PID})
- sleep 1
- fi
- # Start wpa_supplicant daemon.
- RES=$(${WPA_DAEMON_CMD})
- PID=$(pgrep -f "wpa_supplicant.*${INTERFACE}")
- logger -s "WPA (${INTERFACE}): Supplicant running on PID ${PID}."
- # Wait until wpa_cli has authenticated.
- WPA_STATUS_CMD="/usr/sbin/wpa_cli status | grep 'suppPortStatus' | cut -d= -f2"
- IP_STATUS_CMD="ifconfig ${INTERFACE} | grep 'inet\ ' | cut -d':' -f2 | cut -d' ' -f1"
- logger -s "WPA (${INTERFACE}): Waiting for authorization."
- while true;
- do
- WPA_STATUS=$(eval ${WPA_STATUS_CMD})
- if [ X${WPA_STATUS} = X"Authorized" ];
- then
- logger -s "WPA (${INTERFACE}): Authorization completed."
- sleep 3
- IP_STATUS=$(eval ${IP_STATUS_CMD})
- if [ -z ${IP_STATUS} ] || [ ${IP_STATUS} = "0.0.0.0" ];
- then
- logger -s "WPA (${INTERFACE}): No IP address assigned, force restarting DHCP."
- RES=$(eval /var/sec/chroot-dhcpc/usr/sbin/dhclient -nw -cf /var/sec/chroot-dhcpc/etc/eth4.conf -lf /var/sec/chroot-dhcpc/var/db/eth4.leases -pf /var/run/dhclient_eth4.pid ${INTERFACE})
- IP_STATUS=$(eval ${IP_STATUS_CMD})
- fi
- logger -s "WPA (${INTERFACE}): IP address is ${IP_STATUS}."
- break
- else
- sleep 1
- fi
- done
- logger -s "WPA (${INTERFACE}): Process complete, exiting."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement