From 4f590e2934f8981a38040ef1ef8aecfed04d05dd Mon Sep 17 00:00:00 2001 From: robocopAlpha Date: Fri, 16 Jul 2021 04:05:41 +0300 Subject: [PATCH] Writing essential stats to a log file --- .gitignore | 1 + block_FB.sh | 2 -- pull.lists.sh | 14 +++++++++++--- readme.md | 10 ++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 71636a0..09d8667 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ Mirrors lastpull +pull.log diff --git a/block_FB.sh b/block_FB.sh index 2bbaa17..a910f29 100755 --- a/block_FB.sh +++ b/block_FB.sh @@ -8,6 +8,4 @@ rg -FIN "whatsapp" "${WRK_DIR}/Mirrors/facebook_block.txt" | rg -FIN "facebook" rm -f "${WRK_DIR}/Mirrors/facebook_block.txt" sort -u "${WRK_DIR}/Mirrors/tmp.txt" | uniq > "${WRK_DIR}/facebook_block.txt" rm -f "${WRK_DIR}/Mirrors/tmp.txt" -Line_Count=$(wc -l "${WRK_DIR}/facebook_block.txt") -echo -e "${Line_Count} domains" diff --git a/pull.lists.sh b/pull.lists.sh index 7c3aba3..b9d515f 100755 --- a/pull.lists.sh +++ b/pull.lists.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash [[ -f set_env.sh ]] && source set_env.sh || { echo "set_env.sh not found"; exit 1; } +LOGFILE="${WRK_DIR}/pull.log" +if [ ! -f "$LOGFILE" ] ; then + touch "$LOGFILE" +fi + # Mounting storage if df | grep -c dropbox > /dev/null; then umount "${HOME_DIR}/dropbox" || sudo umount "${HOME_DIR}/dropbox" @@ -16,7 +21,9 @@ rclone mount --daemon dropbox:blocklist "${HOME_DIR}/dropbox" --volname dropbox cd "${WRK_DIR}/" -echo $(date +%d.%m.%y-%H:%M:%S) >| lastpull +echo $(date +%d.%m.%y-%H:%M:%S) >| lastpull +${catCMD} lastpull >> "${LOGFILE}" + # Fetch blocklists bash "${WRK_DIR}/get_blocklists.sh" @@ -36,7 +43,8 @@ wc -l MyBlocklist.txt echo -e "\nAdding these to my own Blacklist: \n" ${catCMD} blocked | rg -vIN "^[\\#]" | sd '\s+$' '' | sort -u | uniq >> MyBlocklist.txt -echo -e " $(wc -l MyBlocklist.txt) unique domains. \n" +echo -e " $(wc -l MyBlocklist.txt) unique domains. \n" | tee -a "$LOGFILE" +echo -e " $(wc -l facebook_block.txt) unique domains. \n" | tee -a "$LOGFILE" #------- # Clean-up @@ -62,7 +70,7 @@ chmod 777 ./* # Moving to target echo "Moving blocklists to destination..." cd "${WRK_DIR}/" -rsync -a --progress blocklists/* "${HOME_DIR}/dropbox/" +rsync -a --progress blocklists/* "${HOME_DIR}/dropbox/" | tee -a "$LOGFILE" echo "Final clean up..." umount "${HOME_DIR}/dropbox" || sudo umount "${HOME_DIR}/dropbox" diff --git a/readme.md b/readme.md index 0f2656f..8bea167 100755 --- a/readme.md +++ b/readme.md @@ -59,6 +59,16 @@ echo '5 18 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" updatepi' >| exit ``` +#### Adding List generation as a cron job + +```sh +sudo -s +ln -s /home/dietpi/pihole_lists/pull.lists.sh /usr/local/bin/pullLists +chmod +x /usr/local/bin/pullLists +echo '30 2 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" pullLists' >| /etc/cron.d/pullLists +exit +``` + ## Whitelisting / False Positive reports