case "2"
{
setthedate();
break;
}
case "3"
{
setthetime();
break;
sub setthedate()
{
print( "Current system date: " );
systemcommand( "/bin/date" , "+%Y%m%d" );
print( "\n" );
print( "Enter the new date (same format as above or control + c to quit)\n" );
chomp( $input = <STDIN> ) ;
if( $input =~ m/\d+/ )
{ print "Setting the system date to $input ...\n";
systemcommand( "/bin/date" , "+%Y%m%d -s $input" );
}
else
{
print "Input Error. Please use the format from the example. System date not changed.";
}
} # end setthedate
sub checkip(;$)
{
if($_[0] =~ m/^(?!0+\.0+\.0+\.0)
([01]?\d\d?|2[0-4]\d|25[0-5])
\.([01]?\d\d?|2[0-4]\d|25[0-5])
\.([01]?\d\d?|2[0-4]\d|25[0-5])
\.([01]?\d\d?|2[0-4]\d|25[0-5])$/x )
{
return 1;
}
return 0;
}
# end checkip
# regex isn't quite right but date has built in param checks
sub setthetime()
{
print( "Current system time: " );
systemcommand( "/bin/date" , "+%T" );
print( "\n" );
print( "Enter the new time (same format as above, HH:MM:SS or control + c to quit)\n" );
chomp( $input = <STDIN> ) ;
if( $input =~ m/([0-2]?[0-4]?\:\d+)/ )
{ print "Setting the system time to $input ...\n";
systemcommand( "/bin/date" , "+%T -s $input" );
}
else
{
print "Input Error. Please use the format from the example. System time not changed.";
}
} # end setthetime
sub menu
{
systemcommand( "/bin/date" , "+%Y-%m-%d_%T" );
print "\n= Appliance = \n\n ";
print " Please enter selection: \n\n";
print " 1. Setup IP address (requires reboot) \n";
print " 2. Set the Date \n";
print " 3. Set the Time \n";
print " 4. Synchronize Time with NTP \n";
print " 5. Modify Firewall \n";
print "\n\n";
print " 9. Display Network configuration \n";
print " 0. Reboot machine \n\n";
print ": ";
}
#end menu