From fcc0a045ccfeaa1df27a74fcb0812ac9800d5fa6 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Wed, 28 Sep 2016 20:57:51 +0100 Subject: [PATCH] handle importing in pihole command. pihole -i --- pihole | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pihole b/pihole index 00e4a7bf..d9c5514f 100755 --- a/pihole +++ b/pihole @@ -43,10 +43,21 @@ function debugFunc { } function flushFunc { - ${SUDO} /opt/pihole/piholeLogFlush.sh + sqlite3 /etc/pihole/pihole.db "DROP TABLE IF EXISTS queries" + sqlite3 /etc/pihole/pihole.db "DROP TABLE IF EXISTS forwards" + sqlite3 /etc/pihole/pihole.db "DROP TABLE IF EXISTS replies" exit 1 } +function databaseFunc{ + echo "::: Importing /var/log/pihole/log to /etc/pihole/pihole.db" + python /opt/pihole/dnsmasq_parse.py + echo -n "::: Flushing /var/log/pihole.log..." + echo " " > /var/log/pihole.log + echo " ...done!" + exit 1 + +} function updatePiholeFunc { echo "::: Checking for updates..." @@ -177,6 +188,7 @@ case "$1" in "-b" | "blacklist" ) blacklistFunc "$@";; "-d" | "debug" ) debugFunc;; "-f" | "flush" ) flushFunc;; +"-i" | "importLogToDatabase" ) databaseFunc;; "-up" | "updatePihole" ) updatePiholeFunc;; "-g" | "updateGravity" ) updateGravityFunc "$@";; "-s" | "setupLCD" ) setupLCDFunction;;