Writing essential stats to a log file

This commit is contained in:
robocopAlpha 2021-07-16 04:05:41 +03:00
parent 893cdc4523
commit 4f590e2934
4 changed files with 22 additions and 5 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
Mirrors Mirrors
lastpull lastpull
pull.log

View file

@ -8,6 +8,4 @@ rg -FIN "whatsapp" "${WRK_DIR}/Mirrors/facebook_block.txt" | rg -FIN "facebook"
rm -f "${WRK_DIR}/Mirrors/facebook_block.txt" rm -f "${WRK_DIR}/Mirrors/facebook_block.txt"
sort -u "${WRK_DIR}/Mirrors/tmp.txt" | uniq > "${WRK_DIR}/facebook_block.txt" sort -u "${WRK_DIR}/Mirrors/tmp.txt" | uniq > "${WRK_DIR}/facebook_block.txt"
rm -f "${WRK_DIR}/Mirrors/tmp.txt" rm -f "${WRK_DIR}/Mirrors/tmp.txt"
Line_Count=$(wc -l "${WRK_DIR}/facebook_block.txt")
echo -e "${Line_Count} domains"

View file

@ -1,6 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
[[ -f set_env.sh ]] && source set_env.sh || { echo "set_env.sh not found"; exit 1; } [[ -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 # Mounting storage
if df | grep -c dropbox > /dev/null; then if df | grep -c dropbox > /dev/null; then
umount "${HOME_DIR}/dropbox" || sudo umount "${HOME_DIR}/dropbox" 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}/" 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 # Fetch blocklists
bash "${WRK_DIR}/get_blocklists.sh" bash "${WRK_DIR}/get_blocklists.sh"
@ -36,7 +43,8 @@ wc -l MyBlocklist.txt
echo -e "\nAdding these to my own Blacklist: \n" echo -e "\nAdding these to my own Blacklist: \n"
${catCMD} blocked | rg -vIN "^[\\#]" | sd '\s+$' '' | sort -u | uniq >> MyBlocklist.txt ${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 # Clean-up
@ -62,7 +70,7 @@ chmod 777 ./*
# Moving to target # Moving to target
echo "Moving blocklists to destination..." echo "Moving blocklists to destination..."
cd "${WRK_DIR}/" cd "${WRK_DIR}/"
rsync -a --progress blocklists/* "${HOME_DIR}/dropbox/" rsync -a --progress blocklists/* "${HOME_DIR}/dropbox/" | tee -a "$LOGFILE"
echo "Final clean up..." echo "Final clean up..."
umount "${HOME_DIR}/dropbox" || sudo umount "${HOME_DIR}/dropbox" umount "${HOME_DIR}/dropbox" || sudo umount "${HOME_DIR}/dropbox"

View file

@ -59,6 +59,16 @@ echo '5 18 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" updatepi' >|
exit 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 ## Whitelisting / False Positive reports