summaryrefslogtreecommitdiffstats
path: root/config-db/slxsettings
diff options
context:
space:
mode:
authorOliver Tappe2007-04-08 14:53:46 +0200
committerOliver Tappe2007-04-08 14:53:46 +0200
commitd608f35965e52013342ae9b59acd86da8d333961 (patch)
treebcc5a250f339ce71bdc1c3612b9f405cdd6fafcd /config-db/slxsettings
parent* made output less confusing (use '' instead of <>) (diff)
downloadcore-d608f35965e52013342ae9b59acd86da8d333961.tar.gz
core-d608f35965e52013342ae9b59acd86da8d333961.tar.xz
core-d608f35965e52013342ae9b59acd86da8d333961.zip
* in order to be consistent with other scripts, 'remove' is now a real action. So you
have to do 'slxsettings remove db-type' in order to remove the option db-type from the local settings. * adjusted POD to recent changes git-svn-id: http://svn.openslx.org/svn/openslx/trunk@872 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/slxsettings')
-rwxr-xr-xconfig-db/slxsettings39
1 files changed, 29 insertions, 10 deletions
diff --git a/config-db/slxsettings b/config-db/slxsettings
index 298c84aa..f0de947c 100755
--- a/config-db/slxsettings
+++ b/config-db/slxsettings
@@ -54,8 +54,6 @@ my (
GetOptions(
'quiet' => \$quiet,
# will avoid printing anything
- 'remove=s' => \@remove,
- # will avoid printing anything
'setting=s' => \%cmdlineSettings,
# accepts setting for db-table 'settings'
@@ -73,6 +71,17 @@ if ($versionReq) {
openslxInit() or pod2usage(2);
+# if there are still arguments in the cmdline left, it must be 'remove'-actions:
+while (scalar @ARGV) {
+ my $action = shift;
+ my $key = shift;
+ if ($action !~ m[^remove$]) {
+ print STDERR _tr("Action '%s' is not understood!\n\n", $action);
+ pod2usage();
+ }
+ push @remove, $key;
+}
+
# fetch slxconf entries...
my $openslxDB = OpenSLX::ConfigDB->new();
$openslxDB->connect();
@@ -93,8 +102,7 @@ foreach my $key (sort keys %cmdlineConfig) {
my $value = $cmdlineConfig{$key};
next if !defined $value;
vlog 0, _tr("setting %s to '%s'", $key, $value) unless $quiet;
- $key =~ tr[-][_];
- my $externalKey = "SLX_".uc($key);
+ my $externalKey = externalKeyFor($key);
if (!($settings =~ s[^\s*$externalKey=.*?$][$externalKey=$value]ms)) {
$settings .= "$externalKey=$value\n";
}
@@ -107,10 +115,12 @@ foreach my $key (@remove) {
vlog 0, _tr("ignoring unknown key '%s'", $key);
next;
}
- vlog 0, _tr('removing %s', $key) unless $quiet;
- $key =~ tr[-][_];
- my $externalKey = "SLX_".uc($key);
- $settings =~ s[^\s*$externalKey=.*?$][]ms;
+ my $externalKey = externalKeyFor($key);
+ if ($settings =~ s[^\s*$externalKey=.*?$][]ms) {
+ vlog 0, _tr("removing option '%s' from local settings", $key) unless $quiet;
+ } else {
+ vlog 0, _tr("option '%s' didn't exist in local settings!", $key) unless $quiet;
+ }
$changeCount++;
}
@@ -149,6 +159,14 @@ if ($verbose || !$changeCount) {
}
}
+sub externalKeyFor
+{
+ my $key = shift;
+
+ $key =~ tr[-][_];
+ return "SLX_".uc($key);
+}
+
__END__
=head1 NAME
@@ -195,9 +213,10 @@ slxsettings [options] [action ...]
sets the specified openslx-option to the given value
-=item B<< remove=<openslx-option> >>
+=item B<< remove <openslx-option> [remove ...] >>
-removes given openslx-option (sets it to an empty string)
+removes given openslx-option from the local settings (resets it to the
+default value)
=back