Advertisement
Guest User

RaspberryPi HomePass - Random Cycle

a guest
Aug 16th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #Calculate the number of MACs in the list
  4. MAXLINE=$(/bin/sed -n '$=' /home/pi/maclist.txt)
  5.  
  6. #Generate a random line number to read the MAC from
  7. LINE=$(/usr/bin/shuf -i 1-${MAXLINE} -n 1)
  8.  
  9. #Get the MAC from the specified line number
  10. MAC=$(/bin/sed -n ${LINE}p /home/pi/maclist.txt)
  11.  
  12. #Stop the AP and DHCP services
  13. /usr/bin/sudo /usr/sbin/service hostapd stop
  14. /usr/bin/sudo /usr/sbin/service isc-dhcp-server stop
  15.  
  16. #Take the wireless interface down and change the MAC to our new one
  17. /usr/bin/sudo /sbin/ifconfig wlan0 down
  18. /usr/bin/sudo /sbin/ifconfig wlan0 hw ether $MAC
  19. /usr/bin/sudo /sbin/ifconfig wlan0 up
  20.  
  21. #Give the WiFi drivers a few seconds to start up before starting the AP, otherwise the DHCP service might not start
  22. /bin/sleep 10
  23. /usr/bin/sudo /usr/sbin/service hostapd start
  24.  
  25. #Wait a few seconds for the AP service to start up, otherwise the DHCP service might not bind correctly
  26. /bin/sleep 5
  27. /usr/bin/sudo /usr/sbin/service isc-dhcp-server start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement