pafakedaccesslog/etc-cron.daily-anonymize-pafal
2018-11-16 10:16:09 +01:00

17 lines
486 B
Bash
Executable File

#!/bin/sh
# simple cronjob to anonymize IPv4 and IPv6 addresses
# in pafakedaccesslog logfile entries
# on a Debian GNU/Linux default Apache2 and PHP installation
# placed in /etc/cron.daily/ .
# config
readonly LOG="/var/www/html/pafal/faccess.log"
# ipv4
/bin/sed -i -E 's/^([[:digit:]]{1,3}\.)([[:digit:]]{1,3}\.)([^ ]*)(.*)/\1\20.0\4/' "${LOG}"
# ipv6
/bin/sed -i -E 's/^([[:xdigit:]]{1,4}:)([[:xdigit:]]{1,4}:)([[:xdigit:]]{1,4}:)([^ ]*)(.*)/\1\2\3:0\5/' "${LOG}"
exit 0