add getlogs script

This commit is contained in:
Ben Harris 2017-10-31 22:50:43 -04:00
parent 6d4708949c
commit 863b968050
2 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@ images/*
!images/smiley_default_freebox.png
stats/
video/
.goaccess.last

17
getlogs.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
LOG="/var/log/apache2/heyderebub.com_access.log"
LASTREAD=/var/www/heyderebub.com/public_html/.goaccess.last
OFFSET=$(sed -n '$=' $LOG)
START=1
if [[ -s $LASTREAD ]]; then
START=$(<$LASTREAD)
START="$(($START + 1))"
fi
sed -n $START','$OFFSET'p' < $LOG
echo "$OFFSET" > "$LASTREAD"