nvrm_mod.sh 789 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. /sbin/mount -uw /
  3. rm -f temp.nvm
  4. rm -f tempnvrm.txt
  5. fname=$2
  6. loc="/AppleInternal/Diags/WiFiFirmware/"$1"/"
  7. filename=$(echo $fname | cut -d'.' -f1)
  8. exts=$(echo $fname | cut -d'.' -f2)
  9. newfname=$filename"-orig."$exts
  10. if [ -f "$loc$newfname" ]; then
  11. echo "Backup nvram file exists!"
  12. else
  13. cp $loc$fname $loc$newfname
  14. fi
  15. cat $loc$fname | tr -c "[:print:]^\n" "\n" > temp.nvm
  16. if [ `cat temp.nvm | grep "btc_mode=4" | wc -l` -eq 0 ]; then
  17. len=$(cat temp.nvm | wc -l)
  18. i=1
  19. while [ `head -$i temp.nvm | tail -1 | grep "boardflags2" | wc -l` -eq 0 ]; do i=$(($i+1)); done
  20. head -$(($i-1)) temp.nvm > tempnvrm.txt
  21. echo "boardflags2=0x800000" >> tempnvrm.txt
  22. echo "btc_mode=4" >> tempnvrm.txt
  23. tail -n +$(($i+1)) temp.nvm >> tempnvrm.txt
  24. mv tempnvrm.txt $loc$fname
  25. fi