From: Michael Gernoth Date: Wed, 4 Feb 2009 22:11:10 +0000 (+0100) Subject: saving/restoring of settings implemented X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/commitdiff_plain/e7ae5b6c2e684ce38ac527a7c6a0423322ff2669 saving/restoring of settings implemented --- 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 '') {