summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile91
-rwxr-xr-xbin/slxsettings110
-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
-rw-r--r--installer/OpenSLX/OSExport/Engine.pm6
-rw-r--r--installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm2
-rw-r--r--installer/OpenSLX/OSExport/ExportType/NFS.pm3
-rw-r--r--installer/OpenSLX/OSSetup/Distro/Base.pm2
-rw-r--r--installer/OpenSLX/OSSetup/Engine.pm12
-rw-r--r--installer/default_files/hwdata/Cards.local2
-rw-r--r--installer/default_files/hwdata/pcitable.local2
-rwxr-xr-xinstaller/slxos-export13
-rwxr-xr-xinstaller/slxos-setup11
-rw-r--r--lib/OpenSLX/Basics.pm108
-rw-r--r--lib/OpenSLX/ConfigFolder.pm110
20 files changed, 303 insertions, 320 deletions
diff --git a/Makefile b/Makefile
index 51bc7295..84d589b6 100644
--- a/Makefile
+++ b/Makefile
@@ -23,20 +23,12 @@ endif
ifeq ($(SLX_BASE_PATH),)
SLX_BASE_PATH = /opt/openslx
endif
-SLX_BIN_PATH = ${SLX_BASE_PATH}/bin
-SLX_SHARE_PATH = ${SLX_BASE_PATH}/share
-SLX_VMWARE_PATH = ${SLX_BASE_PATH}/vmware
-
ifeq ($(SLX_PRIVATE_PATH),)
SLX_PRIVATE_PATH = /var/opt/openslx
endif
-
ifeq ($(SLX_PUBLIC_PATH),)
SLX_PUBLIC_PATH = /srv/openslx
endif
-SLX_EXPORT_PATH = ${SLX_PUBLIC_PATH}/export
-SLX_TFTPBOOT_PATH = ${SLX_PUBLIC_PATH}/tftpboot
-
ifeq ($(SLX_TEMP_PATH),)
SLX_TEMP_PATH = /tmp
endif
@@ -138,34 +130,34 @@ supported."; \
echo "Installing OpenSLX project files"; \
mkdir -p $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH) \
-p $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/lib \
- -p $(SLX_BUILD_PATH)$(SLX_BIN_PATH) \
- -p $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/templates \
- -p $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/initramfs \
- -p $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/busybox \
- -p $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/squashfs \
+ -p $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin \
+ -p $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/templates \
+ -p $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/initramfs \
+ -p $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/busybox \
+ -p $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs \
-p $(SLX_BUILD_PATH)$(SLX_PRIVATE_PATH)/config/default/initramfs \
-p $(SLX_BUILD_PATH)$(SLX_PRIVATE_PATH)/config/default/rootfs \
- -p $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/themes \
+ -p $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/themes \
-p $(SLX_BUILD_PATH)${USR_BIN_PATH};
@ # copy license
@cp COPYING $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/;
@ # copy initramfs generator scripts (and inject SLX_CONFIG_PATH, SLX_BASE_PATH on the way):
- @cp ./initramfs/mkdxsinitrd $(SLX_BUILD_PATH)$(SLX_BIN_PATH)/; \
+ @cp ./initramfs/mkdxsinitrd $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/; \
sed -e "s,@@@SLX_CONFIG_PATH@@@,$(SLX_CONFIG_PATH)," \
-e "s,@@@SLX_BASE_PATH@@@,$(SLX_BASE_PATH)," \
- -i $(SLX_BUILD_PATH)$(SLX_BIN_PATH)/mkdxsinitrd;
+ -i $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/mkdxsinitrd;
@ # copy all PERL-scripts and their required modules:
- @cp bin/slx* $(SLX_BUILD_PATH)$(SLX_BIN_PATH)/; \
- cp config-db/slx* $(SLX_BUILD_PATH)$(SLX_BIN_PATH)/; \
- cp installer/slx* $(SLX_BUILD_PATH)$(SLX_BIN_PATH)/; \
+ @cp bin/slx* $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/; \
+ cp config-db/slx* $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/; \
+ cp installer/slx* $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/; \
tar --exclude=.svn -cp -C lib OpenSLX \
| tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/lib; \
tar --exclude=.svn --exclude *.example \
-cp -C lib distro-info \
- | tar -xp -C $(SLX_BUILD_PATH)$(SLX_SHARE_PATH); \
+ | tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \
tar --exclude=.svn --exclude prereqfiles --exclude trusted-package-keys/* \
-cp -C lib distro-info \
| tar -xp -C $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH); \
@@ -175,53 +167,46 @@ supported."; \
| tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/lib; \
@ # link all binaries & scripts into user-path:
- @ln -sf $(SLX_BIN_PATH)/slx* $(SLX_BUILD_PATH)$(USR_BIN_PATH)/; \
- ln -sf $(SLX_BIN_PATH)/mkdxsinitrd $(SLX_BUILD_PATH)$(USR_BIN_PATH)/; \
+ @ln -sf $(SLX_BASE_PATH)/bin/slx* $(SLX_BUILD_PATH)$(USR_BIN_PATH)/; \
+ ln -sf $(SLX_BASE_PATH)/bin/mkdxsinitrd $(SLX_BUILD_PATH)$(USR_BIN_PATH)/; \
@ # copy shareable data:
@cd initramfs/initrd-stuff; tar --exclude=.svn -cp * | \
- tar -xp -C $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/initramfs; cd ../..; \
+ tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/initramfs; cd ../..; \
tar --exclude=.svn -cp -C initramfs distro-specs | \
- tar -xp -C $(SLX_BUILD_PATH)$(SLX_SHARE_PATH); \
+ tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \
cp -p config-db/PXE-template.example \
$(SLX_BUILD_PATH)$(SLX_CONFIG_PATH)/; \
cp -a installer/default_files/machine-setup.default \
- $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/templates/; \
+ $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/templates/; \
cp -a installer/default_files/hwdata/{pcitable.local,Cards.local} \
- $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/templates/; \
+ $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/templates/; \
tar --exclude=.svn -cp -C installer/default_files tftpboot | \
- tar -xp -C $(SLX_BUILD_PATH)$(SLX_SHARE_PATH); \
+ tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \
cd theming; tar --exclude=.svn -cp * | \
- tar -xp -C $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/themes; cd ..; \
+ tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/themes; cd ..; \
cp -pP tools/busybox{,.links,.x86_64,.i586} \
- $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/busybox/; \
- cp -p tools/mksquashfs $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/squashfs/; \
+ $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/busybox/; \
+ cp -p tools/mksquashfs $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/; \
- @ # create pre-/postinit scripts for us in initramfs:
- @echo -e "#!/bin/sh\n#\n# This script allows the local admin to \
-extend the\n# capabilities at the beginning of the initramfs (stage3). \
-The toolset is rather\n# restricted and you have to keep in mind that \
-stage4 rootfs has the\n# prefix '/mnt'." \
- > $(SLX_BUILD_PATH)$(SLX_PRIVATE_PATH)/config/default/initramfs/preinit.local; \
- echo -e "#!/bin/sh\n#\n# This script allows the local admin to \
-extend the\n# capabilities at the end of the initramfs (stage3). The \
-toolset is rather\n# restricted and you have to keep in mind that stage4 \
-rootfs has the\n# prefix '/mnt'. But you might use some special slx \
-functions via\n# inclusion: '. /etc/functions' ..." \
- > $(SLX_BUILD_PATH)$(SLX_PRIVATE_PATH)/config/default/initramfs/postinit.local; \
- chmod u+x $(SLX_BUILD_PATH)$(SLX_PRIVATE_PATH)/config/default/initramfs/*init.local; \
+ @ # create default config folder hierarchy:
+ @perl -Ilib -e 'use OpenSLX::ConfigFolder; createConfigFolderForDefaultSystem();'
@ # create complete default settings and empty local settings file:
@echo -e "# default setup for OpenSLX-installation\
+\n\
+\n# paths that are fixed at packaging/installation time:\
\nSLX_BASE_PATH=${SLX_BASE_PATH}\
\nSLX_CONFIG_PATH=${SLX_CONFIG_PATH}\
+\n\
+\n# paths which can be adjusted after installation:\
\nSLX_PRIVATE_PATH=${SLX_PRIVATE_PATH}\
\nSLX_PUBLIC_PATH=${SLX_PUBLIC_PATH}\
\nSLX_TEMP_PATH=${SLX_TEMP_PATH}\n" \
- > $(SLX_BUILD_PATH)$(SLX_SHARE_PATH)/settings.default; \
+ > $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/settings.default; \
test -e $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH)/settings || \
echo -e "# Local setup for OpenSLX (overrides default settings).\
-\n#\n# Please look at $(SLX_SHARE_PATH)/settings.default and the docs to learn\
+\n#\n# Please look at $(SLX_BASE_PATH)/share/settings.default and the docs to learn\
\n# about the available options.\n" \
> $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH)/settings; \
@@ -236,9 +221,9 @@ functions via\n# inclusion: '. /etc/functions' ..." \
OPENSLX_SVN_SNAPSHOT="1"; \
. ./VERSIONS; \
echo -e "#! /bin/sh\n\necho $${OPENSLX_VERSION_STRING}" \
- > $(SLX_BUILD_PATH)${SLX_BIN_PATH}/slxversion; \
- chmod a+x $(SLX_BUILD_PATH)${SLX_BIN_PATH}/slxversion; \
- ln -sf $(SLX_BIN_PATH)/slxversion $(SLX_BUILD_PATH)$(USR_BIN_PATH)/; \
+ > $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/slxversion; \
+ chmod a+x $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/slxversion; \
+ ln -sf $(SLX_BASE_PATH)/bin/slxversion $(SLX_BUILD_PATH)$(USR_BIN_PATH)/; \
@ # set default db-type:
@DEFAULT_DB_TYPE=$$(cat DEFAULT-DB-TYPE); \
@@ -248,11 +233,11 @@ functions via\n# inclusion: '. /etc/functions' ..." \
vmware_install:
@# we should read the config file here or better have a separate
@# script for installing vmware related stuff
- @echo "Installing VMware files to $(SLX_VMWARE_PATH)"
- @mkdir -p $(SLX_VMWARE_PATH)/templ \
- -p $(SLX_VMWARE_PATH)/vmsessions/kdm
- @cp -a vmware/* $(SLX_VMWARE_PATH)/templ/
- @echo -e "Please configure your exports (add $(SLX_VMWARE_PATH) to your list).\nCopy your *.vmdk files into $(SLX_VMWARE_PATH). For interactive mode add for each virtual machine (*.vmdk) a .desktop file into ./vmsessions (example file $(SLX_VMWARE_PATH)/templ/desktop.template). Don't forget to install Xdialog!"
+ @echo "Installing VMware files to $(SLX_BASE_PATH)/vmware"
+ @mkdir -p $(SLX_BASE_PATH)/vmware/templ \
+ -p $(SLX_BASE_PATH)/vmware/vmsessions/kdm
+ @cp -a vmware/* $(SLX_BASE_PATH)/vmware/templ/
+ @echo -e "Please configure your exports (add $(SLX_BASE_PATH)/vmware to your list).\nCopy your *.vmdk files into $(SLX_BASE_PATH)/vmware. For interactive mode add for each virtual machine (*.vmdk) a .desktop file into ./vmsessions (example file $(SLX_BASE_PATH)/vmware/templ/desktop.template). Don't forget to install Xdialog!"
uninstall:
@echo "Uninstalling openslx.org project files but keeping configs \
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=<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
--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)
=head3 General Options
@@ -219,37 +236,6 @@ settings and exit.
=over 8
-=item B<< --base-path=<string> >>
-
-Sets basic path to project files.
-
-Default is $SLX_BASE_PATH (usually F</opt/openslx>).
-
-=item B<< --bin-path=<string> >>
-
-Sets path to binaries and scripts.
-
-Default is $SLX_BASE_PATH/bin (usually F</opt/openslx/bin>).
-
-=item B<< --config-path=<string> >>
-
-Sets path to configuration files.
-
-Default is $SLX_CONFIG_PATH (usually F</etc/opt/openslx>).
-
-=item B<< --db-basepath=<string> >>
-
-Sets basic path to openslx database.
-
-Default is $SLX_DB_PATH (usually F</var/opt/openslx/db>).
-
-=item B<< --db-datadir=<string> >>
-
-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=<string> >>
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<CSV>).
-=item B<< --export-path=<string> >>
-
-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</srv/openslx/export>.
-
=item B<< --locale=<string> >>
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</srv/openslx>.
-=item B<< --share-path=<string> >>
-
-Sets path to sharable data, where distro-specs and functionality templates
-will be stored.
-
-Default is $SLX_SHARE_PATH (usually F</opt/openslx/share>.
-
-=item B<< --stage1-path=<string> >>
-
-Sets path to stage1 systems, where distributor-systems will be installed.
-
-Default is $SLX_STAGE1_PATH (usually F</var/opt/openslx/stage1>.
-
=item B<< --temp-path=<string> >>
Sets path to temporary data.
Default is $SLX_TEMP_PATH (usually F</tmp>.
-=item B<< --tftpboot-path=<string> >>
-
-Sets path to root of tftp-server from which clients will access their files.
-
-Default is $SLX_TFTPBOOT_PATH (usually F</srv/openslx/tftpboot>.
-
=item B<< --verbose-level=<int> >>
Sets the level of logging verbosity (0-3).
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
diff --git a/installer/OpenSLX/OSExport/Engine.pm b/installer/OpenSLX/OSExport/Engine.pm
index d02ac597..6668416a 100644
--- a/installer/OpenSLX/OSExport/Engine.pm
+++ b/installer/OpenSLX/OSExport/Engine.pm
@@ -208,9 +208,9 @@ sub _initialize
# setup source and target paths:
$self->{'vendor-os-path'}
- = "$openslxConfig{'stage1-path'}/$vendorOSName";
- $self->{'export-path'}
- = "$openslxConfig{'export-path'}/$exportType/$vendorOSName";
+ = "$openslxConfig{'private-path'}/stage1/$vendorOSName";
+ my $exportBasePath = "$openslxConfig{'public-path'}/export";
+ $self->{'export-path'} = "$exportBasePath/$exportType/$vendorOSName";
vlog 1, _tr("vendor-OS from '%s' will be exported to '%s'",
$self->{'vendor-os-path'}, $self->{'export-path'});
}
diff --git a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
index e2a558bd..a1ec0c26 100644
--- a/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
+++ b/installer/OpenSLX/OSExport/ExportType/NBD_Squash.pm
@@ -183,7 +183,7 @@ sub createSquashFS
# ... invoke mksquashfs ...
vlog 0, _tr("invoking mksquashfs...");
my $mksquashfsBinary
- = "$openslxConfig{'share-path'}/squashfs/mksquashfs";
+ = "$openslxConfig{'base-path'}/share/squashfs/mksquashfs";
my $res = system("$mksquashfsBinary $source $target -ff $filterFile");
unlink($filterFile);
# ... remove filter file if done
diff --git a/installer/OpenSLX/OSExport/ExportType/NFS.pm b/installer/OpenSLX/OSExport/ExportType/NFS.pm
index bfe4ba1f..12fa4bfc 100644
--- a/installer/OpenSLX/OSExport/ExportType/NFS.pm
+++ b/installer/OpenSLX/OSExport/ExportType/NFS.pm
@@ -70,7 +70,8 @@ sub generateExportURI
: generatePlaceholderFor('serverip');
$server .= ":$export->{port}" if length($export->{port});
- return "nfs://$server$openslxConfig{'export-path'}/nfs/$vendorOS->{name}";
+ my $exportPath = "$openslxConfig{'public-path'}/export";
+ return "nfs://$server/$exportPath/nfs/$vendorOS->{name}";
}
sub requiredFSMods
diff --git a/installer/OpenSLX/OSSetup/Distro/Base.pm b/installer/OpenSLX/OSSetup/Distro/Base.pm
index 6ed6078c..769288f1 100644
--- a/installer/OpenSLX/OSSetup/Distro/Base.pm
+++ b/installer/OpenSLX/OSSetup/Distro/Base.pm
@@ -50,7 +50,7 @@ sub initialize
}
$self->{'stage1a-binaries'} = {
- "$openslxConfig{'share-path'}/busybox/busybox" => 'bin',
+ "$openslxConfig{'base-path'}/share/busybox/busybox" => 'bin',
};
$self->{'stage1b-faked-files'} = [
diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm
index 35dbb32e..4d313e73 100644
--- a/installer/OpenSLX/OSSetup/Engine.pm
+++ b/installer/OpenSLX/OSSetup/Engine.pm
@@ -138,7 +138,7 @@ sub initialize
if ($actionType ne 'clone') {
# setup path to distribution-specific info:
my $sharedDistroInfoDir
- = "$openslxConfig{'share-path'}/distro-info/$distro->{'base-name'}";
+ = "$openslxConfig{'base-path'}/share/distro-info/$distro->{'base-name'}";
if (!-d $sharedDistroInfoDir) {
die _tr("unable to find shared distro-info in '%s'\n",
$sharedDistroInfoDir);
@@ -164,7 +164,7 @@ sub initialize
}
$self->{'vendor-os-path'}
- = "$openslxConfig{'stage1-path'}/$self->{'vendor-os-name'}";
+ = "$openslxConfig{'private-path'}/stage1/$self->{'vendor-os-name'}";
vlog 1, "vendor-OS path is '$self->{'vendor-os-path'}'";
if ($actionType ne 'clone') {
@@ -601,7 +601,7 @@ sub startLocalURLServersAsNeeded
= $self->hostIs64Bit()
? 'busybox.x86_64'
: 'busybox.i586';
- my $busybox = "$openslxConfig{'share-path'}/busybox/$busyboxName";
+ my $busybox = "$openslxConfig{'base-path'}/share/busybox/$busyboxName";
my $port = 5080;
if ($localURL =~ m[:(\d+)/]) {
$port = $1;
@@ -653,13 +653,13 @@ sub stage1A_createBusyboxEnvironment
= $self->hostIs64Bit()
? 'busybox.x86_64'
: 'busybox.i586';
- copyFile("$openslxConfig{'share-path'}/busybox/$busyboxName",
+ copyFile("$openslxConfig{'base-path'}/share/busybox/$busyboxName",
"$self->{stage1aDir}/bin", 'busybox');
# determine all required libraries and copy those, too:
vlog 1, _tr("calling slxldd for $busyboxName");
my $slxlddCmd
- = "slxldd $openslxConfig{'share-path'}/busybox/$busyboxName";
+ = "slxldd $openslxConfig{'base-path'}/share/busybox/$busyboxName";
vlog 2, "executing: $slxlddCmd";
my $requiredLibsStr = `$slxlddCmd`;
if ($?) {
@@ -682,7 +682,7 @@ sub stage1A_createBusyboxEnvironment
# create all needed links to busybox:
my $links
- = slurpFile("$openslxConfig{'share-path'}/busybox/busybox.links");
+ = slurpFile("$openslxConfig{'base-path'}/share/busybox/busybox.links");
foreach my $linkTarget (split "\n", $links) {
linkFile('/bin/busybox', "$self->{stage1aDir}/$linkTarget");
}
diff --git a/installer/default_files/hwdata/Cards.local b/installer/default_files/hwdata/Cards.local
index 94c15aa8..1bcf28b1 100644
--- a/installer/default_files/hwdata/Cards.local
+++ b/installer/default_files/hwdata/Cards.local
@@ -9,7 +9,7 @@
#
# General information about OpenSLX can be found under http://openslx.org
#
-# <SLX_SHARE_PATH>/share/templates/hwdata/Cards.local
+# <SLX_BASE_PATH>/share/templates/hwdata/Cards.local
#
# Local changes to the Cards file. All additions should be documented here,
# so that they are not lost ... They are prepended via mkdxsinitrd to the
diff --git a/installer/default_files/hwdata/pcitable.local b/installer/default_files/hwdata/pcitable.local
index c66ef550..5c7f370d 100644
--- a/installer/default_files/hwdata/pcitable.local
+++ b/installer/default_files/hwdata/pcitable.local
@@ -9,7 +9,7 @@
#
# General information about OpenSLX can be found under http://openslx.org
#
-# <SLX_SHARE_PATH>/share/templates/hwdata/pcitable.local
+# <SLX_BASE_PATH>/share/templates/hwdata/pcitable.local
#
# local changes to the pcitables file. All additions should be documented
# here, so that they are not lost ... the pcitable file seems to be part of
diff --git a/installer/slxos-export b/installer/slxos-export
index 91c81706..a29f2b4e 100755
--- a/installer/slxos-export
+++ b/installer/slxos-export
@@ -72,7 +72,7 @@ if ($action =~ m[^list-ex]i) {
# filter out RSYNC_TMP folders:
$_ !~ m[###];
}
- sort <$openslxConfig{'export-path'}/$type/*>);
+ sort <$openslxConfig{'public-path'}/export/$type/*>);
}
} elsif ($action =~ m[^list-in]i) {
print _tr("List of installed vendor-OSes:\n");
@@ -80,7 +80,7 @@ if ($action =~ m[^list-ex]i) {
s[^.+/][];
"\t$_\n";
}
- sort <$openslxConfig{'stage1-path'}/*>);
+ sort <$openslxConfig{'private-path'}/stage1/*>);
} elsif ($action =~ m[^list-ty]i) {
print _tr("List of supported export types:\n\t");
print join("\n\t", sort keys %supportedExportTypes)."\n";
@@ -275,23 +275,14 @@ slxsettings, slxos-setup, slxconfig, 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/installer/slxos-setup b/installer/slxos-setup
index bd0df5d5..1d6a0201 100755
--- a/installer/slxos-setup
+++ b/installer/slxos-setup
@@ -146,7 +146,7 @@ if ($action =~ m[^import]i) {
s[^.+/][];
"\t$_\n";
}
- sort <$openslxConfig{'stage1-path'}/*>);
+ sort <$openslxConfig{'private-path'}/stage1/*>);
} else {
print STDERR _tr("You need to specify exactly one action:
clone
@@ -349,23 +349,14 @@ slxsettings, slxos-export, slxconfig, 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/lib/OpenSLX/Basics.pm b/lib/OpenSLX/Basics.pm
index 285a8b4e..38da67d2 100644
--- a/lib/OpenSLX/Basics.pm
+++ b/lib/OpenSLX/Basics.pm
@@ -30,7 +30,7 @@ $VERSION = 1.01;
&addCleanupFunction &removeCleanupFunction
);
-use vars qw(%openslxConfig %cmdlineConfig);
+use vars qw(%openslxConfig %cmdlineConfig %openslxPath);
use subs qw(die);
################################################################################
@@ -52,8 +52,6 @@ my %translations;
# the initial content is based on environment variables or default values.
# Each value may be overridden from config files and/or cmdline arguments.
%openslxConfig = (
- 'croak' => '0',
- 'db-datadir' => $ENV{SLX_DB_DATADIR},
'db-name' => $ENV{SLX_DB_NAME} || 'openslx',
'db-spec' => $ENV{SLX_DB_SPEC},
'db-type' => $ENV{SLX_DB_TYPE} || 'SQLite',
@@ -67,95 +65,57 @@ my %translations;
'verbose-level' => $ENV{SLX_VERBOSE_LEVEL} || '0',
#
+ # options useful during development only:
+ #
+ 'debug-confess' => '0',
+
+ #
# extended settings follow, which are only supported by slxsettings,
# but not by any other script:
#
'ossetup-max-try-count' => '5',
);
chomp($openslxConfig{'locale-charmap'});
-$openslxConfig{'bin-path'} = $ENV{SLX_BIN_PATH}
- || "$openslxConfig{'base-path'}/bin";
-$openslxConfig{'db-basepath'} = $ENV{SLX_DB_PATH}
- || "$openslxConfig{'private-path'}/db";
-$openslxConfig{'export-path'} = $ENV{SLX_EXPORT_PATH}
- || "$openslxConfig{'public-path'}/export";
-$openslxConfig{'share-path'} = $ENV{SLX_SHARE_PATH}
- || "$openslxConfig{'base-path'}/share";
-$openslxConfig{'stage1-path'} = $ENV{SLX_STAGE1_PATH}
- || "$openslxConfig{'private-path'}/stage1";
-$openslxConfig{'tftpboot-path'} = $ENV{SLX_TFTPBOOT_PATH}
- || "$openslxConfig{'public-path'}/tftpboot";
-$openslxConfig{'vmware-path'} = $ENV{SLX_VMWARE_PATH}
- || "$openslxConfig{'base-path'}/vmware";
# specification of cmdline arguments that are shared by all openslx-scripts:
my %openslxCmdlineArgs = (
- 'base-path=s' => \$cmdlineConfig{'base-path'},
-
- # basic path to project files (binaries, functionality templates and
- # distro-specs)
- 'bin-path=s' => \$cmdlineConfig{'bin-path'},
-
- # path to binaries and scripts
- 'config-path=s' => \$cmdlineConfig{'config-path'},
-
- # path to configuration files
- 'croak' => \$cmdlineConfig{'croak'},
-
- # activates debug mode, this will show the lines where any error occured
- 'db-basepath=s' => \$cmdlineConfig{'db-basepath'},
-
- # basic path to openslx database, defaults to "${private-path}/db"
- 'db-datadir=s' => \$cmdlineConfig{'db-datadir'},
-
- # data folder created under db-basepath, default depends on db-type
- 'db-name=s' => \$cmdlineConfig{'db-name'},
-
# name of database, defaults to 'openslx'
- 'db-spec=s' => \$cmdlineConfig{'db-spec'},
+ 'db-name=s' => \$cmdlineConfig{'db-name'},
# full specification of database, a special string defining the
# precise database to connect to (the contents of this string
# depend on db-type)
- 'db-type=s' => \$cmdlineConfig{'db-type'},
+ 'db-spec=s' => \$cmdlineConfig{'db-spec'},
- # type of database to connect to (CSV, SQLite, ...), defaults to 'CSV'
- 'export-path=s' => \$cmdlineConfig{'export-path'},
+ # type of database to connect to (SQLite, mysql, ...), defaults to 'SQLite'
+ 'db-type=s' => \$cmdlineConfig{'db-type'},
- # path to root of all exports, each different export-type (e.g. nfs, nbd)
- # has a separate subfolder in here.
- 'locale=s' => \$cmdlineConfig{'locale'},
+ # activates debug mode, this will show the lines where any error occured
+ # (followed by a stacktrace):
+ 'debug-confess' => \$cmdlineConfig{'debug-confess'},
# locale to use for translations
- 'locale-charmap=s' => \$cmdlineConfig{'locale-charmap'},
+ 'locale=s' => \$cmdlineConfig{'locale'},
# locale-charmap to use for I/O (iso-8859-1, utf-8, etc.)
- 'logfile=s' => \$cmdlineConfig{'locale'},
+ 'locale-charmap=s' => \$cmdlineConfig{'locale-charmap'},
# file to write logging output to, defaults to STDERR
- 'private-path=s' => \$cmdlineConfig{'private-path'},
+ 'logfile=s' => \$cmdlineConfig{'locale'},
# path to private data (which is *not* accesible by clients and contains
# database, vendorOSes and all local extensions [system specific scripts])
- 'public-path=s' => \$cmdlineConfig{'public-path'},
+ 'private-path=s' => \$cmdlineConfig{'private-path'},
# path to public data (which is accesible by clients and contains
# PXE-configurations, kernels, initramfs and client configurations)
- 'share-path=s' => \$cmdlineConfig{'share-path'},
-
- # path to sharable data (functionality templates and distro-specs)
- 'stage1-path=s' => \$cmdlineConfig{'stage1-path'},
-
- # path to stage1 systems
- 'temp-path=s' => \$cmdlineConfig{'temp-path'},
+ 'public-path=s' => \$cmdlineConfig{'public-path'},
# path to temporary data (used during demuxing)
- 'tftpboot-path=s' => \$cmdlineConfig{'tftpboot-path'},
-
- # path to root of tftp-server, tftpable data will be stored there
- 'verbose-level=i' => \$cmdlineConfig{'verbose-level'},
+ 'temp-path=s' => \$cmdlineConfig{'temp-path'},
# level of logging verbosity (0-3)
+ 'verbose-level=i' => \$cmdlineConfig{'verbose-level'},
);
my %cleanupFunctions;
@@ -178,7 +138,6 @@ sub vlog
# ------------------------------------------------------------------------------
sub openslxInit
{
-
# evaluate cmdline arguments:
Getopt::Long::Configure('no_pass_through');
GetOptions(%openslxCmdlineArgs) or return 0;
@@ -186,8 +145,7 @@ sub openslxInit
# try to read and evaluate config files:
my $configPath = $cmdlineConfig{'config-path'}
|| $openslxConfig{'config-path'};
- my $sharePath = $cmdlineConfig{'share-path'}
- || $openslxConfig{'share-path'};
+ my $sharePath = "$openslxConfig{'base-path'}/share";
foreach my $f ("$sharePath/settings.default", "$configPath/settings",
"$ENV{HOME}/.openslx/settings")
{
@@ -265,7 +223,6 @@ sub trInit
}
if (lc($locale) ne 'posix') {
-
# parse locale and canonicalize it (e.g. to 'de_DE') and generate
# two filenames from it (language+country and language only):
if ($locale !~ m{^\s*([^_]+)(?:_(\w+))?}) {
@@ -283,7 +240,6 @@ sub trInit
foreach my $trName (@locales) {
my $trModule = "OpenSLX::Translations::$trName";
if (eval "require $trModule") {
-
# Access OpenSLX::Translations::<locale>::translations
# via a symbolic reference...
no strict 'refs';
@@ -294,14 +250,12 @@ sub trInit
$translations{$k} = $translationsRef->{$k};
}
$loadedTranslationModule = $trModule;
- vlog 1,
- _tr("translations module %s loaded successfully", $trModule);
+ vlog 1, _tr("translations module %s loaded successfully", $trModule);
last;
}
}
if (!defined $loadedTranslationModule) {
- vlog 1,
-"unable to load any translations module for locale '$locale' ($!).";
+ vlog 1, "unable to load any translations module for locale '$locale' ($!).";
}
}
}
@@ -329,7 +283,6 @@ sub callInSubprocess
my $pid = fork();
if (!$pid) {
-
# child...
# ...execute the given function and exit:
&$childFunc();
@@ -355,7 +308,6 @@ sub executeInSubprocess
my $pid = fork();
if (!$pid) {
-
# child...
# ...exec the given cmdline:
exec(@cmdlineArgs);
@@ -398,7 +350,6 @@ sub slxsystem
vlog 2, _tr("executing: %s", join ' ', @_);
my $res = system(@_);
if ($res > 0) {
-
# check if child got killed, if so we stop, too (unless the signal is
# SIGPIPE, which we ignore in order to loop over failed FTP connections
# and the like):
@@ -418,8 +369,8 @@ sub warn
my $msg = shift;
$msg =~ s[^\*\*\* ][]igms;
$msg =~ s[^][*** ]igms;
- if ($openslxConfig{'croak'}) {
- carp $msg;
+ if ($openslxConfig{'debug-confess'}) {
+ Carp::cluck $msg;
}
else {
chomp $msg;
@@ -435,8 +386,8 @@ sub die
my $msg = shift;
$msg =~ s[^\*\*\* ][]igms;
$msg =~ s[^][*** ]igms;
- if ($openslxConfig{'croak'}) {
- croak $msg;
+ if ($openslxConfig{'debug-confess'}) {
+ confess $msg;
}
else {
chomp $msg;
@@ -461,9 +412,8 @@ sub instantiateClass
if (defined $requestedVersion) {
my $classVersion = $class->VERSION;
if ($classVersion < $requestedVersion) {
- die _tr(
-'Could not load class <%s> (Version <%s> required, but <%s> found)',
- $class, $requestedVersion, $classVersion);
+ die _tr('Could not load class <%s> (Version <%s> required, but <%s> found)',
+ $class, $requestedVersion, $classVersion);
}
}
return $class->new;
diff --git a/lib/OpenSLX/ConfigFolder.pm b/lib/OpenSLX/ConfigFolder.pm
new file mode 100644
index 00000000..0c957ef5
--- /dev/null
+++ b/lib/OpenSLX/ConfigFolder.pm
@@ -0,0 +1,110 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# ConfigFolder.pm
+# - provides utility functions for generation of configuration folders
+# -----------------------------------------------------------------------------
+package OpenSLX::ConfigFolder;
+
+use strict;
+use vars qw(@ISA @EXPORT $VERSION);
+
+use Exporter;
+$VERSION = 1.01;
+@ISA = qw(Exporter);
+
+@EXPORT = qw(
+ &createConfigFolderForDefaultSystem
+ &createConfigFolderForSystem
+);
+
+################################################################################
+### Module implementation
+################################################################################
+use Carp;
+use OpenSLX::Basics;
+
+sub createConfigFolderForDefaultSystem
+{
+ my $result = 0;
+ my $defaultConfigPath = "$openslxConfig{'private-path'}/config/default";
+ if (!-e "$defaultConfigPath/initramfs") {
+ slxsystem("mkdir -p $defaultConfigPath/initramfs");
+ $result = 1;
+ }
+ if (!-e "$defaultConfigPath/rootfs") {
+ slxsystem("mkdir -p $defaultConfigPath/rootfs");
+ $result = 1;
+ }
+
+ # create default pre-/postinit scripts for us in initramfs:
+ my $preInitFile = "$defaultConfigPath/initramfs/preinit.local";
+ if (!-e $preInitFile) {
+ open(PREINIT, "> $preInitFile")
+ or die _tr("Unable to create file '%s'!", $preInitFile);
+ my $preInit = <<' END'
+ #!/bin/sh
+ #
+ # This script allows the local admin to extend the
+ # capabilities at the beginning of the initramfs (stage3).
+ # The toolset is rather limited and you have to keep in mind
+ # that stage4 rootfs has the prefix '/mnt'.
+ END
+ ;
+ $preInit =~ s[^\s+][]igms;
+ print PREINIT $preInit;
+ close(PREINIT);
+ slxsystem("chmod u+x $preInitFile");
+ $result = 1;
+ }
+
+ my $postInitFile = "$defaultConfigPath/initramfs/postinit.local";
+ if (!-e $postInitFile) {
+ open(POSTINIT, "> $postInitFile")
+ or die _tr("Unable to create file '%s'!", $postInitFile);
+ my $postInit = <<' END'
+ #!/bin/sh
+ #
+ # This script allows the local admin to extend the
+ # capabilities at the end of the initramfs (stage3).
+ # The toolset is rather limited and you have to keep in mind
+ # that stage4 rootfs has the prefix '/mnt'.
+ # But you may use some special slx-functions available via
+ # inclusion: '. /etc/functions' ...
+ END
+ ;
+ $postInit =~ s[^\s+][]igms;
+ print POSTINIT $postInit;
+ close(POSTINIT);
+ slxsystem("chmod u+x $postInitFile");
+ $result = 1;
+ }
+ return $result;
+}
+
+sub createConfigFolderForSystem
+{
+ my $systemName = shift || confess "need to pass in system-name!";
+
+ my $result = 0;
+ my $systemConfigPath
+ = "$openslxConfig{'private-path'}/config/$systemName/default";
+ if (!-e "$systemConfigPath/initramfs") {
+ slxsystem("mkdir -p $systemConfigPath/initramfs");
+ $result = 1;
+ }
+ if (!-e "$systemConfigPath/rootfs") {
+ slxsystem("mkdir -p $systemConfigPath/rootfs");
+ $result = 1;
+ }
+ return $result;
+}
+
+1;