#!/usr/bin/perl

# Copyright (C) 2001-2002 NEC Corporation
# All Rights Reserved.

require "/opt/nec/wbmc/lib/wbmc.pl";

#accesslog.confؤΥѥ
$access_path ="/etc/opt/nec/wbmc/accesslog.conf";
$access_path_lock ="accesslog.conf";

#access.log.1ؤΥѥ
$logfile = "/var/log/roma/access_log.1";

#¸
$log_generation = "";

#žեaccess_log.1¸ߤʤнλ
if(-e $logfile){

	#       accesslog.ocnfեɹ
	if (!&readFile("$access_path", $access_path_lock, *file) ) {
print <<`EOF`;
	        echo $access_path cannot open
EOF
	        exit(1);
	}

	for ($i = 0; $i < @file; $i++) {

	        # ȤʤɤФ
	        if ($file[$i] =~ /\s*#/) {
	                next;
	      	 }
	        # 
	        if ($file[$i] =~ /^\s*LOG_GENERATION\s*=\s*(.*)\s*$/) {
	                $log_generation = $1;
			next;
	        }
	        # ե̾
	        if ($file[$i] =~ /^\s*LOG_METHOD\s*=\s*(.*)\s*$/) {
	                $log_method = $1;
			next;
	        }
	}

if($log_generation eq ""){
	$log_generation = "1";
}

if($log_method eq "date"){
	$log_generation = `date +%y%m%d%H%M`;
	chomp $log_generation;
}

print <<`END`;

/bin/mv /var/log/roma/access_log.1 /var/log/roma/access$log_generation.log

END

#
#ΥץȤư
#

##wbmc_accesslog_start
##wbmc_accesslog_end


#
#webalizerΥư
#

##wbmc_webalizer_start
##wbmc_webalizer_end


#եõ
print <<`EOF`;
/bin/rm -f /var/log/roma/access?*.log
EOF

}
else{

	exit;

}
