Cleanup and shellchecks

master
Keith Irwin 2022-09-08 21:18:03 -06:00
parent d598b65d1a
commit b88c95b4f3
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
1 changed files with 6 additions and 7 deletions

View File

@ -21,12 +21,11 @@ source "${CONFIG_FILE}"
domain="$("${LIB_DIR}/ns_lookup_rdns" "${ipv4}")" || exit 4
username="$(<<<"${domain}" cut -d'.' -f2)"
hostname="$(<<<"${domain}" cut -d'.' -f1)"
if [ "${2}" == 'json' ]; then
#TODO Remove keys with empty ("") values
printf '{"domain":"%s.%s.%s","ipv4":"%s","ipv6":"%s","pubkey":"%s}"},' \
"${hostname}" "${username}" "${TLD}" "${ipv4}" "${ipv6}" "${pubkey}"
elif [ "${2}" == 'tsv' ]; then
printf '%s.%s.%s\t%s\t%s\t%s\n' \
"${hostname}" "${username}" "${TLD}" "${ipv4}" "${ipv6}" "${pubkey}"
case "${2}" in
#TODO Remove json keys with empty ("") values
'json') printf '{"domain":"%s.%s.%s","ipv4":"%s","ipv6":"%s","pubkey":"%s}"},' \
"${hostname}" "${username}" "${TLD}" "${ipv4}" "${ipv6}" "${pubkey}";
*) printf '%s.%s.%s\t%s\t%s\t%s\n' \
"${hostname}" "${username}" "${TLD}" "${ipv4}" "${ipv6}" "${pubkey}";;
fi
done | sed 's/,$//' # Remove trailing comma from json