diff options
Diffstat (limited to 'lib/OpenSLX')
-rw-r--r-- | lib/OpenSLX/Basics.pm | 13 | ||||
-rw-r--r-- | lib/OpenSLX/Utils.pm | 46 |
2 files changed, 54 insertions, 5 deletions
diff --git a/lib/OpenSLX/Basics.pm b/lib/OpenSLX/Basics.pm index 53103cef..80296e92 100644 --- a/lib/OpenSLX/Basics.pm +++ b/lib/OpenSLX/Basics.pm @@ -83,11 +83,14 @@ my $translations; # extended settings follow, which are only supported by slxsettings, # but not by any other script: # - 'db-user' => undef, - 'db-passwd' => undef, - 'default-shell' => 'bash', - 'default-timezone' => 'Europe/Berlin', - 'ossetup-max-try-count' => '5', + 'db-user' => undef, + 'db-passwd' => undef, + 'default-shell' => 'bash', + 'default-timezone' => 'Europe/Berlin', + 'mirrors-preferred-top-level-domain' => undef, + 'mirrors-to-try-count' => '20', + 'mirrors-to-use-count' => '5', + 'ossetup-max-try-count' => '5', ); chomp($openslxConfig{'locale-charmap'}); diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm index bc57078a..86c31ca9 100644 --- a/lib/OpenSLX/Utils.pm +++ b/lib/OpenSLX/Utils.pm @@ -30,12 +30,16 @@ $VERSION = 1.01; unshiftHereDoc string2Array chrootInto + mergeHash + getFQDN ); ################################################################################ ### Module implementation ################################################################################ use File::Basename; +use Socket; +use Sys::Hostname; use OpenSLX::Basics; @@ -230,4 +234,46 @@ sub chrootInto return; } +sub mergeHash +{ + my $targetHash = shift; + my $sourceHash = shift; + my $fillOnly = shift || 0; + + foreach my $key (keys %{$sourceHash}) { + my $sourceVal = $sourceHash->{$key}; + if (ref($sourceVal) eq 'HASH') { + if (!exists $targetHash->{$key}) { + $targetHash->{$key} = {}; + } + mergeHash($targetHash->{$key}, $sourceVal); + } + elsif (ref($sourceVal) eq 'ARRAY') { + if (!exists $targetHash->{$key}) { + $targetHash->{$key} = []; + } + foreach my $val (@{$sourceHash->{$key}}) { + my $targetVal = {}; + push @{$targetHash->{$key}}, $targetVal; + mergeHash($targetVal, $sourceVal); + } + } + else { + next if $fillOnly && exists $targetHash->{$key}; + $targetHash->{$key} = $sourceVal; + } + } +} + +sub getFQDN +{ + my $hostName = hostname(); + + my $hostAddr = gethostbyname($hostName) + or die(_tr("unable to get address of host '%s'", $hostName)); + my $FQDN = gethostbyaddr($hostAddr, AF_INET) + or die(_tr("unable to get dns-name of address '%s'", $hostAddr)); + return $FQDN; +} + 1; |