summaryrefslogtreecommitdiffstats
path: root/config-db/slxconfig-demuxer
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/slxconfig-demuxer
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/slxconfig-demuxer')
-rwxr-xr-xconfig-db/slxconfig-demuxer91
1 files changed, 51 insertions, 40 deletions
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