start.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/sh
  2. DIR="$( cd "$( dirname "$0" )" && pwd )"
  3. WPAS=$DIR/../../wpa_supplicant/wpa_supplicant
  4. WPACLI=$DIR/../../wpa_supplicant/wpa_cli
  5. HAPD=$DIR/../../hostapd/hostapd
  6. WLANTEST=$DIR/../../wlantest/wlantest
  7. HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
  8. if [ -z "$LOGDIR" ] ; then
  9. DATE="$(date +%s)"
  10. LOGDIR="$DIR/logs/$DATE"
  11. mkdir -p $LOGDIR
  12. rm -rf $DIR/logs/current
  13. ln -sf $DATE $DIR/logs/current
  14. fi
  15. if groups | tr ' ' "\n" | grep -q ^admin$; then
  16. GROUP=admin
  17. else
  18. GROUP=adm
  19. fi
  20. sed "s/ GROUP=.*$/ GROUP=$GROUP/" "$DIR/sta-dummy.conf" > "$LOGDIR/sta-dummy.conf"
  21. for i in 0 1 2; do
  22. sed "s/ GROUP=.*$/ GROUP=$GROUP/" "$DIR/p2p$i.conf" > "$LOGDIR/p2p$i.conf"
  23. done
  24. if [ "$1" = "concurrent" ]; then
  25. CONCURRENT=y
  26. CONCURRENT_ARGS="-N -Dnl80211 -ista%d -c $LOGDIR/sta-dummy.conf"
  27. shift
  28. else
  29. unset CONCURRENT
  30. CONCURRENT_ARGS=
  31. fi
  32. if [ "$1" = "valgrind" ]; then
  33. VALGRIND=y
  34. VALGRIND_WPAS="valgrind --log-file=$LOGDIR/valgrind-wlan%d"
  35. VALGRIND_HAPD="valgrind --log-file=$LOGDIR/valgrind-hostapd"
  36. chmod -f a+rx $WPAS
  37. chmod -f a+rx $HAPD
  38. shift
  39. else
  40. unset VALGRIND
  41. VALGRIND_WPAS=
  42. VALGRIND_HAPD=
  43. fi
  44. if [ "$1" = "trace" ]; then
  45. TRACE="T"
  46. shift
  47. else
  48. TRACE=""
  49. fi
  50. $DIR/stop.sh
  51. test -f /proc/modules && sudo modprobe mac80211_hwsim radios=5
  52. if [ "$CONCURRENT" = "y" ]; then
  53. sudo iw wlan0 interface add sta0 type station
  54. sudo iw wlan1 interface add sta1 type station
  55. sudo iw wlan2 interface add sta2 type station
  56. fi
  57. sudo ifconfig hwsim0 up
  58. sudo $WLANTEST -i hwsim0 -n $LOGDIR/hwsim0.pcapng -c -dt -L $LOGDIR/hwsim0 &
  59. for i in 0 1 2; do
  60. sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $LOGDIR/p2p$i.conf \
  61. $(printf -- "$CONCURRENT_ARGS" $i) -ddKt$TRACE -f $LOGDIR/log$i &
  62. done
  63. sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -ddKt -f $LOGDIR/hostapd &
  64. sleep 1
  65. sudo chown -f $USER $LOGDIR/hwsim0.pcapng $LOGDIR/hwsim0 $LOGDIR/log* $LOGDIR/hostapd
  66. if [ "x$VALGRIND" = "xy" ]; then
  67. sudo chown -f $USER $LOGDIR/*valgrind*
  68. fi
  69. if [ -x $HLR_AUC_GW ]; then
  70. $HLR_AUC_GW -m $DIR/auth_serv/hlr_auc_gw.milenage_db > $LOGDIR/hlr_auc_gw &
  71. fi
  72. $HAPD -ddKt $DIR/auth_serv/as.conf > $LOGDIR/auth_serv &
  73. # wait for programs to be fully initialized
  74. for i in 0 1 2; do
  75. for j in `seq 1 10`; do
  76. if $WPACLI -g /tmp/wpas-wlan$i ping | grep -q PONG; then
  77. break
  78. fi
  79. if [ $j = "10" ]; then
  80. echo "Could not connect to /tmp/wpas-wlan$i"
  81. exit 1
  82. fi
  83. sleep 1
  84. done
  85. done
  86. for j in `seq 1 10`; do
  87. if $WPACLI -g /var/run/hostapd-global ping | grep -q PONG; then
  88. break
  89. fi
  90. if [ $j = "10" ]; then
  91. echo "Could not connect to /var/run/hostapd-global"
  92. exit 1
  93. fi
  94. sleep 1
  95. done
  96. exit 0