#!/bin/bash

usage () {
	echo "USAGE: llx-getdhcp-options [DHCP_OPTION]" 
}

if [ "$1" = "-h" ] || [ "$1" = "--help" ]  ; then
	usage
	exit 0
fi
if [ -z "$1"  ]; then
	nmcli -c no -t  -g NAME con show --active |  while read c; do nmcli -t -f DHCP4.OPTION con show "$c" | cut -d ":" -f2; done
else
	DHCP_OPTION=$1
	VALUE=$(nmcli -c no -t  -g NAME con show --active |  while read c; do nmcli -t -f DHCP4.OPTION con show "$c" | cut -d ":" -f2 | grep -e "$DHCP_OPTION =" | grep -v requested | cut -d "=" -f2 | xargs; done)

	if [ -z "$VALUE" ]; then
	    exit 1
	fi

	echo "$VALUE"
fi





