| 2469 | | # update apache logrotate |
| 2470 | | # |
| 2471 | | |
| 2472 | | if ($main::cfg{'AWSTATS_ACTIVE'} eq 'yes') { |
| 2473 | | if (-f "/etc/logrotate.d/apache") { |
| 2474 | | # TODO: Fix, if awstats.pl allready added |
| 2475 | | sys_command_rs("sed -i 's#sharedscripts#sharedscripts\n\tprerotate\n\t\t$main::cfg{'AWSTATS_ROOT_DIR'}/awstats_updateall.pl now -awstatsprog=$main::cfg{'AWSTATS_ENGINE_DIR'}/awstats.pl\n\tendscript#g' /etc/logrotate.d/apache"); |
| | 2469 | # update apache logrotate (check for apache, apache2) |
| | 2470 | # |
| | 2471 | |
| | 2472 | @apache_file = ("apache", "apache2"); |
| | 2473 | foreach $apache_file (@apache_file) { |
| | 2474 | if (-f "/etc/logrotate.d/apache".$apache_file) { |
| | 2475 | $file = "/etc/logrotate.d/".$apache_file; |
| | 2476 | # search for awstats_updateall.pl |
| | 2477 | $word = "awstats_updateall.pl"; |
| | 2478 | |
| | 2479 | open(F, '<' ,$file); |
| | 2480 | @lines = <F>; |
| | 2481 | close(F); |
| | 2482 | |
| | 2483 | $nummatches = grep(/$word/, @lines); |
| | 2484 | |
| | 2485 | # add code if not exists |
| | 2486 | if ($nummatches == 0) { |
| | 2487 | sys_command_rs("sed -i 's#sharedscripts#sharedscripts\n\tprerotate\n\t\t$main::cfg{'AWSTATS_ROOT_DIR'}/awstats_updateall.pl now -awstatsprog=$main::cfg{'AWSTATS_ENGINE_DIR'}/awstats.pl &> /dev/null\n\tendscript#g' /etc/logrotate.d/$apache_file"); |
| | 2488 | } |