#!/usr/bin/perl

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

# RCS: $Id: confinit,v 1.1.1.1 2004/09/09 08:14:21 snavi Exp $


# ̾
#     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ɤ߽Ф
# ( Keyword  .old Ϳƴ)
#
# INITCONF.INIѤߤξӤưڤؤ
# о
#   [WbMC]
#   [IfEth0]
#   [IfEth1]
# 󹹿Τ(̾¹)
#   [Account]
#
$firstSet = 1;
$clearFlag = 0;
if (-e "/etc/opt/nec/wbmc/INITCONF.INI") {
    $firstSet = 0;
    if ($err = &readInitFile("/etc/opt/nec/wbmc/INITCONF.INI")) {
	&errorMsg($err);
	exit(1);
    }
    if ($err = &clearConf()) {
	&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);
}

exit(0);

