#!/usr/bin/perl

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

# RCS: $Id: confinit,v 1.1.1.1 2009/06/24 10:16:38 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 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);

