summaryrefslogtreecommitdiffstats
path: root/config-db
diff options
context:
space:
mode:
authorOliver Tappe2007-06-17 12:29:17 +0200
committerOliver Tappe2007-06-17 12:29:17 +0200
commit9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b (patch)
tree176dc068777af9af1119c55648ec73e78517393e /config-db
parentEnabled busybox option to allow longer filenames in tar archives (see (diff)
downloadcore-9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b.tar.gz
core-9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b.tar.xz
core-9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b.zip
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
Diffstat (limited to 'config-db')
-rw-r--r--config-db/OpenSLX/ConfigDB.pm4
-rw-r--r--config-db/OpenSLX/MetaDB/Base.pm10
-rw-r--r--config-db/OpenSLX/MetaDB/CSV.pm15
-rw-r--r--config-db/OpenSLX/MetaDB/SQLite.pm10
-rw-r--r--config-db/OpenSLX/MetaDB/mysql.pm4
-rwxr-xr-xconfig-db/slxconfig17
-rwxr-xr-xconfig-db/slxconfig-demuxer91
7 files changed, 73 insertions, 78 deletions
diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm
index b6755155..3926fb9f 100644
--- a/config-db/OpenSLX/ConfigDB.pm
+++ b/config-db/OpenSLX/ConfigDB.pm
@@ -176,7 +176,7 @@ sub connect
vlog 0, "\t$dbMod\n";
}
}
- die _tr('Please use slxsettings to switch to another db-type.');
+ die _tr('Please use slxsettings if you want to switch to another db-type.');
}
$self->{'db-type'} = $dbType;
@@ -957,7 +957,7 @@ sub aggregatedSystemFileInfoFor
$info->{'vendor-os'} = $vendorOS;
my $kernelPath
- = "$openslxConfig{'stage1-path'}/$vendorOS->{name}/boot";
+ = "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}/boot";
$info->{'kernel-file'} = "$kernelPath/$system->{kernel}";
my $exportURI = $export->{'uri'};
diff --git a/config-db/OpenSLX/MetaDB/Base.pm b/config-db/OpenSLX/MetaDB/Base.pm
index db1f2e7e..74daf5f1 100644
--- a/config-db/OpenSLX/MetaDB/Base.pm
+++ b/config-db/OpenSLX/MetaDB/Base.pm
@@ -378,16 +378,6 @@ the following entries in order to find out which database to connect to:
=over
-=item C<$config{'db-basepath'}>
-
-Basic path to openslx database, defaults to path of running script
-
-=item C<$config{'db-datadir'}>
-
-Data folder created under db-basepath, default depends on db-type (many
-DBMSs don't have such a folder, as they do not store the data in the
-filesystem).
-
=item C<$config{'db-spec'}>
Full specification of database, a special string defining the
diff --git a/config-db/OpenSLX/MetaDB/CSV.pm b/config-db/OpenSLX/MetaDB/CSV.pm
index 94335d25..cd2a7da4 100644
--- a/config-db/OpenSLX/MetaDB/CSV.pm
+++ b/config-db/OpenSLX/MetaDB/CSV.pm
@@ -48,22 +48,17 @@ sub connect
my $dbSpec = $openslxConfig{'db-spec'};
if (!defined $dbSpec) {
# build $dbSpec from individual parameters:
- my $dbBasepath = $openslxConfig{'db-basepath'};
- my $dbDatadir = $openslxConfig{'db-datadir'}
- || "$openslxConfig{'db-name'}-csv";
+ my $dbBasepath = "$openslxConfig{'private-path'}/db";
+ my $dbDatadir = "$openslxConfig{'db-name'}-csv";
my $dbPath = "$dbBasepath/$dbDatadir";
- if (!-e $dbPath) {
- mkdir $dbPath
- or die _tr("unable to create db-datadir %s! (%s)\n",
- $dbPath, $!);
- }
+ system("mkdir -p $dbPath") unless -e $dbPath;
$dbSpec = "f_dir=$dbPath;csv_eol=\n;";
}
vlog 1, "trying to connect to CSV-database <$dbSpec>";
$self->{'dbh'} = DBI->connect("dbi:CSV:$dbSpec", undef, undef,
{PrintError => 0})
- or confess _tr("Cannot connect to database '%s' (%s)",
- $dbSpec, $DBI::errstr);
+ or die _tr("Cannot connect to database '%s' (%s)",
+ $dbSpec, $DBI::errstr);
}
sub quote
diff --git a/config-db/OpenSLX/MetaDB/SQLite.pm b/config-db/OpenSLX/MetaDB/SQLite.pm
index 147b2061..d2b91a03 100644
--- a/config-db/OpenSLX/MetaDB/SQLite.pm
+++ b/config-db/OpenSLX/MetaDB/SQLite.pm
@@ -45,10 +45,10 @@ sub connect
my $dbSpec = $openslxConfig{'db-spec'};
if (!defined $dbSpec) {
# build $dbSpec from individual parameters:
- my $dbBasepath = $openslxConfig{'db-basepath'};
- my $dbDatadir = $openslxConfig{'db-datadir'} || 'sqlite';
+ my $dbBasepath = "$openslxConfig{'private-path'}/db";
+ my $dbDatadir = 'sqlite';
my $dbPath = "$dbBasepath/$dbDatadir";
- mkdir $dbPath unless -e $dbPath;
+ system("mkdir -p $dbPath") unless -e $dbPath;
$dbSpec = "dbname=$dbPath/$openslxConfig{'db-name'}";
}
vlog 1, "trying to connect to SQLite-database <$dbSpec>";
@@ -57,8 +57,8 @@ sub connect
so there is no support for %s available, sorry!\n%s], 'DBD::SQLite', 'SQLite', $@);
$self->{'dbh'} = DBI->connect("dbi:SQLite:$dbSpec", undef, undef,
{PrintError => 0, AutoCommit => 1})
- or confess _tr("Cannot connect to database <%s> (%s)",
- $dbSpec, $DBI::errstr);
+ or die _tr("Cannot connect to database <%s> (%s)",
+ $dbSpec, $DBI::errstr);
}
sub schemaRenameTable
diff --git a/config-db/OpenSLX/MetaDB/mysql.pm b/config-db/OpenSLX/MetaDB/mysql.pm
index 231e1bda..25cc93a8 100644
--- a/config-db/OpenSLX/MetaDB/mysql.pm
+++ b/config-db/OpenSLX/MetaDB/mysql.pm
@@ -51,8 +51,8 @@ sub connect
vlog 1, "trying to connect user <$user> to mysql-database <$dbSpec>";
$self->{'dbh'} = DBI->connect("dbi:mysql:$dbSpec", $user, '',
{PrintError => 0})
- or confess _tr("Cannot connect to database <%s> (%s)",
- $dbSpec, $DBI::errstr);
+ or die _tr("Cannot connect to database <%s> (%s)",
+ $dbSpec, $DBI::errstr);
}
sub schemaConvertTypeDescrToNative
diff --git a/config-db/slxconfig b/config-db/slxconfig
index fe70e48b..f64b1fcd 100755
--- a/config-db/slxconfig
+++ b/config-db/slxconfig
@@ -33,6 +33,7 @@ use lib "$FindBin::RealBin/../config-db";
use OpenSLX::Basics;
use OpenSLX::ConfigDB;
+use OpenSLX::ConfigFolder;
use OpenSLX::DBSchema;
my (
@@ -371,6 +372,13 @@ sub addSystemToConfigDB
unless exists $systemData->{attr_start_x};
}
+ my $systemConfigPath
+ = "$openslxConfig{'private-path'}/config/$systemName/default";
+ if (!-e $systemConfigPath) {
+ # create the default (empty) config folders for this system:
+ createConfigFolderForSystem($systemName);
+ }
+
my $systemID = $openslxDB->addSystem([$systemData]);
vlog 0, _tr("system '%s' has been successfully added to DB (ID=%s)\n",
$systemName, $systemID);
@@ -806,23 +814,14 @@ slxsettings, slxos-setup, slxos-export, slxconfig-demuxer
Being a part of OpenSLX, this script supports several other options
which can be used to overrule the OpenSLX settings:
- --base-path=<string> basic path to project files
- --bin-path=<string> path to binaries and scripts
- --config-path=<string> path to configuration files
- --db-basepath=<string> basic path to openslx database
- --db-datadir=<string> data folder created under db-basepath
--db-name=<string> name of database
--db-spec=<string> full DBI-specification of database
--db-type=<string> type of database to connect to
- --export-path=<string> path to root of all exported filesystems
--locale=<string> locale to use for translations
--logfile=<string> file to write logging output to
--private-path=<string> path to private data
--public-path=<string> path to public (client-accesible) data
- --share-path=<string> path to sharable data
- --stage1-path=<string> path to stage1 systems
--temp-path=<string> path to temporary data
- --tftpboot-path=<string> path to root of tftp-server
--verbose-level=<int> level of logging verbosity (0-3)
Please refer to the C<slxsettings>-manpage for a more detailed description
diff --git a/config-db/slxconfig-demuxer b/config-db/slxconfig-demuxer
index a5cd3d68..5d3804c7 100755
--- a/config-db/slxconfig-demuxer
+++ b/config-db/slxconfig-demuxer
@@ -23,15 +23,14 @@ slxconfig-demuxer
to a set of configuration files. These files are used by any OpenSLX-client
during boot to find out which systems to offer for booting.
- The resulting files will be put into the OpenSLX-tftpboot-path (you can use
- the option --tftpboot-path to override the default taken from the OpenSLX
- default settings).
+ The resulting files will be put into the OpenSLX-tftpboot-path.
Please use the --man option in order to read the full manual.
];
use Fcntl qw(:DEFAULT :flock);
use File::Basename;
+use File::Find;
use Getopt::Long qw(:config pass_through);
use Pod::Usage;
@@ -44,6 +43,7 @@ use lib "$FindBin::RealBin";
use OpenSLX::Basics;
use OpenSLX::ConfigDB qw(:support);
+use OpenSLX::ConfigFolder;
use OpenSLX::Utils;
my $pxeDefaultTemplate =
@@ -103,17 +103,28 @@ my $openslxDB = OpenSLX::ConfigDB->new();
$openslxDB->connect();
my $clientConfigPath = "$openslxConfig{'private-path'}/config";
-if (!-d $clientConfigPath) {
- die _tr("Unable to access client-config-path '%s'!", $clientConfigPath);
+# make sure that the default config folders exist:
+if (createConfigFolderForDefaultSystem()) {
+ # this path should have been generated by earlier stage (slxsettings), so
+ # we indicate that there is some kind of problem:
+ warn _tr("Completed client-config-folder '%s', since at least some parts of it didn't exist!",
+ $clientConfigPath);
}
+
+my $lockFile = "$openslxConfig{'private-path'}/config-demuxer.lock";
+lockScript($lockFile);
+
+END { unlockScript($lockFile); }
+
my $tempPath = "$openslxConfig{'temp-path'}/slxconfig-demuxer";
if (!$dryRun) {
- mkdir $tempPath;
+ slxsystem("rm -rf $tempPath");
+ slxsystem("mkdir -p $tempPath");
if (!-d $tempPath) {
die _tr("Unable to create or access temp-path '%s'!", $tempPath);
}
}
-my $tftpbootPath = $openslxConfig{'tftpboot-path'};
+my $tftpbootPath = "$openslxConfig{'public-path'}/tftpboot";
if (!$dryRun) {
slxsystem("rm -rf $tftpbootPath/client-config/* $tftpbootPath/pxe/*");
slxsystem("mkdir -p $tftpbootPath/client-config $tftpbootPath/pxe/pxelinux.cfg");
@@ -122,11 +133,6 @@ if (!$dryRun) {
}
}
-my $lockFile = "$tftpbootPath/config-demuxer.lock";
-lockScript($lockFile);
-
-END { unlockScript($lockFile); }
-
writeConfigurations();
my $wr = ($dryRun ? "would have written" : "wrote");
@@ -178,6 +184,25 @@ sub unlockScript
unlink $lockFile;
}
+sub folderContainsFiles
+{
+ my $folder = shift;
+
+ return 0 unless -d $folder;
+
+ my $result = 0;
+ my $wanted = sub {
+ if ($result) {
+ # skip anything else if we have found a file already
+ $File::Find::prune = 1;
+ }
+ $result = 1 if -f;
+ };
+ find({ wanted => $wanted, follow_fast => 1 }, $folder);
+ vlog 2, "result for folderContainsFiles($folder): $result\n";
+ return $result;
+}
+
sub digestAttributes
{ # returns a digest-string for the given attribute hash, in order to
# facilitate comparing different attribute hashes.
@@ -262,7 +287,7 @@ sub copyExternalSystemConfig
my $systemSpecConfigPath
= "$clientConfigPath/$systemName/default";
vlog 2, "checking $systemSpecConfigPath for system config...";
- if (-d $systemSpecConfigPath) {
+ if (folderContainsFiles($systemSpecConfigPath)) {
slxsystem("cp -a $systemSpecConfigPath/* $targetPath");
}
if (defined $clientName) {
@@ -271,7 +296,7 @@ sub copyExternalSystemConfig
my $clientSpecConfigPath
= "$clientConfigPath/$systemName/$clientName";
vlog 2, "checking $clientSpecConfigPath for client config...";
- if (-d $clientSpecConfigPath) {
+ if (folderContainsFiles($clientSpecConfigPath)) {
slxsystem("cp -a $clientSpecConfigPath/* $targetPath")
}
}
@@ -306,17 +331,17 @@ sub writePXEMenus
if (!-e "$pxePath/pxelinux.0") {
my $pxelinux0Path
- = "$openslxConfig{'share-path'}/tftpboot/pxelinux.0";
+ = "$openslxConfig{'base-path'}/share/tftpboot/pxelinux.0";
slxsystem(qq[cp -p "$pxelinux0Path" $pxePath/]) unless $dryRun;
}
if (!-e "$pxePath/menu.c32") {
my $menuc32Path
- = "$openslxConfig{'share-path'}/tftpboot/menu.c32";
+ = "$openslxConfig{'base-path'}/share/tftpboot/menu.c32";
slxsystem(qq[cp -p "$menuc32Path" $pxePath/]) unless $dryRun;
}
if (!-e "$pxePath/vesamenu.c32") {
my $vesamenuc32Path
- = "$openslxConfig{'share-path'}/tftpboot/vesamenu.c32";
+ = "$openslxConfig{'base-path'}/share/tftpboot/vesamenu.c32";
slxsystem(qq[cp -p "$vesamenuc32Path" $pxePath/]) unless $dryRun;
}
@@ -375,7 +400,7 @@ sub generateInitalRamFS
$osExportEngine->initializeFromExisting($info->{export}->{name});
vlog 1, _tr('generating initialramfs %s/initramfs', $pxeVendorOSPath);
- my $cmd = "$openslxConfig{'bin-path'}/mkdxsinitrd ";
+ my $cmd = "$openslxConfig{'base-path'}/bin/mkdxsinitrd ";
if (length($info->{attr_ramfs_nicmods}) > 0) {
$cmd .= qq[-n "$info->{attr_ramfs_nicmods}" ];
}
@@ -385,7 +410,7 @@ sub generateInitalRamFS
$cmd .= qq[-f "$fsMods" ];
}
my $rootPath
- = "$openslxConfig{'stage1-path'}/$vendorOS->{name}";
+ = "$openslxConfig{'private-path'}/stage1/$vendorOS->{name}";
$cmd .= "-i $pxeVendorOSPath/$info->{'initramfs-name'} -r $rootPath ";
$cmd .= "-S $info->{name} ";
# pass in system name
@@ -407,9 +432,6 @@ sub generateInitalRamFS
my $slxver = `slxversion`;
chomp $slxver;
$ENV{'SLX_VERSION'} = $slxver;
- $ENV{'SLX_PRIVATE_PATH'} = $openslxConfig{'private-path'};
- $ENV{'SLX_PUBLIC_PATH'} = $openslxConfig{'public-path'};
- $ENV{'SLX_SHARE_PATH'} = $openslxConfig{'share-path'};
slxsystem($cmd) unless $dryRun;
}
@@ -579,9 +601,7 @@ configurational attributes and then demultiplex the resulting information
to a set of configuration files. These files are used by any OpenSLX-client
during boot to find out which systems to offer for booting.
-The resulting files will be put into the OpenSLX-tftpboot-path (you can use the
-option B<--tftpboot-path> to override the default taken from the OpenSLX
-default settings).
+The resulting files will be put into the OpenSLX-tftpboot-path.
=head2 FILE CREATION
@@ -592,12 +612,12 @@ The following set of files will be created:
=item B<Basic PXE Setup>
The basic PXE files (F<menu.c32>, F<pxelinux.0>) will be copied into
-F<$SLX_TFTPBOOT_PATH/pxe> to make them available to any PXE-client via tftp.
+F<$SLX_PUBLIC_PATH/tftpboot/pxe> to make them available to any PXE-client via tftp.
=item B<PXE Client Configurations>
For each client, a PXE configuration file will be generated and written to
-F<$SLX_TFTPBOOT_PATH/pxe/pxelinux.cfg/01-<MAC-of-client>>. This file will
+F<$SLX_PUBLIC_PATH/tftpboot/pxe/pxelinux.cfg/01-<MAC-of-client>>. This file will
contain information about the systems this client shall offer for booting.
For each of these systems, the kernel cmdline options required for that
particular system setup is specified (via PXE's APPEND option).
@@ -609,9 +629,9 @@ configuration file) will use the configuration from the default client
=item B<System Kernels and Initialram-Filesystems>
For each bootable system, that system's kernel will be copied to
-F<$SLX_TFTPBOOT_PATH/pxe/<vendor-os-name>/kernel and an OpenSLX-specific initramfs
+F<$SLX_PUBLIC_PATH/tftpboot/pxe/<vendor-os-name>/kernel and an OpenSLX-specific initramfs
required for booting that particular system is generated (by means of
-slxmkramfs) and put into F<$SLX_TFTPBOOT_PATH/pxe/<vendor-os-name>/initramfs.
+slxmkramfs) and put into F<$SLX_PUBLIC_PATH/tftpboot/pxe/<vendor-os-name>/initramfs.
These two files (kernel & initramfs) will be referenced by the PXE client
configuration of all clients that offer this specific system for booting.
@@ -619,10 +639,10 @@ configuration of all clients that offer this specific system for booting.
=item B<OpenSLX Client Configurations>
For each system, an OpenSLX configuration archive will be generated and written
-to F<$SLX_TFTPBOOT_PATH/client-config/<system-name>/default. Furthermore,
+to F<$SLX_PUBLIC_PATH/tftpboot/client-config/<system-name>/default. Furthermore,
every client of that system whose attributes differ from the system's default
will get its own configuration archive generated here, too (e.g.
-F<$SLX_TFTPBOOT_PATH/client-config/<system-name>/01-<MAC-of-client>.tgz>).
+F<$SLX_PUBLIC_PATH/tftpboot/client-config/<system-name>/01-<MAC-of-client>.tgz>).
Each of these archives will contain the file F<initramfs/machine-setup>,
specifying all the attributes of that particular system and/or client
@@ -709,23 +729,14 @@ slxsettings, slxos-setup, slxos-export, slxconfig
Being a part of OpenSLX, this script supports several other options
which can be used to overrule the OpenSLX settings:
- --base-path=<string> basic path to project files
- --bin-path=<string> path to binaries and scripts
- --config-path=<string> path to configuration files
- --db-basepath=<string> basic path to openslx database
- --db-datadir=<string> data folder created under db-basepath
--db-name=<string> name of database
--db-spec=<string> full DBI-specification of database
--db-type=<string> type of database to connect to
- --export-path=<string> path to root of all exported filesystems
--locale=<string> locale to use for translations
--logfile=<string> file to write logging output to
--private-path=<string> path to private data
--public-path=<string> path to public (client-accesible) data
- --share-path=<string> path to sharable data
- --stage1-path=<string> path to stage1 systems
--temp-path=<string> path to temporary data
- --tftpboot-path=<string> path to root of tftp-server
--verbose-level=<int> level of logging verbosity (0-3)
Please refer to the C<slxsettings>-manpage for a more detailed description