Also print datetime a domain was added when listing the domains on the CLI

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2019-04-26 17:07:16 +02:00
parent 08ee9526ad
commit 6b1d2523e8
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

View file

@ -175,7 +175,7 @@ RemoveDomain() {
}
Displaylist() {
local list listname count num_pipes domain enabled status
local list listname count num_pipes domain enabled status nicedate
listname="${listType}"
data="$(sqlite3 "${gravityDBfile}" "SELECT * FROM ${listType};" 2> /dev/null)"
@ -196,7 +196,9 @@ Displaylist() {
# Extract domain and enabled status based on the obtained number of pipe characters
domain="$(cut -d'|' -f"-$((num_pipes-2))" <<< "${line}")"
enabled="$(cut -d'|' -f"$((num_pipes-1))" <<< "${line}")"
dateadded="$(cut -d'|' -f"$((num_pipes))" <<< "${line}")"
echo "${dateadded}"
# Translate boolean status into human readable string
if [[ "${enabled}" -eq 1 ]]; then
status="enabled"
@ -204,7 +206,10 @@ Displaylist() {
status="disabled"
fi
echo " ${count}: ${domain} (${status})"
# Get nice representation of numerical date stored in database
nicedate=$(date --rfc-2822 -d "@${dateadded}")
echo " ${count}: ${domain} (${status}, added ${nicedate})"
count=$((count+1))
done <<< "${data}"
exit 0;