Initial openvim v0.4.6 upload
[osm/openvim.git] / scripts / get_dhcp_lease.sh
1 #!/bin/bash
2 awk '
3 ($1=="lease" && $3=="{"){ lease=$2; active="no"; found="no" }
4 ($1=="binding" && $2=="state" && $3=="active;"){ active="yes" }
5 ($1=="hardware" && $2=="ethernet" && $3==tolower("'$1';")){ found="yes" }
6 ($1=="client-hostname"){ name=$2 }
7 ($1=="}"){ if (active=="yes" && found=="yes"){ target_lease=lease; target_name=name}}
8 END{printf("%s", target_lease)} #print target_name
9 ' /var/lib/dhcp/dhcpd.leases
10