Advertisement
gpz1100

Untitled

Mar 29th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. cat /conf/start_8021x.sh
  2.  
  3. ------------------------
  4. #!/usr/bin/env sh
  5.  
  6. INTERFACE="eth4"
  7.  
  8. logger -s "WPA (${INTERFACE}): Beginning WPA authorization process."
  9.  
  10. WPA_DAEMON_CMD="/usr/sbin/wpa_supplicant -D wired -i ${INTERFACE} -c /conf/wpa_supplicant.conf -B"
  11.  
  12. # Kill any existing wpa_supplicant process.
  13. PID=$(pgrep -f "wpa_supplicant.*${INTERFACE}")
  14. if [ ${PID} > 0 ];
  15. then
  16. logger -s "WPA (${INTERFACE}): Terminating existing supplicant on PID ${PID}."
  17. RES=$(kill ${PID})
  18. sleep 1
  19. fi
  20.  
  21. # Start wpa_supplicant daemon.
  22. RES=$(${WPA_DAEMON_CMD})
  23. PID=$(pgrep -f "wpa_supplicant.*${INTERFACE}")
  24. logger -s "WPA (${INTERFACE}): Supplicant running on PID ${PID}."
  25.  
  26. # Wait until wpa_cli has authenticated.
  27. WPA_STATUS_CMD="/usr/sbin/wpa_cli status | grep 'suppPortStatus' | cut -d= -f2"
  28. IP_STATUS_CMD="ifconfig ${INTERFACE} | grep 'inet\ ' | cut -d':' -f2 | cut -d' ' -f1"
  29.  
  30.  
  31. logger -s "WPA (${INTERFACE}): Waiting for authorization."
  32.  
  33. while true;
  34. do
  35. WPA_STATUS=$(eval ${WPA_STATUS_CMD})
  36. if [ X${WPA_STATUS} = X"Authorized" ];
  37. then
  38. logger -s "WPA (${INTERFACE}): Authorization completed."
  39. sleep 3
  40. IP_STATUS=$(eval ${IP_STATUS_CMD})
  41.  
  42. if [ -z ${IP_STATUS} ] || [ ${IP_STATUS} = "0.0.0.0" ];
  43. then
  44. logger -s "WPA (${INTERFACE}): No IP address assigned, force restarting DHCP."
  45. 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})
  46. IP_STATUS=$(eval ${IP_STATUS_CMD})
  47. fi
  48. logger -s "WPA (${INTERFACE}): IP address is ${IP_STATUS}."
  49. break
  50. else
  51. sleep 1
  52. fi
  53. done
  54.  
  55. logger -s "WPA (${INTERFACE}): Process complete, exiting."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement