X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=scripts%2Fget_dhcp_lease.sh;fp=scripts%2Fget_dhcp_lease.sh;h=d2f04c3d14f86df8e20f3d5b6bbbbecf7110db88;hb=f7aa8c4db7a57d5865d3b7767d5957fda6867198;hp=0000000000000000000000000000000000000000;hpb=de6d6e77ff7bb93136a01ca8d3b90be9bc4be013;p=osm%2Fopenvim.git diff --git a/scripts/get_dhcp_lease.sh b/scripts/get_dhcp_lease.sh new file mode 100755 index 0000000..d2f04c3 --- /dev/null +++ b/scripts/get_dhcp_lease.sh @@ -0,0 +1,10 @@ +#!/bin/bash +awk ' +($1=="lease" && $3=="{"){ lease=$2; active="no"; found="no" } +($1=="binding" && $2=="state" && $3=="active;"){ active="yes" } +($1=="hardware" && $2=="ethernet" && $3==tolower("'$1';")){ found="yes" } +($1=="client-hostname"){ name=$2 } +($1=="}"){ if (active=="yes" && found=="yes"){ target_lease=lease; target_name=name}} +END{printf("%s", target_lease)} #print target_name +' /var/lib/dhcp/dhcpd.leases +