From 9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sun, 17 Jun 2007 10:29:17 +0000 Subject: largish change with respect to configurable paths: * instead of supporting configurable paths at different hierarchy levels, there are now only five configurable folder: + base-path (/opt/openslx), fixed at installation time + config-path (/etc/opt/openslx), fixed at installation time + private-path (/var/opt/openslx), freely configurable by user + public-path (/srv/openslx), freely configurable by user + temp-path (/tmp), freely configurable by user this closes ticket#143 * several holes have been plugged concerning the creation of folders before they are accessed, closing ticket#142 * the functionality of generating config default folders has been moved from the Makefile into a new Perl-module (ConfigFolder.pm), in order to be available to the Perl-scripts, too * slxsettings has been changed to reflect the nature of base-path and config-path as fixed paths git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1172 95ad53e4-c205-0410-b2fa-d234c58c8868 --- bin/slxsettings | 110 ++++++++++++++++++-------------------------------------- 1 file changed, 35 insertions(+), 75 deletions(-) (limited to 'bin') diff --git a/bin/slxsettings b/bin/slxsettings index b6fd6e1e..1d4afcb5 100755 --- a/bin/slxsettings +++ b/bin/slxsettings @@ -84,12 +84,10 @@ while (scalar @ARGV) { # fetch current content of local settings file... my $settings = slurpFile("$openslxConfig{'config-path'}/settings"); -my $changeCount; +my %changed; # ...set new values... foreach my $key (keys %givenSettings) { - next if $key eq 'config-path'; - # config-path can't be changed, it is used to find settings my $value = $givenSettings{$key}; next if !defined $value; vlog 0, _tr("setting %s to '%s'", $key, $value) unless $quiet; @@ -97,7 +95,7 @@ foreach my $key (keys %givenSettings) { if (!($settings =~ s[^\s*$externalKey=.*?$][$externalKey=$value]ms)) { $settings .= "$externalKey=$value\n"; } - $changeCount++; + $changed{$key}++; } # reset specified keys to fall back to default: @@ -108,29 +106,41 @@ foreach my $key (@reset) { } else { vlog 0, _tr("option '%s' didn't exist in local settings!", $key) unless $quiet; } - $changeCount++; + $changed{$key}++; } # ... and write local settings file if necessary -if ($changeCount) { +if (keys %changed) { my $f = "$openslxConfig{'config-path'}/settings"; open(SETTINGS, "> $f") or die _tr("Unable to write local settings file '%s' (%s)", $f, $!); print SETTINGS $settings; close(SETTINGS); + + openslxInit(); + + foreach my $key (keys %changed) { + changedHandler($key, $openslxConfig{$key}); + } } -if (!$changeCount) { +if (!keys %changed) { + print _tr("paths fixed at installation time:\n"); + print qq[\t--base-path='$openslxConfig{'base-path'}'\n]; + print qq[\t--config-path='$openslxConfig{'config-path'}'\n]; my $text - = $changeCount ? "resulting base settings:" : "current base settings:"; - print "\n"._tr($text)."\n"; + = keys %changed + ? "resulting base settings (cmdline options):\n" + : "current base settings (cmdline options):\n"; + print $text; my @baseSettings = grep { exists $cmdlineConfig{$_} } keys %openslxConfig; foreach my $key (sort @baseSettings) { print qq[\t--$key='$openslxConfig{$key}'\n]; } - print "extended settings:\n"; + print _tr("extended settings:\n"); my @extSettings = grep { !exists $cmdlineConfig{$_} } keys %openslxConfig; foreach my $key (sort @extSettings) { + next if $key =~ m[^(base-path|config-path)$]; print qq[\t$key='$openslxConfig{$key}'\n]; } } @@ -143,7 +153,22 @@ sub externalKeyFor return "SLX_".uc($key); } +sub changedHandler +{ + my $key = shift; + my $value = shift; + + # invoke a key-specific change handler if it exists: + $key =~ tr[-][_]; + eval { no strict 'refs'; "${key}_changed_handler"->(); }; +} +sub private_path_changed_handler +{ + # create the default config folders (for default system only): + require OpenSLX::ConfigFolder; + OpenSLX::ConfigFolder::createConfigFolderForDefaultSystem(); +} =head1 NAME @@ -159,22 +184,14 @@ slxsettings [options] [action ...] =head3 OpenSLX Options - --base-path= basic path to project files - --bin-path= path to binaries and scripts - --config-path= path to configuration files - --db-basepath= basic path to openslx database - --db-datadir= data folder created under db-basepath --db-name= name of database --db-spec= full DBI-specification of database --db-type= type of database to connect to - --export-path= path to root of all exported filesystems --locale= locale to use for translations --logfile= file to write logging output to --private-path= path to private data --public-path= path to public (client-accesible) data - --share-path= path to sharable data --temp-path= path to temporary data - --tftpboot-path= path to root of tftp-server --verbose-level= level of logging verbosity (0-3) =head3 General Options @@ -219,37 +236,6 @@ settings and exit. =over 8 -=item B<< --base-path= >> - -Sets basic path to project files. - -Default is $SLX_BASE_PATH (usually F). - -=item B<< --bin-path= >> - -Sets path to binaries and scripts. - -Default is $SLX_BASE_PATH/bin (usually F). - -=item B<< --config-path= >> - -Sets path to configuration files. - -Default is $SLX_CONFIG_PATH (usually F). - -=item B<< --db-basepath= >> - -Sets basic path to openslx database. - -Default is $SLX_DB_PATH (usually F). - -=item B<< --db-datadir= >> - -Sets data folder created under db-basepath. - -Default is $SLX_DB_DATADIR (usually empty as it depends on db-type -whether or not such a directory is required at all). - =item B<< --db-name= >> Gives the name of the database to connect to. @@ -269,13 +255,6 @@ Sets the type of database to connect to (CSV, SQLite, mysql, ...). Default $SLX_DB_TYPE (usually C). -=item B<< --export-path= >> - -Sets path to root of all exported filesystems. For each type of export (NFS, -NBD, ...) a separate folder will be created in here. - -Default is $SLX_EXPORT_PATH (usually F. - =item B<< --locale= >> Sets the locale to use for translations. @@ -301,31 +280,12 @@ Sets path to public (client-accesible) data. Default is $SLX_PUBLIC_PATH (usually F. -=item B<< --share-path= >> - -Sets path to sharable data, where distro-specs and functionality templates -will be stored. - -Default is $SLX_SHARE_PATH (usually F. - -=item B<< --stage1-path= >> - -Sets path to stage1 systems, where distributor-systems will be installed. - -Default is $SLX_STAGE1_PATH (usually F. - =item B<< --temp-path= >> Sets path to temporary data. Default is $SLX_TEMP_PATH (usually F. -=item B<< --tftpboot-path= >> - -Sets path to root of tftp-server from which clients will access their files. - -Default is $SLX_TFTPBOOT_PATH (usually F. - =item B<< --verbose-level= >> Sets the level of logging verbosity (0-3). -- cgit v1.2.3-55-g7522