#!/usr/bin/perl

# Copyright (C) 2000 NEC Corporation
# All Rights Reserved.

# RCS: $Id: confinit,v 1.4 2002/11/15 13:25:58 wbmc Exp $

# 2001.06.28 Tsuno
# memo:
#		WbMC󥹥ȡɬ/opt/nec/wbmc/language.pl
#		󥹥ȡ뤵Ƥʤȥץȥ顼ˤʤΤդɬפǤ

# ̾
#     confinit - ȿǥץ
#
# 
#     confinit [file]
#
# 
#     եƤɤ߹ǡƼԤ
#     ե뤬ꤵʤɸϤɤ߹ࡣ
#
# λ
#     ｪλʤ 0
#     ۾ｪλʤ 0ʳ
#

#
# 饤֥ɤ߹
#
require "/opt/nec/wbmc/bin/confinit.pl";

#
# ͤɤ߽Ф
#
if ($err = &readConfFile($ARGV[0])) {
    &errorMsg($err);
    exit(1);
}


#
# ͤå
#
if ($err = &checkConfParam()) {
    &errorMsg($err);
    exit(1);
}

#
# INITCONF.INI˽񤭹
#
if ($err = &writeConfFile("/etc/opt/nec/wbmc/INITCONF.INI")) {
    &errorMsg($err);
    exit(1);
}

#
# ᥤ롼ƤӽФ
#
if ($err = &confInit($ARGV[0])) {
    &errorMsg($err);
    exit(1);
}

# 2001.06.28 Boss System Tsuno

# ʲ/opt/nec/wbmc/language.plꤷʤޤ
# ǥեȤꤵƤ뤿ᡢɬ

$lang_file		= "/opt/nec/wbmc/language.pl";
$lang_lock		= "language";

# language.pl뤫
#if (-f $lang_file) {
#	# ¸ߤΤ̵
#		print "error0\n";
#	exit(0);
#}

# INITCONF.INIɤ߹
$filename = "/etc/opt/nec/wbmc/INITCONF.INI";
if (-f $filename) {
	if ($err = &readConfFile($filename)) {
		print "error1\n";
		exit(0);
	}
}

#@setfile = ();
if($LANGUAGE{'SETLANG'} eq 'Japanese'){
	push(@setfile,"\$mes_language = \"Japanese\";\n");
} else {
	push(@setfile,"\$mes_language = \"English\";\n");
}
push(@setfile,"\n");
push(@setfile,"1;\n");

if (!&writeFile($lang_file, $lang_lock, @setfile)) {
		print "error2\n".$LANGUAGE{'SETLANG'};
	exit(1);
}
# 2001.06.28 Boss System Tsuno

#2001.07.17 NiNes Honda
#WBMCHTTPD.CONFѹ롣
#URLǥǥ쥯ȥɽեindex.htmlǤϤʤ
#ܸʤindex_j.htmlѸʤindex_e.htmlȤ

if ($err = &ChangeWbmchttpdConf()){
    &errorMsg($err);
    exit(1);
}

## move 2002/11/13 QNES  1 line  No.40 ##
system("/etc/cron.daily/wbmc_certificate");

#2002.10.18 Nines Honda add
system("/sbin/chkconfig --level 3 wbmchttpd on");
system("/etc/rc.d/init.d/wbmchttpd start");

## move 2002/11/13 QNES  1 line  No.40 ##
#system("/etc/cron.daily/wbmc_certificate");

#ॾ

system("rm -f /etc/localtime");
system("ln -s /usr/share/zoneinfo/$TIMEZONE{'SETTZ'} /etc/localtime");
system("/sbin/hwclock --systohc");


#2001.07.17 NiNes Honda

## add 2002/11/13 QNES  2 line  No.49 ##
system("/bin/touch /etc/crontab");
system("/bin/touch /etc/cron.d");

exit(0);

