From 84bc002ada26576ca5886d07a76d7ec16d27ddf4 Mon Sep 17 00:00:00 2001 From: B Stack Date: Sat, 14 Oct 2017 17:31:56 -0400 Subject: add bash autocompletion for updatezone --- etc/bash_completion.d/updatezone | 13 +++++++++++++ usr/share/ddtools/dhcpd-control.sh | 5 ++++- usr/share/doc/ddtools/README.txt | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 etc/bash_completion.d/updatezone diff --git a/etc/bash_completion.d/updatezone b/etc/bash_completion.d/updatezone new file mode 100644 index 0000000..f55d1ce --- /dev/null +++ b/etc/bash_completion.d/updatezone @@ -0,0 +1,13 @@ +_updatezone_autocomplete() { + #devtty=/dev/pts/2 + local cur prev words cword; + _init_completion || return + local _tmpfile1="$( mktemp )" + grep -iE "UZ_ZONE_NAME=" /etc/ddtools/*.conf 2>/dev/null | sed -r -e 's/^UZ_.*=//;' >> "${_tmpfile1}" + #echo "----- ${cur} --- prev: ${prev} -- words: ${words} -- cword: ${cword} --" > "${devtty}" + grep -viE "${cur}" "${_tmpfile1}" + COMPREPLY=($( compgen -W "$( grep -viE "${prev}" "${_tmpfile1}" )" -- "$cur" )) + command rm -f "${_tmpfile1}" 1>/dev/null 2>&1 + return 0 +} +complete -F _updatezone_autocomplete updatezone diff --git a/usr/share/ddtools/dhcpd-control.sh b/usr/share/ddtools/dhcpd-control.sh index e10aaa9..843e79a 100755 --- a/usr/share/ddtools/dhcpd-control.sh +++ b/usr/share/ddtools/dhcpd-control.sh @@ -418,7 +418,10 @@ trap "clean_dhcpdcontrol" 0 #sed -n -r -e '/\{/,/^\}/{p}' /var/lib/dhcpd/dhcpd.leases | grep -iE "\{|\}|client-fqdn|hostname|hardware|starts|ends" | sed -e ':a;/\}/!{N;s/\n/ /;ba};' -e 's/\s\+/ /g;' -e 's/hardware ethernet/mac/;' | awk '!x[$13]++' | sort -k2 sed -n -r -e '/\{/,/^\}/{p}' "${DHCPD_CONTROL_LEASES_FILE}" | grep -iE "\{|\}|client-fqdn|hostname|hardware|starts|ends" | sed -e ':a;/\}/!{N;s/\n/ /;ba};' -e 's/\s\+/ /g;' -e 's/hardware ethernet/mac/;' | grep -viE "failover peer" | awk '!x[$13]++' | sort -k2 ;; - + *) + ferror "Gotta say unh! Action ${action} ${fallopts} not yet implemented. Aborted." + exit 1 + ;; esac # Prepare instructions for other server diff --git a/usr/share/doc/ddtools/README.txt b/usr/share/doc/ddtools/README.txt index 2dcb55c..ae6ac85 100644 --- a/usr/share/doc/ddtools/README.txt +++ b/usr/share/doc/ddtools/README.txt @@ -49,3 +49,4 @@ $ updatezone ipa.smith122.com ad.smith122.com 2017-10-14 B Stack 0.0-3 - Rearranged directory structure to match current standards +- Added bash autocompletion definition for updatezone -- cgit