
To be aware of:
https://www.debian.org/releases/bookwor ... free-split
If you change bullseye to bookworm in /etc/apt/sources.list , you also have to change non-free to non-free-firmware.
DG.
Code: Select all
#/bin/bash
#
# Script takes ip addresses (once) from 'access.log' from apache(2)
# DG (C) 2024
#
# Goto right path
cd ~
# Check if access.log existand copy it
if [ -f /var/log/apache2/access.log ]; then
cp /var/log/apache2/access.log Myfile.txt;
else
echo "Copy does not work!!!";
fi
# Subtract all ip addresses from copy into Myfile2.txt
while IFS='' read -r LINE || [ -n "${LINE}" ]; do cut -d' ' -f1; done < ~/Myfile.txt >> ~/Myfile2.txt
# Sort will unify the list to 'once' occurence and put output into ip-list-today.txt
sort ~/Myfile2.txt | uniq > ~/ip-list-today.txt
# remove old files
if [ -f ~/ip-list-today.txt ]; then
echo "OK";
if [ -f ~/Myfile.txt ]; then
rm ~/Myfile.txt;
fi
if [ -f ~/Myfile2.txt ]; then
rm ~/Myfile2.txt;
fi
else
echo "Something went wrong!";
fi
#
# END
Code: Select all
#/bin/bash
#
# Script takes ip addresses (once) from 'access.log' from apache(2)
# DG (C) 2024
# https://dolfgeerdink.nl/phpbb/viewtopic.php?p=474#p474
#
# Goto right path
cd ~
# Check if access.log exist and copy it
if [ -f /var/log/apache2/access.log ]; then
cp /var/log/apache2/access.log Myfile.txt;
else
echo "Copy does not work!!!";
fi
# Subtract all ip addresses from copy into Myfile2.txt
while IFS='' read -r LINE || [ -n "${LINE}" ]; do cut -d' ' -f1; done < ~/Myfile.txt >> ~/Myfile2.txt
# Sort will unify the list to 'once' occurence and put output into ip-list-today.txt
sort ~/Myfile2.txt | uniq > ~/ip-list-$(date +%d%m%y).txt
# Check new file and remove old files
if [ -f ~/ip-list-$(date +%d%m%y).txt ]; then
echo "OK";
if [ -f ~/Myfile.txt ]; then
rm ~/Myfile.txt;
fi
if [ -f ~/Myfile2.txt ]; then
rm ~/Myfile2.txt;
fi
else
echo "Something went wrong!";
fi
#
# END