Advertisement
Guest User

OpenVPN list

a guest
Dec 26th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. #!/bin/bash
  2. (
  3. HOSTNAME=$3
  4. HWADDR=$2
  5. IPADDR=""
  6.  
  7. #Get the IP using ARP
  8. count=0
  9. while [[ "$IPADDR" == "" ]] && [[ $count < 5 ]]; do
  10.     IPADDR=$(arp -n | grep -i "$HWADDR" | awk -F " " '{print $1}')
  11.     sleep 5
  12.     count=num=$(( $count + 1 ))
  13. done
  14.  
  15. #Check if IP is already there
  16. HOSTSTATUS=$(grep "^$HOSTNAME," /etc/openvpn/ipp/server-us.txt | wc -l)
  17.  
  18. #IP not in ipp file yet, lets do a refresh....
  19. if [[ $HOSTSTATUS == "0" ]] && [[ $HOSTNAME != "" ]]; then
  20.     #Put hostname/ip address in ipp file manually
  21.     echo "$HOSTNAME,$IPADDR" >> /etc/openvpn/ipp/server-us.txt
  22.  
  23.     #Generate a hosts file for DNSMasq from the ipp files
  24.     awk -F "," '{print $2, $1".srv.startledphoenix.net"}' /etc/openvpn/ipp/server-*.txt > /etc/hosts.openvpn-clients
  25.  
  26.     #Force DNSMasq to refresh the hosts
  27.     service dnsmasq restart
  28. fi
  29. ) &
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement