aboutsummaryrefslogtreecommitdiffstats
path: root/cron/counter.sh
blob: b75dd1256f7ceaad227035015369b440d5109ff0 (plain)
1
2
3
4
5
6
7
8
9
10
#!/bin/sh -e

logfile='/var/log/nginx/access.log'
destfile='/usr/local/www/jozan/index.html'
foretext='Unique visitors: '
botlist='petalbot|googlebot|adsbot-google|ahrefs\.com|pingbot|robots\.txt|pandalytics|serpstatbot|zoombot|semrush.com\/bot|archive\.org_bot|bingbot|vuhuvbot|neevabot|botaflatoon|botfnetowrksx|zaldamosearchbot|facebookexternalhit|mj12bot|polaris botnet|turnitinbot'

[ -e $logfile ]  || exit 1
[ -e $destfile ] || exit 1
sed -i '' "s/$foretext.*$/$foretext<b>$(grep -E -v -i "$botlist" $logfile | awk '{print $1}' | sort | uniq | wc -l | tr -d ' ')<\/b>/" $destfile