From e7ae5b6c2e684ce38ac527a7c6a0423322ff2669 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Wed, 4 Feb 2009 23:11:10 +0100 Subject: [PATCH] saving/restoring of settings implemented --- rsbs2.pl | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/rsbs2.pl b/rsbs2.pl index bf0bd9d..ee813f8 100755 --- a/rsbs2.pl +++ b/rsbs2.pl @@ -159,6 +159,8 @@ sub _getprop { my $reqstr=''; my $resp = _req($reqstr); + + print "get: ${property}\n" if ($verbose); if ($resp->{RESP}->{RC} ne '0x0') { $resp->{RESP}->{RC}; @@ -195,7 +197,7 @@ sub setprop { if ($res->{RESP}->{RC} ne '0x0') { print "Error setting ${property} to ${value}: ".$res->{RESP}->{RC}."\n"; } else { - print "${property}: ${oldval} -> ${value}\n" if ($verbose); + print "${property}: ${oldval} -> ${value}\n"; } } @@ -430,7 +432,7 @@ while (defined($ARGV[0])) { } } -if (!defined(${$Config{$hostalias}}{'host'})) { +if ($valid_arg && (!defined(${$Config{$hostalias}}{'host'}))) { $valid_arg = 0; } @@ -483,11 +485,29 @@ if (@sprop) { } if ($save ne '') { - print "save: implement me!\n"; + my @dontsave = qw(ENABLE_LAN_AUTONEG ENABLE_LAN_100 ENABLE_LAN_FDUPLEX GATEWAY + IP_ADDRESS NETMASK TFTP_FIRMWARE_FILE TFTP_ADDR_FIRMWARE ENABLE_DHCP); + + open (SAVEFILE, ">${save}") || die "Error opening save-file: $!\n"; + foreach my $ts (@fw_vars) { + next if (grep(/^${ts}$/, @dontsave)); + + my $phash = _getprop($ts)->{RESP}->{PROPLIST}->{PROP}; + next if ($phash->{PERMS} ne 'RW'); + + print SAVEFILE "${ts}=".$phash->{VAL}."\n"; + } + close(SAVEFILE); } if ($load ne '') { - print "load: implement me!\n"; + open (LOADFILE, "<${load}") || die "Error opening load-file: $!\n"; + while() { + chomp; + (my $p, my $v) = split(/=/, $_); + setprop($p, $v); + } + close(LOADFILE); } if ($enable_debug ne '') { -- 2.39.5