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