#!/usr/bin/perl -I/usr/sausalito/perl
# $Id: 10reset_password,v 1.1 2001/03/01 20:38:10 pbose Exp $
#
# Copyright (C) 2000 Cobalt Networks, Inc.
# All rights reserved
#
# This script is called when the user selects Reset password
# from the lcd panel or console.

use POSIX;
use LCD;
use Term::ReadLine;
use Getopt::Std;
use CCE;
use I18n;

use vars qw/ $opt_c $opt_s /;

getopts("sc");
$option = ($opt_s) ? "-s" : "";

my $i18n = new I18n;

$str = $i18n->get("[[base-lcd.reset_password_question]]");
$yesnostr = $i18n->get("[[base-lcd.yes_no]]");

if ($opt_c) {
  printf("\n$str\n\n");
  $term = new Term::ReadLine 'select';
  $choice = $term->readline("[Y]ES/[N]O > ");

  exit 1 if ($choice !~ /^y/i);

} else {
  $result = system("/sbin/lcd-yesno $option -1 \"$str\" -2 \"$yesnostr\"");
  exit 1 unless ($result == 256);
}

system("/etc/lcd.d/reset_password");

