Advertisement
Guest User

mtk_init_country.sh

a guest
Sep 24th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.41 KB | None | 0 0
  1. #!/bin/sh
  2. return_status=true
  3.  
  4. #Defines
  5. if [ ! "$MTLK_INIT_PLATFORM" ]; then
  6.     . /tmp/mtlk_init_platform.sh
  7. fi
  8. command=$1
  9.  
  10. start_mtlk_init_country()
  11. {
  12.     print2log DBG "mtlk_init_country.sh: Start"
  13.  
  14.     wlan_count=`host_api get $$ sys wlan_count`
  15.  
  16.     NETWORK_TYPE=`host_api get $$ wlan0 network_type`
  17.     COUNTRY_CODE=`iwpriv wlan0 gEEPROM | sed -n '/EEPROM country:/{s/EEPROM country:.*\([A-Z?][A-Z?]\)/\1/p}'`
  18.    
  19.     i=0
  20.     while [ "$i" -lt "$wlan_count" ]
  21.     do
  22.         wlan=wlan$i
  23.  
  24.         if [ "$NETWORK_TYPE" = "$STA" ]
  25.         then
  26.             ACTIVE_11D=`host_api get $$ $wlan dot11dActive`
  27.             if [ "$ACTIVE_11D" = "0" ]
  28.             then
  29.                 return
  30.             fi
  31.         fi
  32.         if [ -n "$COUNTRY_CODE" ] && [ "$COUNTRY_CODE" != "??" ]
  33.         then
  34.             host_api set $$ $wlan EEPROMCountryValid $YES
  35.             host_api set $$ $wlan Country $COUNTRY_CODE
  36.         else
  37.             host_api set $$ $wlan EEPROMCountryValid $NO
  38.         fi
  39.         let i=$i+1
  40.     done
  41.     # No need to commit, since values are evaluated after each reboot.
  42.     print2log DBG "mtlk_init_country.sh: Done"
  43. }
  44.  
  45. stop_mtlk_init_country()
  46. {
  47.     return
  48. }
  49.  
  50. create_config_mtlk_init_country()
  51. {
  52.     return
  53. }
  54.  
  55. should_run_mtlk_init_country()
  56. {
  57.     if [ -e $wave_init_failure ]
  58.     then
  59.         return_status=false
  60.     fi
  61. }
  62.  
  63. case $command in
  64.     start)
  65.         start_mtlk_init_country
  66.     ;;
  67.     stop)
  68.         stop_mtlk_init_country
  69.     ;;
  70.     create_config)
  71.         create_config_mtlk_init_country
  72.     ;;
  73.     should_run)
  74.         should_run_mtlk_init_country
  75.     ;;
  76. esac
  77.  
  78. $return_status
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement