Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- (
- HOSTNAME=$3
- HWADDR=$2
- IPADDR=""
- #Get the IP using ARP
- count=0
- while [[ "$IPADDR" == "" ]] && [[ $count < 5 ]]; do
- IPADDR=$(arp -n | grep -i "$HWADDR" | awk -F " " '{print $1}')
- sleep 5
- count=num=$(( $count + 1 ))
- done
- #Check if IP is already there
- HOSTSTATUS=$(grep "^$HOSTNAME," /etc/openvpn/ipp/server-us.txt | wc -l)
- #IP not in ipp file yet, lets do a refresh....
- if [[ $HOSTSTATUS == "0" ]] && [[ $HOSTNAME != "" ]]; then
- #Put hostname/ip address in ipp file manually
- echo "$HOSTNAME,$IPADDR" >> /etc/openvpn/ipp/server-us.txt
- #Generate a hosts file for DNSMasq from the ipp files
- awk -F "," '{print $2, $1".srv.startledphoenix.net"}' /etc/openvpn/ipp/server-*.txt > /etc/hosts.openvpn-clients
- #Force DNSMasq to refresh the hosts
- service dnsmasq restart
- fi
- ) &
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement