#!/usr/bin/perl -wT

#----------------------------------------------------------------------
# copyright (C) 1999-2003 Mitel Networks Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------
package esmith::console;

use strict;

use POSIX;
use Locale::gettext;
use Errno;
use esmith::util;
use esmith::console;
use esmith::I18N;

my $release = esmith::util::determineRelease();
my $release_string = "Mitel Networks server ${release}";

BEGIN
{
    # Set PATH explicitly and clear related environment variables so that calls
    # to external programs do not cause results to be tainted. See
    # "perlsec" manual page for details.

    $ENV {'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin';
    $ENV {'SHELL'} = '/bin/bash';
    delete $ENV {'ENV'};
    delete $ENV {'BASH_ENV'};
}

my $i18n = new esmith::I18N;
$i18n->setLocale("server-console");

# XXX-FIXME
# We call whiptail directly (rather than through the screen function)
# as we don't want the --clear parameter passed by screen().
# Appropriate magic can clean this up.

system(
       "/usr/bin/whiptail",
       "--backtitle",
       "$release_string Copyright 1999-2003 Mitel Networks Corporation",
       "--title", gettext("Activating configuration settings"),
       "--infobox", gettext("Please standby while your configuration " .
	   "settings are activated ..."),
       8, SCREEN_COLUMNS,
      );
system("/sbin/e-smith/signal-event", "bootstrap-console-save");
unlink "/var/state/e-smith/activate-config";
system("/usr/bin/tput", "clear");
exit (0);
