I want to add "prerotate" event to logrotate. Since ISPC handles log rotation in custom way - is there any .sh script which I could modify to achieve my goal? I want to count unique IPs before each logrotate event.
Why do you want to count them before rotation? Rotation is done exactly at midnight and you can access yesterday's log for 24 hours under a fixed name (see log folder, there is always a symlink for yesterday's log pointing to the right log file), so if you want to count IP addresses for a day, it makes more sense to write a script that runs e.g. at 1am that goes trough all logs and counts IP addresses.
Correct, if there is no yesterday log file, then apache has not logged anything yesterday. E.g. GoAccess, webalizer and awstats all calculate stats on yesterday's log as well.