From a0ce0340d0f95514008cfac751fe58748bbadd88 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 20 Mar 2008 00:04:16 +0000 Subject: * Switched indent used in Perl-code and settings files from tabs to 4 spaces. May need some manual corrections here and there, but should basically be ok. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1658 95ad53e4-c205-0410-b2fa-d234c58c8868 --- os-plugins/OpenSLX/OSPlugin/Base.pm | 224 +++---- os-plugins/OpenSLX/OSPlugin/Engine.pm | 616 ++++++++--------- os-plugins/OpenSLX/OSPlugin/Roster.pm | 152 ++--- .../bootsplash/OpenSLX/OSPlugin/bootsplash.pm | 222 +++--- os-plugins/plugins/desktop/OpenSLX/Distro/Base.pm | 212 +++--- .../plugins/desktop/OpenSLX/Distro/debian.pm | 2 +- .../plugins/desktop/OpenSLX/Distro/fedora.pm | 28 +- .../plugins/desktop/OpenSLX/Distro/gentoo.pm | 50 +- os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm | 2 +- .../plugins/desktop/OpenSLX/Distro/ubuntu.pm | 2 +- .../plugins/desktop/OpenSLX/OSPlugin/desktop.pm | 746 ++++++++++----------- .../OpenSLX/OSPlugin/displaymanager.pm | 178 ++--- .../plugins/example/OpenSLX/OSPlugin/example.pm | 214 +++--- os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm | 302 ++++----- .../vmchooser/OpenSLX/OSPlugin/vmchooser.pm | 180 ++--- os-plugins/plugins/vmware/OpenSLX/Distro/base.pm | 14 +- .../vmwarebinary/OpenSLX/OSPlugin/vmwarebinary.pm | 160 ++--- .../plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm | 380 +++++------ os-plugins/slxos-plugin | 470 ++++++------- 19 files changed, 2077 insertions(+), 2077 deletions(-) (limited to 'os-plugins') diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm index 5da72f2a..cede0bce 100644 --- a/os-plugins/OpenSLX/OSPlugin/Base.pm +++ b/os-plugins/OpenSLX/OSPlugin/Base.pm @@ -9,14 +9,14 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # Base.pm -# - provides empty base of the OpenSLX OSPlugin API. +# - provides empty base of the OpenSLX OSPlugin API. # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::Base; use strict; use warnings; -our $VERSION = 1.01; # API-version . implementation-version +our $VERSION = 1.01; # API-version . implementation-version =head1 NAME @@ -79,7 +79,7 @@ Please note that by convention, plugin names are all lowercase! sub new { - confess "Creating OpenSLX::OSPlugin::Base-objects directly makes no sense!"; + confess "Creating OpenSLX::OSPlugin::Base-objects directly makes no sense!"; } =item initialize() @@ -91,12 +91,12 @@ engine that drives this plugin. sub initialize { - my $self = shift; + my $self = shift; - $self->{'os-plugin-engine'} = shift; - $self->{'distro'} = shift; - - return; + $self->{'os-plugin-engine'} = shift; + $self->{'distro'} = shift; + + return; } =item getInfo() @@ -109,12 +109,12 @@ this method and return the information about itself. sub getInfo { - my $self = shift; + my $self = shift; - return { - # a short (one-liner) description of this plugin - description => '', - }; + return { + # a short (one-liner) description of this plugin + description => '', + }; } =item getAttrInfo() @@ -143,20 +143,20 @@ Valid values range from 0-99. If your plugin does not have any requirements in this context, just specify the default value '50'. =back - + =cut sub getAttrInfo { - my $self = shift; - - # This default configuration will be added as attributes to the default - # system, such that it can be overruled for any specific system by means - # of slxconfig. - return { - # attribute 'active' is mandatory for all plugins - # attribute 'precedence' is mandatory for all plugins - }; + my $self = shift; + + # This default configuration will be added as attributes to the default + # system, such that it can be overruled for any specific system by means + # of slxconfig. + return { + # attribute 'active' is mandatory for all plugins + # attribute 'precedence' is mandatory for all plugins + }; } =item getDefaultAttrsForVendorOS() @@ -169,10 +169,10 @@ Returns a hash-ref with the default attribute values for the given vendor-OS. sub getDefaultAttrsForVendorOS { - my $self = shift; + my $self = shift; - # the default implementation does not change the default values at all: - return $self->getAttrInfo(); + # the default implementation does not change the default values at all: + return $self->getAttrInfo(); } =back @@ -199,15 +199,15 @@ any files from the host, fetch them from there. sub installationPhase { - my $self = shift; - my $pluginRepositoryPath = shift; - # the repository folder, relative to the vendor-OS root - my $pluginTempPath = shift; - # the temporary folder, relative to the vendor-OS root - my $openslxPath = shift; - # the openslx base path bind-mounted into the chroot (/mnt/openslx) - - return; + my $self = shift; + my $pluginRepositoryPath = shift; + # the repository folder, relative to the vendor-OS root + my $pluginTempPath = shift; + # the temporary folder, relative to the vendor-OS root + my $openslxPath = shift; + # the openslx base path bind-mounted into the chroot (/mnt/openslx) + + return; } =item removalPhase() @@ -224,15 +224,15 @@ N.B.: This method is invoked while chrooted into the vendor-OS root. sub removalPhase { - my $self = shift; - my $pluginRepositoryPath = shift; - # the repository folder, relative to the vendor-OS root - my $pluginTempPath = shift; - # the temporary folder, relative to the vendor-OS root - my $openslxPath = shift; - # the openslx base path bind-mounted into the chroot (/mnt/openslx) - - return; + my $self = shift; + my $pluginRepositoryPath = shift; + # the repository folder, relative to the vendor-OS root + my $pluginTempPath = shift; + # the temporary folder, relative to the vendor-OS root + my $openslxPath = shift; + # the openslx base path bind-mounted into the chroot (/mnt/openslx) + + return; } =back @@ -257,10 +257,10 @@ that it would like to see added. sub suggestAdditionalKernelParams { - my $self = shift; - my $makeInitRamFSEngine = shift; - - return; + my $self = shift; + my $makeInitRamFSEngine = shift; + + return; } =item suggestAdditionalKernelModules() @@ -270,15 +270,15 @@ requires. In order to do so, the plugin should return the names of additional kernel modules that it would like to see added. - + =cut sub suggestAdditionalKernelModules { - my $self = shift; - my $makeInitRamFSEngine = shift; - - return; + my $self = shift; + my $makeInitRamFSEngine = shift; + + return; } =item copyRequiredFilesIntoInitramfs() @@ -294,12 +294,12 @@ All other files should be taken from the root-fs instead! sub copyRequiredFilesIntoInitramfs { - my $self = shift; - my $targetPath = shift; - my $attrs = shift; - my $makeInitRamFSEngine = shift; - - return; + my $self = shift; + my $targetPath = shift; + my $attrs = shift; + my $makeInitRamFSEngine = shift; + + return; } =item setupPluginInInitramfs() @@ -315,59 +315,59 @@ suggestAdditionalKernelModules() and maybe copyRequiredFilesIntoInitramfs(). sub setupPluginInInitramfs { - my $self = shift; - my $attrs = shift; - my $makeInitRamFSEngine = shift; - - my $pluginName = $self->{name}; - my $pluginSrcPath = "$openslxConfig{'base-path'}/lib/plugins"; - my $buildPath = $makeInitRamFSEngine->{'build-path'}; - my $pluginInitdPath = "$buildPath/etc/plugin-init.d"; - my $initHooksPath = "$buildPath/etc/init-hooks"; - - # copy runlevel script - my $precedence - = sprintf('%02d', $attrs->{"${pluginName}::precedence"}); - my $scriptName = "$pluginSrcPath/$pluginName/XX_${pluginName}.sh"; - my $targetName = "$pluginInitdPath/${precedence}_${pluginName}.sh"; - if (-e $scriptName) { - $makeInitRamFSEngine->addCMD("cp $scriptName $targetName"); - $makeInitRamFSEngine->addCMD("chmod a+x $targetName"); - } - - # copy init hook scripts, if any - if (-d "$pluginSrcPath/$pluginName/init-hooks") { - my $hookSrcPath = "$pluginSrcPath/$pluginName/init-hooks"; - $makeInitRamFSEngine->addCMD( - "cp -r $hookSrcPath/* $buildPath/etc/init-hooks/" - ); - } - - # invoke hook methods to suggest additional kernel params ... - my @suggestedParams - = $self->suggestAdditionalKernelParams($makeInitRamFSEngine); - if (@suggestedParams) { - my $params = join ' ', @suggestedParams; - vlog(1, "plugin $pluginName suggests these kernel params: $params"); - $makeInitRamFSEngine->addKernelParams(@suggestedParams); - } - - # ... and kernel modules - my @suggestedModules - = $self->suggestAdditionalKernelModules($makeInitRamFSEngine); - if (@suggestedModules) { - my $modules = join(',', @suggestedModules); - vlog(1, "plugin $pluginName suggests these kernel modules: $modules"); - $makeInitRamFSEngine->addKernelModules(@suggestedModules); - } - - # invoke hook method to copy any further files that are required in stage3 - # before the root-fs has been mounted - $self->copyRequiredFilesIntoInitramfs( - $buildPath, $attrs, $makeInitRamFSEngine - ); - - return 1; + my $self = shift; + my $attrs = shift; + my $makeInitRamFSEngine = shift; + + my $pluginName = $self->{name}; + my $pluginSrcPath = "$openslxConfig{'base-path'}/lib/plugins"; + my $buildPath = $makeInitRamFSEngine->{'build-path'}; + my $pluginInitdPath = "$buildPath/etc/plugin-init.d"; + my $initHooksPath = "$buildPath/etc/init-hooks"; + + # copy runlevel script + my $precedence + = sprintf('%02d', $attrs->{"${pluginName}::precedence"}); + my $scriptName = "$pluginSrcPath/$pluginName/XX_${pluginName}.sh"; + my $targetName = "$pluginInitdPath/${precedence}_${pluginName}.sh"; + if (-e $scriptName) { + $makeInitRamFSEngine->addCMD("cp $scriptName $targetName"); + $makeInitRamFSEngine->addCMD("chmod a+x $targetName"); + } + + # copy init hook scripts, if any + if (-d "$pluginSrcPath/$pluginName/init-hooks") { + my $hookSrcPath = "$pluginSrcPath/$pluginName/init-hooks"; + $makeInitRamFSEngine->addCMD( + "cp -r $hookSrcPath/* $buildPath/etc/init-hooks/" + ); + } + + # invoke hook methods to suggest additional kernel params ... + my @suggestedParams + = $self->suggestAdditionalKernelParams($makeInitRamFSEngine); + if (@suggestedParams) { + my $params = join ' ', @suggestedParams; + vlog(1, "plugin $pluginName suggests these kernel params: $params"); + $makeInitRamFSEngine->addKernelParams(@suggestedParams); + } + + # ... and kernel modules + my @suggestedModules + = $self->suggestAdditionalKernelModules($makeInitRamFSEngine); + if (@suggestedModules) { + my $modules = join(',', @suggestedModules); + vlog(1, "plugin $pluginName suggests these kernel modules: $modules"); + $makeInitRamFSEngine->addKernelModules(@suggestedModules); + } + + # invoke hook method to copy any further files that are required in stage3 + # before the root-fs has been mounted + $self->copyRequiredFilesIntoInitramfs( + $buildPath, $attrs, $makeInitRamFSEngine + ); + + return 1; } =back diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm index 344bfdb9..5469a98d 100644 --- a/os-plugins/OpenSLX/OSPlugin/Engine.pm +++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # Engine.pm -# - provides driver engine for the OSPlugin API. +# - provides driver engine for the OSPlugin API. # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::Engine; @@ -49,11 +49,11 @@ Trivial constructor sub new { - my $class = shift; + my $class = shift; - my $self = {}; + my $self = {}; - return bless $self, $class; + return bless $self, $class; } =item initialize($pluginName, $vendorOSName ) @@ -65,69 +65,69 @@ loads plugin. sub initialize { - my $self = shift; - my $pluginName = shift; - my $vendorOSName = shift; - my $givenAttrs = shift || {}; - - $self->{'vendor-os-name'} = $vendorOSName; - - $self->{'vendor-os-path'} - = "$openslxConfig{'private-path'}/stage1/$vendorOSName"; - vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'"); - - if ($pluginName) { - $self->{'plugin-name'} = $pluginName; - $self->{'plugin-path'} - = "$openslxConfig{'base-path'}/lib/plugins/$pluginName"; - vlog(1, "plugin path is '$self->{'plugin-path'}'"); - - # create ossetup-engine for given vendor-OS: - my $osSetupEngine = OpenSLX::OSSetup::Engine->new; - $osSetupEngine->initialize($self->{'vendor-os-name'}, 'plugin'); - $self->{'ossetup-engine'} = $osSetupEngine; - - $self->{'plugin'} = $self->_loadPlugin(); - return if !$self->{'plugin'}; - - $self->{'chrooted-plugin-repo-path'} - = "$openslxConfig{'base-path'}/plugin-repo/$self->{'plugin-name'}"; - $self->{'plugin-repo-path'} - = "$self->{'vendor-os-path'}/$self->{'chrooted-plugin-repo-path'}"; - $self->{'chrooted-plugin-temp-path'} - = "/tmp/slx-plugin/$self->{'plugin-name'}"; - $self->{'plugin-temp-path'} - = "$self->{'vendor-os-path'}/$self->{'chrooted-plugin-temp-path'}"; - $self->{'chrooted-openslx-base-path'} = '/mnt/openslx'; - - # check and store given attribute set - my $knownAttrs = $self->{plugin}->getAttrInfo(); - my @unknownAttrs - = grep { !exists $knownAttrs->{$_} } keys %$givenAttrs; - if (@unknownAttrs) { - die _tr( - "The plugin '%s' does not support these attributes:\n\t%s", - $pluginName, join(',', @unknownAttrs) - ); - } - - # merge attributes that were given on cmdline with the ones that - # already exist in the DB and finally with the default values - $self->{'plugin-attrs'} = { %$givenAttrs }; - my $defaultAttrs = $self->{plugin}->getDefaultAttrsForVendorOS( - $vendorOSName - ); - my $dbAttrs = $self->_fetchInstalledPluginAttrs($vendorOSName); - for my $attrName (keys %$defaultAttrs) { - next if exists $givenAttrs->{$attrName}; - $self->{'plugin-attrs'}->{$attrName} - = exists $dbAttrs->{$attrName} - ? $dbAttrs->{$attrName} - : $defaultAttrs->{$attrName}->{default}; - } - } - - return 1; + my $self = shift; + my $pluginName = shift; + my $vendorOSName = shift; + my $givenAttrs = shift || {}; + + $self->{'vendor-os-name'} = $vendorOSName; + + $self->{'vendor-os-path'} + = "$openslxConfig{'private-path'}/stage1/$vendorOSName"; + vlog(1, "vendor-OS path is '$self->{'vendor-os-path'}'"); + + if ($pluginName) { + $self->{'plugin-name'} = $pluginName; + $self->{'plugin-path'} + = "$openslxConfig{'base-path'}/lib/plugins/$pluginName"; + vlog(1, "plugin path is '$self->{'plugin-path'}'"); + + # create ossetup-engine for given vendor-OS: + my $osSetupEngine = OpenSLX::OSSetup::Engine->new; + $osSetupEngine->initialize($self->{'vendor-os-name'}, 'plugin'); + $self->{'ossetup-engine'} = $osSetupEngine; + + $self->{'plugin'} = $self->_loadPlugin(); + return if !$self->{'plugin'}; + + $self->{'chrooted-plugin-repo-path'} + = "$openslxConfig{'base-path'}/plugin-repo/$self->{'plugin-name'}"; + $self->{'plugin-repo-path'} + = "$self->{'vendor-os-path'}/$self->{'chrooted-plugin-repo-path'}"; + $self->{'chrooted-plugin-temp-path'} + = "/tmp/slx-plugin/$self->{'plugin-name'}"; + $self->{'plugin-temp-path'} + = "$self->{'vendor-os-path'}/$self->{'chrooted-plugin-temp-path'}"; + $self->{'chrooted-openslx-base-path'} = '/mnt/openslx'; + + # check and store given attribute set + my $knownAttrs = $self->{plugin}->getAttrInfo(); + my @unknownAttrs + = grep { !exists $knownAttrs->{$_} } keys %$givenAttrs; + if (@unknownAttrs) { + die _tr( + "The plugin '%s' does not support these attributes:\n\t%s", + $pluginName, join(',', @unknownAttrs) + ); + } + + # merge attributes that were given on cmdline with the ones that + # already exist in the DB and finally with the default values + $self->{'plugin-attrs'} = { %$givenAttrs }; + my $defaultAttrs = $self->{plugin}->getDefaultAttrsForVendorOS( + $vendorOSName + ); + my $dbAttrs = $self->_fetchInstalledPluginAttrs($vendorOSName); + for my $attrName (keys %$defaultAttrs) { + next if exists $givenAttrs->{$attrName}; + $self->{'plugin-attrs'}->{$attrName} + = exists $dbAttrs->{$attrName} + ? $dbAttrs->{$attrName} + : $defaultAttrs->{$attrName}->{default}; + } + } + + return 1; } =back @@ -148,51 +148,51 @@ the plugin's installer method while chrooted into that vendor-OS. sub installPlugin { - my $self = shift; - - if ($self->{'vendor-os-name'} ne '<<>>') { - - # as the attrs may be changed by the plugin during installation, we - # have to find a way to pass them back to this process (remember; - # installation takes place in a forked process in order to do a chroot). - # We simply serialize the attributes into a temp and deserialize it - # in the calling process. - my $serializedAttrsFile - = "$self->{'plugin-temp-path'}/serialized-attrs"; - my $chrootedSerializedAttrsFile - = "$self->{'chrooted-plugin-temp-path'}/serialized-attrs"; - - mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]); - - # HACK: do a dummy serialization here in order to get Storable - # completely loaded (otherwise it will complain in the chroot about - # missing modules). - store $self->{'plugin-attrs'}, $serializedAttrsFile; - - $self->_callChrootedFunctionForPlugin( - sub { - # invoke plugin and let it install itself into vendor-OS - $self->{plugin}->installationPhase( - $self->{'chrooted-plugin-repo-path'}, - $self->{'chrooted-plugin-temp-path'}, - $self->{'chrooted-openslx-base-path'}, - $self->{'plugin-attrs'}, - ); - - # serialize possibly changed attributes (executed inside chroot) - store $self->{'plugin-attrs'}, $chrootedSerializedAttrsFile; - } - ); - - # now retrieve (deserialize) the current attributes and store them - $self->{'plugin-attrs'} = retrieve $serializedAttrsFile; - $self->_addInstalledPluginToDB(); - - # cleanup temp path - rmtree([ $self->{'plugin-temp-path'} ]); - } - - return 1; + my $self = shift; + + if ($self->{'vendor-os-name'} ne '<<>>') { + + # as the attrs may be changed by the plugin during installation, we + # have to find a way to pass them back to this process (remember; + # installation takes place in a forked process in order to do a chroot). + # We simply serialize the attributes into a temp and deserialize it + # in the calling process. + my $serializedAttrsFile + = "$self->{'plugin-temp-path'}/serialized-attrs"; + my $chrootedSerializedAttrsFile + = "$self->{'chrooted-plugin-temp-path'}/serialized-attrs"; + + mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]); + + # HACK: do a dummy serialization here in order to get Storable + # completely loaded (otherwise it will complain in the chroot about + # missing modules). + store $self->{'plugin-attrs'}, $serializedAttrsFile; + + $self->_callChrootedFunctionForPlugin( + sub { + # invoke plugin and let it install itself into vendor-OS + $self->{plugin}->installationPhase( + $self->{'chrooted-plugin-repo-path'}, + $self->{'chrooted-plugin-temp-path'}, + $self->{'chrooted-openslx-base-path'}, + $self->{'plugin-attrs'}, + ); + + # serialize possibly changed attributes (executed inside chroot) + store $self->{'plugin-attrs'}, $chrootedSerializedAttrsFile; + } + ); + + # now retrieve (deserialize) the current attributes and store them + $self->{'plugin-attrs'} = retrieve $serializedAttrsFile; + $self->_addInstalledPluginToDB(); + + # cleanup temp path + rmtree([ $self->{'plugin-temp-path'} ]); + } + + return 1; } =item removePlugin() @@ -204,28 +204,28 @@ the plugin's removal method while chrooted into that vendor-OS. sub removePlugin { - my $self = shift; + my $self = shift; - if ($self->{'vendor-os-name'} ne '<<>>') { + if ($self->{'vendor-os-name'} ne '<<>>') { - mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]); + mkpath([ $self->{'plugin-repo-path'}, $self->{'plugin-temp-path'} ]); - $self->_callChrootedFunctionForPlugin( - sub { - $self->{plugin}->removalPhase( - $self->{'chrooted-plugin-repo-path'}, - $self->{'chrooted-plugin-temp-path'}, - $self->{'chrooted-openslx-base-path'}, - ); - } - ); + $self->_callChrootedFunctionForPlugin( + sub { + $self->{plugin}->removalPhase( + $self->{'chrooted-plugin-repo-path'}, + $self->{'chrooted-plugin-temp-path'}, + $self->{'chrooted-openslx-base-path'}, + ); + } + ); - rmtree([ $self->{'plugin-temp-path'} ]); - } - - $self->_removeInstalledPluginFromDB(); + rmtree([ $self->{'plugin-temp-path'} ]); + } + + $self->_removeInstalledPluginFromDB(); - return 1; + return 1; } =item getInstalledPlugins() @@ -237,22 +237,22 @@ vendor-OS. sub getInstalledPlugins { - my $self = shift; - - my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); - $openslxDB->connect(); - my $vendorOS = $openslxDB->fetchVendorOSByFilter( { - name => $self->{'vendor-os-name'}, - } ); - if (!$vendorOS) { - die _tr( - 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'} - ); - } - my @installedPlugins = $openslxDB->fetchInstalledPlugins($vendorOS->{id}); - $openslxDB->disconnect(); - - return @installedPlugins; + my $self = shift; + + my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); + $openslxDB->connect(); + my $vendorOS = $openslxDB->fetchVendorOSByFilter( { + name => $self->{'vendor-os-name'}, + } ); + if (!$vendorOS) { + die _tr( + 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'} + ); + } + my @installedPlugins = $openslxDB->fetchInstalledPlugins($vendorOS->{id}); + $openslxDB->disconnect(); + + return @installedPlugins; } =back @@ -275,9 +275,9 @@ Returns the name of the current vendor-OS. sub vendorOSName { - my $self = shift; + my $self = shift; - return $self->{'vendor-os-name'}; + return $self->{'vendor-os-name'}; } =item distroName() @@ -291,9 +291,9 @@ distro version, like 'suse-10.2' or 'ubuntu-7.04'. sub distroName { - my $self = shift; + my $self = shift; - return $self->{'ossetup-engine'}->distroName(); + return $self->{'ossetup-engine'}->distroName(); } =item downloadFile($fileURL, $targetPath, $wgetOptions) @@ -325,18 +325,18 @@ If the downloaded was successful this method returns C<1>, otherwise it dies. sub downloadFile { - my $self = shift; - my $fileURL = shift || return; - my $targetPath = shift || $self->{'chrooted-plugin-temp-path'}; - my $wgetOptions = shift || ''; - - my $busybox = $self->{'ossetup-engine'}->busyboxBinary(); - - if (slxsystem("$busybox wget -P $targetPath $wgetOptions $fileURL")) { - die _tr('unable to download file "%s"! (%s)', $fileURL, $!); - } - - return 1; + my $self = shift; + my $fileURL = shift || return; + my $targetPath = shift || $self->{'chrooted-plugin-temp-path'}; + my $wgetOptions = shift || ''; + + my $busybox = $self->{'ossetup-engine'}->busyboxBinary(); + + if (slxsystem("$busybox wget -P $targetPath $wgetOptions $fileURL")) { + die _tr('unable to download file "%s"! (%s)', $fileURL, $!); + } + + return 1; } =item getInstalledPackages() @@ -350,12 +350,12 @@ install additional packages. sub getInstalledPackages { - my $self = shift; + my $self = shift; - my $metaPackager = $self->{'ossetup-engine'}->metaPackager(); - return if !$metaPackager; + my $metaPackager = $self->{'ossetup-engine'}->metaPackager(); + return if !$metaPackager; - return $metaPackager->getInstalledPackages(); + return $metaPackager->getInstalledPackages(); } =item getInstallablePackagesForSelection() @@ -368,12 +368,12 @@ to complete the selection. sub getInstallablePackagesForSelection { - my $self = shift; - my $selection = shift; + my $self = shift; + my $selection = shift; - return $self->{'ossetup-engine'}->getInstallablePackagesForSelection( - $selection - ); + return $self->{'ossetup-engine'}->getInstallablePackagesForSelection( + $selection + ); } @@ -401,15 +401,15 @@ otherwise it dies. sub installPackages { - my $self = shift; - my $packages = shift; + my $self = shift; + my $packages = shift; - return if !$packages; + return if !$packages; - my $metaPackager = $self->{'ossetup-engine'}->metaPackager(); - return if !$metaPackager; + my $metaPackager = $self->{'ossetup-engine'}->metaPackager(); + return if !$metaPackager; - return $metaPackager->installPackages($packages); + return $metaPackager->installPackages($packages); } =item removePackages($packages) @@ -433,15 +433,15 @@ otherwise it dies. sub removePackages { - my $self = shift; - my $packages = shift; + my $self = shift; + my $packages = shift; - return if !$packages; + return if !$packages; - my $metaPackager = $self->{'ossetup-engine'}->metaPackager(); - return if !$metaPackager; + my $metaPackager = $self->{'ossetup-engine'}->metaPackager(); + return if !$metaPackager; - return $metaPackager->removePackages($packages); + return $metaPackager->removePackages($packages); } =back @@ -450,148 +450,148 @@ sub removePackages sub _loadPlugin { - my $self = shift; - - my $pluginModule = "OpenSLX::OSPlugin::$self->{'plugin-name'}"; - my $plugin = instantiateClass( - $pluginModule, { pathToClass => $self->{'plugin-path'} } - ); - return if !$plugin; - - # if there's a distro folder, instantiate the most appropriate distro class - my $distro; - if (-d "$self->{'plugin-path'}/OpenSLX/Distro") { - unshift @INC, $self->{'plugin-path'}; - my $distroName = $self->distroName(); - $distroName =~ tr{.-}{__}; - my @distroModules; - while($distroName =~ m{^(.+)_[^_]*$}) { - push @distroModules, $distroName; - $distroName = $1; - } - push @distroModules, $distroName; - push @distroModules, 'Base'; - for my $distroModule (@distroModules) { - last if eval { - $distro = instantiateClass( - 'OpenSLX::Distro::' . $distroModule, - { pathToClass => $self->{'plugin-path'} } - ); - 1; - }; - } - shift @INC; - if (!$distro) { - die _tr( - 'unable to load any distro module for vendor-OS %s', - $self->{'vendor-os-name'} - ); - } - $distro->initialize($self); - } - - $plugin->initialize($self, $distro); - - return $plugin; + my $self = shift; + + my $pluginModule = "OpenSLX::OSPlugin::$self->{'plugin-name'}"; + my $plugin = instantiateClass( + $pluginModule, { pathToClass => $self->{'plugin-path'} } + ); + return if !$plugin; + + # if there's a distro folder, instantiate the most appropriate distro class + my $distro; + if (-d "$self->{'plugin-path'}/OpenSLX/Distro") { + unshift @INC, $self->{'plugin-path'}; + my $distroName = $self->distroName(); + $distroName =~ tr{.-}{__}; + my @distroModules; + while($distroName =~ m{^(.+)_[^_]*$}) { + push @distroModules, $distroName; + $distroName = $1; + } + push @distroModules, $distroName; + push @distroModules, 'Base'; + for my $distroModule (@distroModules) { + last if eval { + $distro = instantiateClass( + 'OpenSLX::Distro::' . $distroModule, + { pathToClass => $self->{'plugin-path'} } + ); + 1; + }; + } + shift @INC; + if (!$distro) { + die _tr( + 'unable to load any distro module for vendor-OS %s', + $self->{'vendor-os-name'} + ); + } + $distro->initialize($self); + } + + $plugin->initialize($self, $distro); + + return $plugin; } sub _callChrootedFunctionForPlugin { - my $self = shift; - my $function = shift; - - # bind-mount openslx basepath to /mnt/openslx of vendor-OS: - my $basePath = $openslxConfig{'base-path'}; - my $openslxPathInChroot = "$self->{'vendor-os-path'}/mnt/openslx"; - mkpath( [ $openslxPathInChroot ] ); - if (slxsystem("mount -o bind $basePath $openslxPathInChroot")) { - croak( - _tr( - "unable to bind mount '%s' to '%s'! (%s)", - $basePath, $openslxPathInChroot, $! - ) - ); - } - - # now let plugin install itself into vendor-OS - my $ok = eval { - $self->{'ossetup-engine'}->callChrootedFunctionForVendorOS($function); - }; - - if (slxsystem("umount $openslxPathInChroot")) { - croak(_tr("unable to umount '%s'! (%s)", $openslxPathInChroot, $!)); - } - - if (!$ok) { - die $@; - } - - return; + my $self = shift; + my $function = shift; + + # bind-mount openslx basepath to /mnt/openslx of vendor-OS: + my $basePath = $openslxConfig{'base-path'}; + my $openslxPathInChroot = "$self->{'vendor-os-path'}/mnt/openslx"; + mkpath( [ $openslxPathInChroot ] ); + if (slxsystem("mount -o bind $basePath $openslxPathInChroot")) { + croak( + _tr( + "unable to bind mount '%s' to '%s'! (%s)", + $basePath, $openslxPathInChroot, $! + ) + ); + } + + # now let plugin install itself into vendor-OS + my $ok = eval { + $self->{'ossetup-engine'}->callChrootedFunctionForVendorOS($function); + }; + + if (slxsystem("umount $openslxPathInChroot")) { + croak(_tr("unable to umount '%s'! (%s)", $openslxPathInChroot, $!)); + } + + if (!$ok) { + die $@; + } + + return; } sub _addInstalledPluginToDB { - my $self = shift; - - my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); - $openslxDB->connect(); - my $vendorOS = $openslxDB->fetchVendorOSByFilter( { - name => $self->{'vendor-os-name'}, - } ); - if (!$vendorOS) { - die _tr( - 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'} - ); - } - $openslxDB->addInstalledPlugin( - $vendorOS->{id}, $self->{'plugin-name'}, $self->{'plugin-attrs'} - ); - $openslxDB->disconnect(); - - return 1; + my $self = shift; + + my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); + $openslxDB->connect(); + my $vendorOS = $openslxDB->fetchVendorOSByFilter( { + name => $self->{'vendor-os-name'}, + } ); + if (!$vendorOS) { + die _tr( + 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'} + ); + } + $openslxDB->addInstalledPlugin( + $vendorOS->{id}, $self->{'plugin-name'}, $self->{'plugin-attrs'} + ); + $openslxDB->disconnect(); + + return 1; } sub _fetchInstalledPluginAttrs { - my $self = shift; - - my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); - $openslxDB->connect(); - my $vendorOS = $openslxDB->fetchVendorOSByFilter( { - name => $self->{'vendor-os-name'}, - } ); - if (!$vendorOS) { - die _tr( - 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'} - ); - } - my $installedPlugin = $openslxDB->fetchInstalledPlugins( - $vendorOS->{id}, $self->{'plugin-name'} - ); - $openslxDB->disconnect(); - - return {} if !$installedPlugin; - return $installedPlugin->{attrs}; + my $self = shift; + + my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); + $openslxDB->connect(); + my $vendorOS = $openslxDB->fetchVendorOSByFilter( { + name => $self->{'vendor-os-name'}, + } ); + if (!$vendorOS) { + die _tr( + 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'} + ); + } + my $installedPlugin = $openslxDB->fetchInstalledPlugins( + $vendorOS->{id}, $self->{'plugin-name'} + ); + $openslxDB->disconnect(); + + return {} if !$installedPlugin; + return $installedPlugin->{attrs}; } sub _removeInstalledPluginFromDB { - my $self = shift; - - my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); - $openslxDB->connect(); - my $vendorOS = $openslxDB->fetchVendorOSByFilter( { - name => $self->{'vendor-os-name'}, - } ); - if (!$vendorOS) { - die _tr( - 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'} - ); - } - $openslxDB->removeInstalledPlugin($vendorOS->{id}, $self->{'plugin-name'}); - $openslxDB->disconnect(); - - return 1; + my $self = shift; + + my $openslxDB = instantiateClass("OpenSLX::ConfigDB"); + $openslxDB->connect(); + my $vendorOS = $openslxDB->fetchVendorOSByFilter( { + name => $self->{'vendor-os-name'}, + } ); + if (!$vendorOS) { + die _tr( + 'unable to find vendor-OS "%s" in DB!', $self->{'vendor-os-name'} + ); + } + $openslxDB->removeInstalledPlugin($vendorOS->{id}, $self->{'plugin-name'}); + $openslxDB->disconnect(); + + return 1; } 1; diff --git a/os-plugins/OpenSLX/OSPlugin/Roster.pm b/os-plugins/OpenSLX/OSPlugin/Roster.pm index a8df3b38..023abb4c 100644 --- a/os-plugins/OpenSLX/OSPlugin/Roster.pm +++ b/os-plugins/OpenSLX/OSPlugin/Roster.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # OSPlugin::Roster.pm -# - provides information about all available plugins +# - provides information about all available plugins # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::Roster; @@ -29,15 +29,15 @@ Returns a hash that keys the names of available plugins to their info hash. sub getAvailablePlugins { - my $class = shift; + my $class = shift; - $class->_init() if !%plugins; + $class->_init() if !%plugins; - my %pluginInfo; - foreach my $pluginName (keys %plugins) { - $pluginInfo{$pluginName} = $plugins{$pluginName}->getInfo(); - } - return \%pluginInfo; + my %pluginInfo; + foreach my $pluginName (keys %plugins) { + $pluginInfo{$pluginName} = $plugins{$pluginName}->getInfo(); + } + return \%pluginInfo; } =item C @@ -48,15 +48,15 @@ Returns an instance of the plugin with the given name sub getPlugin { - my $class = shift; - my $pluginName = shift; + my $class = shift; + my $pluginName = shift; - $class->_init() if !%plugins; + $class->_init() if !%plugins; - my $plugin = $plugins{$pluginName}; - return if !$plugin; + my $plugin = $plugins{$pluginName}; + return if !$plugin; - return dclone($plugin); + return dclone($plugin); } =item C @@ -68,14 +68,14 @@ given plugin sub getPluginAttrInfo { - my $class = shift; - my $pluginName = shift; + my $class = shift; + my $pluginName = shift; - $class->_init() if !%plugins; + $class->_init() if !%plugins; - return if !$plugins{$pluginName}; + return if !$plugins{$pluginName}; - return $plugins{$pluginName}->getAttrInfo(); + return $plugins{$pluginName}->getAttrInfo(); } =item C @@ -98,11 +98,11 @@ added. sub addAllAttributesToHash { - my $class = shift; - my $attrInfo = shift; - my $pluginName = shift; + my $class = shift; + my $attrInfo = shift; + my $pluginName = shift; - return $class->_addAttributesToHash($attrInfo, $pluginName, sub { 1 } ); + return $class->_addAttributesToHash($attrInfo, $pluginName, sub { 1 } ); } =item C @@ -125,14 +125,14 @@ added. sub addAllStage1AttributesToHash { - my $class = shift; - my $attrInfo = shift; - my $pluginName = shift; - - return $class->_addAttributesToHash($attrInfo, $pluginName, sub { - my $attr = shift; - return $attr->{applies_to_vendor_os}; - } ); + my $class = shift; + my $attrInfo = shift; + my $pluginName = shift; + + return $class->_addAttributesToHash($attrInfo, $pluginName, sub { + my $attr = shift; + return $attr->{applies_to_vendor_os}; + } ); } =item C @@ -155,59 +155,59 @@ added. sub addAllStage3AttributesToHash { - my $class = shift; - my $attrInfo = shift; - my $pluginName = shift; - - return $class->_addAttributesToHash($attrInfo, $pluginName, sub { - my $attr = shift; - return $attr->{applies_to_systems} || $attr->{applies_to_clients}; - } ); + my $class = shift; + my $attrInfo = shift; + my $pluginName = shift; + + return $class->_addAttributesToHash($attrInfo, $pluginName, sub { + my $attr = shift; + return $attr->{applies_to_systems} || $attr->{applies_to_clients}; + } ); } sub _addAttributesToHash { - my $class = shift; - my $attrInfo = shift; - my $pluginName = shift; - my $testFunc = shift; - - $class->_init() if !%plugins; - - foreach my $plugin (values %plugins) { - next if $pluginName && $plugin->{name} ne $pluginName; - my $pluginAttrInfo = $plugin->getAttrInfo(); - foreach my $attr (keys %$pluginAttrInfo) { - next if !$testFunc->($pluginAttrInfo->{$attr}); - $attrInfo->{$attr} = dclone($pluginAttrInfo->{$attr}); - } - } - return 1; + my $class = shift; + my $attrInfo = shift; + my $pluginName = shift; + my $testFunc = shift; + + $class->_init() if !%plugins; + + foreach my $plugin (values %plugins) { + next if $pluginName && $plugin->{name} ne $pluginName; + my $pluginAttrInfo = $plugin->getAttrInfo(); + foreach my $attr (keys %$pluginAttrInfo) { + next if !$testFunc->($pluginAttrInfo->{$attr}); + $attrInfo->{$attr} = dclone($pluginAttrInfo->{$attr}); + } + } + return 1; } sub _init { - my $class = shift; - - %plugins = (); - my $pluginPath = "$openslxConfig{'base-path'}/lib/plugins"; - foreach my $modulePath (glob("$pluginPath/*")) { - next if $modulePath !~ m{/([^/]+)$}; - my $pluginName = $1; - if (!-e "$modulePath/OpenSLX/OSPlugin/$pluginName.pm") { - vlog( - 1, - "skipped plugin-folder $modulePath as no corresponding perl " - . "module could be found." - ); - next; - } - my $class = "OpenSLX::OSPlugin::$pluginName"; - vlog(2, "loading plugin $class from path '$modulePath'"); - my $plugin = instantiateClass($class, { pathToClass => $modulePath }); - $plugins{$pluginName} = $plugin; - } - return; + my $class = shift; + + %plugins = (); + my $pluginPath = "$openslxConfig{'base-path'}/lib/plugins"; + foreach my $modulePath (glob("$pluginPath/*")) { + next if $modulePath !~ m{/([^/]+)$}; + my $pluginName = $1; + if (!-e "$modulePath/OpenSLX/OSPlugin/$pluginName.pm") { + vlog( + 1, + "skipped plugin-folder $modulePath as no corresponding perl " + . "module could be found." + ); + next; + } + my $class = "OpenSLX::OSPlugin::$pluginName"; + vlog(2, "loading plugin $class from path '$modulePath'"); + my $plugin = instantiateClass($class, { pathToClass => $modulePath }); + $plugins{$pluginName} = $plugin; + } + return; } 1; diff --git a/os-plugins/plugins/bootsplash/OpenSLX/OSPlugin/bootsplash.pm b/os-plugins/plugins/bootsplash/OpenSLX/OSPlugin/bootsplash.pm index 16345136..55e557f3 100644 --- a/os-plugins/plugins/bootsplash/OpenSLX/OSPlugin/bootsplash.pm +++ b/os-plugins/plugins/bootsplash/OpenSLX/OSPlugin/bootsplash.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # bootsplash.pm -# - implementation of the 'bootsplash' plugin, which installs splashy +# - implementation of the 'bootsplash' plugin, which installs splashy # into the ramfs, including changeing theme # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::bootsplash; @@ -24,138 +24,138 @@ use OpenSLX::Utils; sub new { - my $class = shift; + my $class = shift; - my $self = { - name => 'bootsplash', - }; + my $self = { + name => 'bootsplash', + }; - return bless $self, $class; + return bless $self, $class; } sub getInfo { - my $self = shift; - - return { - description => unshiftHereDoc(<<' End-of-Here'), - Installs Splashy as bootsplash into ramfs and sets a Theme. - End-of-Here - mustRunAfter => [], - }; + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + Installs Splashy as bootsplash into ramfs and sets a Theme. + End-of-Here + mustRunAfter => [], + }; } sub getAttrInfo { - my $self = shift; - - return { - 'bootsplash::active' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'bootsplash'-plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - 'bootsplash::precedence' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - the execution precedence of the 'bootsplash' plugin - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'allowed range is from 01-99', - default => 30, - }, - - 'bootsplash::theme' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - name of the theme to apply to bootsplash (unset for no theme) - End-of-Here - content_regex => undef, - content_descr => undef, - default => 'openslx', - }, - }; + my $self = shift; + + return { + 'bootsplash::active' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'bootsplash'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + 'bootsplash::precedence' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'bootsplash' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 30, + }, + + 'bootsplash::theme' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to bootsplash (unset for no theme) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'openslx', + }, + }; } sub suggestAdditionalKernelParams { - my $self = shift; - my $makeInitRamFSEngine = shift; - - my @suggestedParams; - - # add vga=0x317 unless explicit vga-mode is already set - if (!$makeInitRamFSEngine->haveKernelParam(qr{\bvga=})) { - push @suggestedParams, 'vga=0x317'; - } - - # add quiet, if not already set - if (!$makeInitRamFSEngine->haveKernelParam('quiet')) { - push @suggestedParams, 'quiet'; - } - - return @suggestedParams; + my $self = shift; + my $makeInitRamFSEngine = shift; + + my @suggestedParams; + + # add vga=0x317 unless explicit vga-mode is already set + if (!$makeInitRamFSEngine->haveKernelParam(qr{\bvga=})) { + push @suggestedParams, 'vga=0x317'; + } + + # add quiet, if not already set + if (!$makeInitRamFSEngine->haveKernelParam('quiet')) { + push @suggestedParams, 'quiet'; + } + + return @suggestedParams; } sub suggestAdditionalKernelModules { - my $self = shift; - my $makeInitRamFSEngine = shift; - - my @suggestedModules; - - # Ubuntu needs vesafb and fbcon (which drags along some others) - if ($makeInitRamFSEngine->{'distro-name'} =~ m{^ubuntu}i) { - push @suggestedModules, qw( vesafb fbcon ) - } - - return @suggestedModules; + my $self = shift; + my $makeInitRamFSEngine = shift; + + my @suggestedModules; + + # Ubuntu needs vesafb and fbcon (which drags along some others) + if ($makeInitRamFSEngine->{'distro-name'} =~ m{^ubuntu}i) { + push @suggestedModules, qw( vesafb fbcon ) + } + + return @suggestedModules; } sub copyRequiredFilesIntoInitramfs { - my $self = shift; - my $targetPath = shift; - my $attrs = shift; - my $makeInitRamFSEngine = shift; - - my $themeDir = "$openslxConfig{'base-path'}/share/themes"; - my $bootsplashTheme = $attrs->{'bootsplash::theme'} || ''; - if ($bootsplashTheme) { - my $bootsplashThemeDir = "$themeDir/$bootsplashTheme/bootsplash"; - if (-d $bootsplashThemeDir) { - my $splashyPath = "$openslxConfig{'base-path'}/share/splashy"; - $makeInitRamFSEngine->addCMD( - "cp -p $splashyPath/* $targetPath/bin/" - ); - $makeInitRamFSEngine->addCMD( - "mkdir -p $targetPath/etc/splashy" - ); - $makeInitRamFSEngine->addCMD( - "cp -a $bootsplashThemeDir/* $targetPath/etc/splashy/" - ); - } - } - else { - $bootsplashTheme = ''; - } - - vlog( - 1, - _tr( - "bootsplash-plugin: bootsplash=%s", - $bootsplashTheme - ) - ); - - return; + my $self = shift; + my $targetPath = shift; + my $attrs = shift; + my $makeInitRamFSEngine = shift; + + my $themeDir = "$openslxConfig{'base-path'}/share/themes"; + my $bootsplashTheme = $attrs->{'bootsplash::theme'} || ''; + if ($bootsplashTheme) { + my $bootsplashThemeDir = "$themeDir/$bootsplashTheme/bootsplash"; + if (-d $bootsplashThemeDir) { + my $splashyPath = "$openslxConfig{'base-path'}/share/splashy"; + $makeInitRamFSEngine->addCMD( + "cp -p $splashyPath/* $targetPath/bin/" + ); + $makeInitRamFSEngine->addCMD( + "mkdir -p $targetPath/etc/splashy" + ); + $makeInitRamFSEngine->addCMD( + "cp -a $bootsplashThemeDir/* $targetPath/etc/splashy/" + ); + } + } + else { + $bootsplashTheme = ''; + } + + vlog( + 1, + _tr( + "bootsplash-plugin: bootsplash=%s", + $bootsplashTheme + ) + ); + + return; } 1; diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/Base.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/Base.pm index 37cfff46..3764de39 100644 --- a/os-plugins/plugins/desktop/OpenSLX/Distro/Base.pm +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/Base.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # base.pm -# - provides empty base of the OpenSLX OSPlugin Distro API for the desktop +# - provides empty base of the OpenSLX OSPlugin Distro API for the desktop # plugin. # ----------------------------------------------------------------------------- package OpenSLX::Distro::Base; @@ -17,7 +17,7 @@ package OpenSLX::Distro::Base; use strict; use warnings; -our $VERSION = 1.01; # API-version . implementation-version +our $VERSION = 1.01; # API-version . implementation-version use OpenSLX::Basics; use OpenSLX::Utils; @@ -27,204 +27,204 @@ use OpenSLX::Utils; ################################################################################ sub new { - my $class = shift; - my $self = {}; - return bless $self, $class; + my $class = shift; + my $self = {}; + return bless $self, $class; } sub initialize { - my $self = shift; - $self->{engine} = shift; - - return 1; + my $self = shift; + $self->{engine} = shift; + + return 1; } sub isInPath { - my $self = shift; - my $binary = shift; - - my $path = qx{which $binary 2>/dev/null}; + my $self = shift; + my $binary = shift; + + my $path = qx{which $binary 2>/dev/null}; - return $path ? 1 : 0; + return $path ? 1 : 0; } sub isGNOMEInstalled { - my $self = shift; + my $self = shift; - return $self->isInPath('gnome-session'); + return $self->isInPath('gnome-session'); } sub isGDMInstalled { - my $self = shift; + my $self = shift; - return $self->isInPath('gdm'); + return $self->isInPath('gdm'); } sub installGNOME { - my $self = shift; + my $self = shift; - $self->{engine}->installPackages( - $self->{engine}->getInstallablePackagesForSelection('gnome') - ); + $self->{engine}->installPackages( + $self->{engine}->getInstallablePackagesForSelection('gnome') + ); - return 1; + return 1; } sub installGDM { - my $self = shift; + my $self = shift; - $self->{engine}->installPackages('gdm'); + $self->{engine}->installPackages('gdm'); - return 1; + return 1; } sub GDMPathInfo { - my $self = shift; - - my $pathInfo = { - config => '/etc/gdm/gdm.conf', - paths => [ - '/var/lib/gdm', - '/var/log/gdm', - ], - }; + my $self = shift; + + my $pathInfo = { + config => '/etc/gdm/gdm.conf', + paths => [ + '/var/lib/gdm', + '/var/log/gdm', + ], + }; - return $pathInfo; + return $pathInfo; } sub GDMConfigHashForWorkstation { - my $self = shift; - - return { - 'chooser' => { - }, - 'daemon' => { - AutomaticLoginEnable => 'false', - BaseXsession => '/etc/X11/Xsession', - Group => 'gdm', - User => 'gdm', - }, - 'debug' => { - Enable => 'false', - }, - 'greeter' => { - AllowShutdown => 'true', - Browser => 'false', - MinimalUID => '500', - SecureShutdown => 'false', - ShowDomain => 'false', - }, - 'gui' => { - }, - 'security' => { - AllowRemoteRoot => 'false', - DisallowTCP => 'true', - SupportAutomount => 'true', - }, - 'server' => { - }, - 'xdmcp' => { - Enable => 'false', - }, - }; + my $self = shift; + + return { + 'chooser' => { + }, + 'daemon' => { + AutomaticLoginEnable => 'false', + BaseXsession => '/etc/X11/Xsession', + Group => 'gdm', + User => 'gdm', + }, + 'debug' => { + Enable => 'false', + }, + 'greeter' => { + AllowShutdown => 'true', + Browser => 'false', + MinimalUID => '500', + SecureShutdown => 'false', + ShowDomain => 'false', + }, + 'gui' => { + }, + 'security' => { + AllowRemoteRoot => 'false', + DisallowTCP => 'true', + SupportAutomount => 'true', + }, + 'server' => { + }, + 'xdmcp' => { + Enable => 'false', + }, + }; } sub GDMConfigHashForKiosk { - my $self = shift; - - my $configHash = $self->GDMConfigHashForWorkstation(); + my $self = shift; + + my $configHash = $self->GDMConfigHashForWorkstation(); - $configHash->{daemon}->{AutomaticLoginEnable} = 'true'; - $configHash->{daemon}->{AutomaticLogin} = 'nobody'; + $configHash->{daemon}->{AutomaticLoginEnable} = 'true'; + $configHash->{daemon}->{AutomaticLogin} = 'nobody'; - return $configHash; + return $configHash; } sub GDMConfigHashForChooser { - my $self = shift; - - my $configHash = $self->GDMConfigHashForWorkstation(); - $configHash->{xdmcp}->{Enable} = 'true'; + my $self = shift; + + my $configHash = $self->GDMConfigHashForWorkstation(); + $configHash->{xdmcp}->{Enable} = 'true'; - return $configHash; + return $configHash; } sub isKDEInstalled { - my $self = shift; - - return $self->isInPath('startkde'); + my $self = shift; + + return $self->isInPath('startkde'); } sub isKDMInstalled { - my $self = shift; + my $self = shift; - return $self->isInPath('kdm'); + return $self->isInPath('kdm'); } sub installKDE { - my $self = shift; + my $self = shift; - $self->{engine}->installPackages( - $self->{engine}->getInstallablePackagesForSelection('kde') - ); + $self->{engine}->installPackages( + $self->{engine}->getInstallablePackagesForSelection('kde') + ); - return 1; + return 1; } sub installKDM { - my $self = shift; + my $self = shift; - $self->{engine}->installPackages('kdm'); + $self->{engine}->installPackages('kdm'); - return 1; + return 1; } sub isXFCEInstalled { - my $self = shift; + my $self = shift; - return $self->isInPath('startxfce4'); + return $self->isInPath('startxfce4'); } sub isXDMInstalled { - my $self = shift; + my $self = shift; - return $self->isInPath('xdm'); + return $self->isInPath('xdm'); } sub installXFCE { - my $self = shift; + my $self = shift; - $self->{engine}->installPackages( - $self->{engine}->getInstallablePackagesForSelection('xfce') - ); + $self->{engine}->installPackages( + $self->{engine}->getInstallablePackagesForSelection('xfce') + ); - return 1; + return 1; } sub installXDM { - my $self = shift; + my $self = shift; - $self->{engine}->installPackages('xdm'); + $self->{engine}->installPackages('xdm'); - return 1; + return 1; } 1; diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/debian.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/debian.pm index c5e6c5cd..2d837629 100644 --- a/os-plugins/plugins/desktop/OpenSLX/Distro/debian.pm +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/debian.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # debian.pm -# - provides Debian-specific overrides of the OpenSLX Distro API for the +# - provides Debian-specific overrides of the OpenSLX Distro API for the # desktop plugin. # ----------------------------------------------------------------------------- package OpenSLX::Distro::debian; diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/fedora.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/fedora.pm index 7fe4973c..0bc9ebdc 100644 --- a/os-plugins/plugins/desktop/OpenSLX/Distro/fedora.pm +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/fedora.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # Fedora.pm -# - provides Fedora-specific overrides of the OpenSLX OSSetup API. +# - provides Fedora-specific overrides of the OpenSLX OSSetup API. # ----------------------------------------------------------------------------- package OpenSLX::OSSetup::Distro::Fedora; @@ -25,24 +25,24 @@ use OpenSLX::Basics; ################################################################################ sub new { - my $class = shift; - my $self = {}; - return bless $self, $class; + my $class = shift; + my $self = {}; + return bless $self, $class; } sub initialize { - my $self = shift; - my $engine = shift; + my $self = shift; + my $engine = shift; - $self->SUPER::initialize($engine); - $self->{'packager-type'} = 'rpm'; - $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'yum'; - $self->{'stage1c-faked-files'} = [ - '/etc/fstab', - '/etc/mtab', - ]; - return; + $self->SUPER::initialize($engine); + $self->{'packager-type'} = 'rpm'; + $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'yum'; + $self->{'stage1c-faked-files'} = [ + '/etc/fstab', + '/etc/mtab', + ]; + return; } 1; \ No newline at end of file diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/gentoo.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/gentoo.pm index 4d1032f7..c49ba5d6 100644 --- a/os-plugins/plugins/desktop/OpenSLX/Distro/gentoo.pm +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/gentoo.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # SUSE.pm -# - provides SUSE-specific overrides of the OpenSLX OSSetup API. +# - provides SUSE-specific overrides of the OpenSLX OSSetup API. # ----------------------------------------------------------------------------- package OpenSLX::OSSetup::Distro::Gentoo; @@ -25,34 +25,34 @@ use OpenSLX::Basics; ################################################################################ sub new { - my $class = shift; - my $self = {}; - return bless $self, $class; + my $class = shift; + my $self = {}; + return bless $self, $class; } sub pickKernelFile { - my $self = shift; - my $kernelPath = shift; - - my $newestKernelFile; - my $newestKernelFileSortKey = ''; - foreach my $kernelFile (glob("$kernelPath/kernel-genkernel-x86-*")) { - next unless $kernelFile =~ m{ - x86-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?) - }x; - my $sortKey - = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5); - if ($newestKernelFileSortKey lt $sortKey) { - $newestKernelFile = $kernelFile; - $newestKernelFileSortKey = $sortKey; - } - } - - if (!defined $newestKernelFile) { - die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath); - } - return $newestKernelFile; + my $self = shift; + my $kernelPath = shift; + + my $newestKernelFile; + my $newestKernelFileSortKey = ''; + foreach my $kernelFile (glob("$kernelPath/kernel-genkernel-x86-*")) { + next unless $kernelFile =~ m{ + x86-(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?-(\d+(?:\.\d+)?) + }x; + my $sortKey + = sprintf("%02d.%02d.%02d.%02d-%2.1f", $1, $2, $3, $4||0, $5); + if ($newestKernelFileSortKey lt $sortKey) { + $newestKernelFile = $kernelFile; + $newestKernelFileSortKey = $sortKey; + } + } + + if (!defined $newestKernelFile) { + die _tr("unable to pick a kernel-file from path '%s'!", $kernelPath); + } + return $newestKernelFile; } 1; diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm index 761a3705..e360e1b5 100644 --- a/os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # SUSE.pm -# - provides SUSE-specific overrides of the OpenSLX Distro API for the desktop +# - provides SUSE-specific overrides of the OpenSLX Distro API for the desktop # plugin. # ----------------------------------------------------------------------------- package OpenSLX::Distro::suse; diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/ubuntu.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/ubuntu.pm index 9982d363..c932f87f 100644 --- a/os-plugins/plugins/desktop/OpenSLX/Distro/ubuntu.pm +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/ubuntu.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # Ubuntu.pm -# - provides Ubuntu-specific overrides of the OpenSLX OSSetup API. +# - provides Ubuntu-specific overrides of the OpenSLX OSSetup API. # ----------------------------------------------------------------------------- package OpenSLX::Distro::ubuntu; diff --git a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm index bef21fa9..9aa78d49 100644 --- a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm +++ b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # desktop.pm -# - implementation of the 'desktop' plugin, which installs +# - implementation of the 'desktop' plugin, which installs # all needed information for a displaymanager and for the desktop. # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::desktop; @@ -27,449 +27,449 @@ use OpenSLX::Utils; sub new { - my $class = shift; + my $class = shift; - my $self = { - name => 'desktop', - }; + my $self = { + name => 'desktop', + }; - return bless $self, $class; + return bless $self, $class; } sub getInfo { - my $self = shift; - - return { - description => unshiftHereDoc(<<' End-of-Here'), - Sets a desktop and creates needed configs, theme can be set as well. - End-of-Here - mustRunAfter => [], - }; + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + Sets a desktop and creates needed configs, theme can be set as well. + End-of-Here + mustRunAfter => [], + }; } sub getAttrInfo { - my $self = shift; - - return { - 'desktop::active' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'desktop'-plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - 'desktop::precedence' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - the execution precedence of the 'desktop' plugin - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'allowed range is from 01-99', - default => 40, - }, - 'desktop::manager' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - which display manager to start: gdm, kdm or xdm? - End-of-Here - content_regex => qr{^(g|k|x)dm$}, - content_descr => 'allowed: gdm, kdm, xdm', - default => undef, - }, - 'desktop::kind' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - which desktop environment shall be used: gnome, kde, or xfce? - End-of-Here - content_regex => qr{^(gnome,kde,xfce)$}, - content_descr => 'allowed: gnome, kde, xfce', - default => undef, - }, - 'desktop::mode' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - which type of operation mode shall be activated: - workstattion, kiosk or chooser? - End-of-Here - content_regex => qr{^(workstation|kiosk|chooser)$}, - content_descr => 'allowed: workstation,kiosk,chooser', - default => 'workstation', - }, - 'desktop::theme' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - name of the theme to apply to the desktop (unset for no theme) - End-of-Here - content_descr => 'one of the entries in "supported_themes"', - default => 'openslx', - }, - 'desktop::supported_themes' => { - applies_to_vendor_os => 1, - description => unshiftHereDoc(<<' End-of-Here'), - name of all themes that shall be installed in vendor-OS (such - that they can be selected via 'desktop::theme' in stage 3). - End-of-Here - content_descr => 'a comma-separated list of theme names', - default => 'openslx,blue,circles', - }, - 'desktop::gdm' => { - applies_to_vendor_os => 1, - description => unshiftHereDoc(<<' End-of-Here'), - should gdm be available (installed in vendor-OS)? - End-of-Here - content_regex => qr{^0|1$}, - content_descr => '"0", "1" or "-" (for unset)', - default => undef, - }, - 'desktop::kdm' => { - applies_to_vendor_os => 1, - description => unshiftHereDoc(<<' End-of-Here'), - should kdm be available (installed in vendor-OS)? - End-of-Here - content_regex => qr{^0|1$}, - content_descr => '"0", "1" or "-" (for unset)', - default => undef, - }, - 'desktop::xdm' => { - applies_to_vendor_os => 1, - description => unshiftHereDoc(<<' End-of-Here'), - should xdm be available (installed in vendor-OS)? - End-of-Here - content_regex => qr{^0|1$}, - content_descr => '"0", "1" or "-" (for unset)', - default => undef, - }, - 'desktop::gnome' => { - applies_to_vendor_os => 1, - description => unshiftHereDoc(<<' End-of-Here'), - should gnome be available (installed in vendor-OS)? - End-of-Here - content_regex => qr{^0|1$}, - content_descr => '"0", "1" or "-" (for unset)', - default => undef, - }, - 'desktop::kde' => { - applies_to_vendor_os => 1, - description => unshiftHereDoc(<<' End-of-Here'), - should kde be available (installed in vendor-OS)? - End-of-Here - content_regex => qr{^0|1$}, - content_descr => '"0", "1" or "-" (for unset)', - default => undef, - }, - 'desktop::xfce' => { - applies_to_vendor_os => 1, - description => unshiftHereDoc(<<' End-of-Here'), - should xfce be available (installed in vendor-OS)? - End-of-Here - content_regex => qr{^0|1$}, - content_descr => '"0", "1" or "-" (for unset)', - default => undef, - }, - }; + my $self = shift; + + return { + 'desktop::active' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'desktop'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + 'desktop::precedence' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'desktop' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 40, + }, + 'desktop::manager' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + which display manager to start: gdm, kdm or xdm? + End-of-Here + content_regex => qr{^(g|k|x)dm$}, + content_descr => 'allowed: gdm, kdm, xdm', + default => undef, + }, + 'desktop::kind' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + which desktop environment shall be used: gnome, kde, or xfce? + End-of-Here + content_regex => qr{^(gnome,kde,xfce)$}, + content_descr => 'allowed: gnome, kde, xfce', + default => undef, + }, + 'desktop::mode' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + which type of operation mode shall be activated: + workstattion, kiosk or chooser? + End-of-Here + content_regex => qr{^(workstation|kiosk|chooser)$}, + content_descr => 'allowed: workstation,kiosk,chooser', + default => 'workstation', + }, + 'desktop::theme' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to the desktop (unset for no theme) + End-of-Here + content_descr => 'one of the entries in "supported_themes"', + default => 'openslx', + }, + 'desktop::supported_themes' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + name of all themes that shall be installed in vendor-OS (such + that they can be selected via 'desktop::theme' in stage 3). + End-of-Here + content_descr => 'a comma-separated list of theme names', + default => 'openslx,blue,circles', + }, + 'desktop::gdm' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should gdm be available (installed in vendor-OS)? + End-of-Here + content_regex => qr{^0|1$}, + content_descr => '"0", "1" or "-" (for unset)', + default => undef, + }, + 'desktop::kdm' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should kdm be available (installed in vendor-OS)? + End-of-Here + content_regex => qr{^0|1$}, + content_descr => '"0", "1" or "-" (for unset)', + default => undef, + }, + 'desktop::xdm' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should xdm be available (installed in vendor-OS)? + End-of-Here + content_regex => qr{^0|1$}, + content_descr => '"0", "1" or "-" (for unset)', + default => undef, + }, + 'desktop::gnome' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should gnome be available (installed in vendor-OS)? + End-of-Here + content_regex => qr{^0|1$}, + content_descr => '"0", "1" or "-" (for unset)', + default => undef, + }, + 'desktop::kde' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should kde be available (installed in vendor-OS)? + End-of-Here + content_regex => qr{^0|1$}, + content_descr => '"0", "1" or "-" (for unset)', + default => undef, + }, + 'desktop::xfce' => { + applies_to_vendor_os => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should xfce be available (installed in vendor-OS)? + End-of-Here + content_regex => qr{^0|1$}, + content_descr => '"0", "1" or "-" (for unset)', + default => undef, + }, + }; } sub getDefaultAttrsForVendorOS { - my $self = shift; - my $vendorOSName = shift; - - my $attrs = $self->getAttrInfo(); - - if ($vendorOSName =~ m{kde}) { - $attrs->{'desktop::manager'}->{default} = 'kdm'; - $attrs->{'desktop::kind'}->{default} = 'kde'; - } - elsif ($vendorOSName =~ m{gnome}) { - $attrs->{'desktop::manager'}->{default} = 'gdm'; - $attrs->{'desktop::kind'}->{default} = 'gnome'; - } - elsif ($vendorOSName =~ m{xfce}) { - $attrs->{'desktop::manager'}->{default} = 'xdm'; - $attrs->{'desktop::kind'}->{default} = 'xcfe'; - } - else { - # TODO: chroot into vendor-OS and determine the available desktop - } - return $attrs; + my $self = shift; + my $vendorOSName = shift; + + my $attrs = $self->getAttrInfo(); + + if ($vendorOSName =~ m{kde}) { + $attrs->{'desktop::manager'}->{default} = 'kdm'; + $attrs->{'desktop::kind'}->{default} = 'kde'; + } + elsif ($vendorOSName =~ m{gnome}) { + $attrs->{'desktop::manager'}->{default} = 'gdm'; + $attrs->{'desktop::kind'}->{default} = 'gnome'; + } + elsif ($vendorOSName =~ m{xfce}) { + $attrs->{'desktop::manager'}->{default} = 'xdm'; + $attrs->{'desktop::kind'}->{default} = 'xcfe'; + } + else { + # TODO: chroot into vendor-OS and determine the available desktop + } + return $attrs; } sub installationPhase { - my $self = shift; - - $self->{pluginRepositoryPath} = shift; - $self->{pluginTempPath} = shift; - $self->{openslxPath} = shift; - $self->{attrs} = shift; - - # We are going to change some of the stage1 attributes during installation - # (basically we are filling the ones that are not defined). Since the result - # of these changes might change between invocations, we do not want to store - # the resulting values, but we want to store the original (undef). - # In order to do so, we copy all stage1 attributes directly into the - # object hash and change them there. - $self->{gdm} = $self->{attrs}->{'desktop::gdm'}; - $self->{kdm} = $self->{attrs}->{'desktop::kdm'}; - $self->{xdm} = $self->{attrs}->{'desktop::xdm'}; - $self->{gnome} = $self->{attrs}->{'desktop::gnome'}; - $self->{kde} = $self->{attrs}->{'desktop::kde'}; - $self->{xcfe} = $self->{attrs}->{'desktop::xfce'}; - + my $self = shift; + + $self->{pluginRepositoryPath} = shift; + $self->{pluginTempPath} = shift; + $self->{openslxPath} = shift; + $self->{attrs} = shift; + + # We are going to change some of the stage1 attributes during installation + # (basically we are filling the ones that are not defined). Since the result + # of these changes might change between invocations, we do not want to store + # the resulting values, but we want to store the original (undef). + # In order to do so, we copy all stage1 attributes directly into the + # object hash and change them there. + $self->{gdm} = $self->{attrs}->{'desktop::gdm'}; + $self->{kdm} = $self->{attrs}->{'desktop::kdm'}; + $self->{xdm} = $self->{attrs}->{'desktop::xdm'}; + $self->{gnome} = $self->{attrs}->{'desktop::gnome'}; + $self->{kde} = $self->{attrs}->{'desktop::kde'}; + $self->{xcfe} = $self->{attrs}->{'desktop::xfce'}; + use Data::Dumper; print Dumper $self->{attrs}; - $self->_installRequiredPackages(); - $self->_fillUnsetStage1Attrs(); - $self->_ensureSensibleStage3Attrs(); + $self->_installRequiredPackages(); + $self->_fillUnsetStage1Attrs(); + $self->_ensureSensibleStage3Attrs(); use Data::Dumper; print Dumper $self->{attrs}; - # start to actually do something - according to current stage1 attributes - if ($self->{gdm}) { - $self->_setupGDM(); - } - if ($self->{kdm}) { - $self->_setupKDM(); - } - if ($self->{xdm}) { - $self->_setupXDM(); - } - - return; + # start to actually do something - according to current stage1 attributes + if ($self->{gdm}) { + $self->_setupGDM(); + } + if ($self->{kdm}) { + $self->_setupKDM(); + } + if ($self->{xdm}) { + $self->_setupXDM(); + } + + return; } sub removalPhase { - my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; - return; + return; } sub copyRequiredFilesIntoInitramfs { - my $self = shift; - my $targetPath = shift; - my $attrs = shift; - my $makeInitRamFSEngine = shift; - - my $themeDir = "$openslxConfig{'base-path'}/share/themes"; + my $self = shift; + my $targetPath = shift; + my $attrs = shift; + my $makeInitRamFSEngine = shift; + + my $themeDir = "$openslxConfig{'base-path'}/share/themes"; my $desktopXdmcp = $attrs->{'desktop::xdmcp'} || ''; - my $xdmcpConfigDir = "$openslxConfig{'base-path'}/lib/plugins/desktop/files/$desktopXdmcp"; - my $desktopTheme = $attrs->{'desktop::theme'} || ''; - if ($desktopTheme) { - my $desktopThemeDir - = "$themeDir/$desktopTheme/desktop/$desktopXdmcp"; - if (-d $desktopThemeDir) { + my $xdmcpConfigDir = "$openslxConfig{'base-path'}/lib/plugins/desktop/files/$desktopXdmcp"; + my $desktopTheme = $attrs->{'desktop::theme'} || ''; + if ($desktopTheme) { + my $desktopThemeDir + = "$themeDir/$desktopTheme/desktop/$desktopXdmcp"; + if (-d $desktopThemeDir) { $makeInitRamFSEngine->addCMD( "mkdir -p $targetPath/usr/share/files" ); - $makeInitRamFSEngine->addCMD( - "mkdir -p $targetPath/usr/share/themes" - ); - $makeInitRamFSEngine->addCMD( - "cp -a $desktopThemeDir $targetPath/usr/share/themes/" - ); + $makeInitRamFSEngine->addCMD( + "mkdir -p $targetPath/usr/share/themes" + ); + $makeInitRamFSEngine->addCMD( + "cp -a $desktopThemeDir $targetPath/usr/share/themes/" + ); $makeInitRamFSEngine->addCMD( "cp -a $xdmcpConfigDir $targetPath/usr/share/files" ); - } - } - else { - $desktopTheme = ''; - } - - vlog( - 1, - _tr( - "desktop-plugin: desktop=%s", - $desktopTheme - ) - ); - - return; + } + } + else { + $desktopTheme = ''; + } + + vlog( + 1, + _tr( + "desktop-plugin: desktop=%s", + $desktopTheme + ) + ); + + return; } sub _installRequiredPackages { - my $self = shift; - - my $engine = $self->{'os-plugin-engine'}; - - if ($self->{'gnome'} && !$self->{distro}->isGNOMEInstalled()) { - $self->{distro}->installGNOME(); - } - if ($self->{'gdm'} && !$self->{distro}->isGDMInstalled()) { - $self->{distro}->installGDM(); - } - if ($self->{'kde'} && !$self->{distro}->isKDEInstalled()) { - $self->{distro}->installKDE(); - } - if ($self->{'kdm'} && !$self->{distro}->isKDMInstalled()) { - $self->{distro}->installKDM(); - } - if ($self->{'xfce'} && !$self->{distro}->isXFCEInstalled()) { - $self->{distro}->installXFCE(); - } - if ($self->{'xdm'} && !$self->{distro}->isXDMInstalled()) { - $self->{distro}->installXDM(); - } - - return 1; + my $self = shift; + + my $engine = $self->{'os-plugin-engine'}; + + if ($self->{'gnome'} && !$self->{distro}->isGNOMEInstalled()) { + $self->{distro}->installGNOME(); + } + if ($self->{'gdm'} && !$self->{distro}->isGDMInstalled()) { + $self->{distro}->installGDM(); + } + if ($self->{'kde'} && !$self->{distro}->isKDEInstalled()) { + $self->{distro}->installKDE(); + } + if ($self->{'kdm'} && !$self->{distro}->isKDMInstalled()) { + $self->{distro}->installKDM(); + } + if ($self->{'xfce'} && !$self->{distro}->isXFCEInstalled()) { + $self->{distro}->installXFCE(); + } + if ($self->{'xdm'} && !$self->{distro}->isXDMInstalled()) { + $self->{distro}->installXDM(); + } + + return 1; } sub _fillUnsetStage1Attrs { - my $self = shift; - - if (!defined $self->{'gnome'}) { - $self->{'gnome'} = $self->{distro}->isGNOMEInstalled(); - } - if (!defined $self->{'gdm'}) { - $self->{'gdm'} = $self->{distro}->isGDMInstalled(); - } - if (!defined $self->{'kde'}) { - $self->{'kde'} = $self->{distro}->isKDEInstalled(); - } - if (!defined $self->{'kdm'}) { - $self->{'kdm'} = $self->{distro}->isKDMInstalled(); - } - if (!defined $self->{'xfce'}) { - $self->{'xfce'} = $self->{distro}->isXFCEInstalled(); - } - if (!defined $self->{'xdm'}) { - $self->{'xdm'} = $self->{distro}->isXDMInstalled(); - } - - return 1; + my $self = shift; + + if (!defined $self->{'gnome'}) { + $self->{'gnome'} = $self->{distro}->isGNOMEInstalled(); + } + if (!defined $self->{'gdm'}) { + $self->{'gdm'} = $self->{distro}->isGDMInstalled(); + } + if (!defined $self->{'kde'}) { + $self->{'kde'} = $self->{distro}->isKDEInstalled(); + } + if (!defined $self->{'kdm'}) { + $self->{'kdm'} = $self->{distro}->isKDMInstalled(); + } + if (!defined $self->{'xfce'}) { + $self->{'xfce'} = $self->{distro}->isXFCEInstalled(); + } + if (!defined $self->{'xdm'}) { + $self->{'xdm'} = $self->{distro}->isXDMInstalled(); + } + + return 1; } sub _ensureSensibleStage3Attrs { - my $self = shift; - - # check if current desktop kind is enabled at all and select another - # one, if it isn't - my $kind = $self->{attrs}->{'desktop::kind'} || ''; - if (!$self->{$kind}) { - my @desktops = map { $self->{$_} ? $_ : () } qw( gnome kde xfce ); - if (!@desktops) { - die _tr( - "no desktop kind is possible, plugin 'desktop' wouldn't work!" - ); - } - $self->{attrs}->{'desktop::kind'} = $desktops[0]; - } - - # check if current desktop manager is enabled at all and select another - # one, if it isn't - my $manager = $self->{attrs}->{'desktop::manager'} || ''; - if (!$self->{$manager}) { - my @managers = map { $self->{$_} ? $_ : () } qw( gdm kdm xdm ); - if (!@managers) { - die _tr( - "no desktop manager is possible, plugin 'desktop' wouldn't work!" - ); - } - $self->{attrs}->{'desktop::manager'} = $managers[0]; - } - - return 1; + my $self = shift; + + # check if current desktop kind is enabled at all and select another + # one, if it isn't + my $kind = $self->{attrs}->{'desktop::kind'} || ''; + if (!$self->{$kind}) { + my @desktops = map { $self->{$_} ? $_ : () } qw( gnome kde xfce ); + if (!@desktops) { + die _tr( + "no desktop kind is possible, plugin 'desktop' wouldn't work!" + ); + } + $self->{attrs}->{'desktop::kind'} = $desktops[0]; + } + + # check if current desktop manager is enabled at all and select another + # one, if it isn't + my $manager = $self->{attrs}->{'desktop::manager'} || ''; + if (!$self->{$manager}) { + my @managers = map { $self->{$_} ? $_ : () } qw( gdm kdm xdm ); + if (!@managers) { + die _tr( + "no desktop manager is possible, plugin 'desktop' wouldn't work!" + ); + } + $self->{attrs}->{'desktop::manager'} = $managers[0]; + } + + return 1; } sub _setupGDM { - my $self = shift; - my $attrs = shift; - - my $repoPath = $self->{pluginRepositoryPath}; - mkpath([ - "$repoPath/gdm/workstation", - "$repoPath/gdm/kiosk", - "$repoPath/gdm/chooser", - ]); - - my $pathInfo = $self->{distro}->GDMPathInfo(); - $self->_setupGDMScript($pathInfo); - - my $configHash = $self->{distro}->GDMConfigHashForWorkstation(); - $self->_writeConfigHash($configHash, "$repoPath/gdm/workstation/gdm.conf"); - - $configHash = $self->{distro}->GDMConfigHashForKiosk(); - $self->_writeConfigHash($configHash, "$repoPath/gdm/kiosk/gdm.conf"); - - $configHash = $self->{distro}->GDMConfigHashForChooser(); - $self->_writeConfigHash($configHash, "$repoPath/gdm/chooser/gdm.conf"); - - return; + my $self = shift; + my $attrs = shift; + + my $repoPath = $self->{pluginRepositoryPath}; + mkpath([ + "$repoPath/gdm/workstation", + "$repoPath/gdm/kiosk", + "$repoPath/gdm/chooser", + ]); + + my $pathInfo = $self->{distro}->GDMPathInfo(); + $self->_setupGDMScript($pathInfo); + + my $configHash = $self->{distro}->GDMConfigHashForWorkstation(); + $self->_writeConfigHash($configHash, "$repoPath/gdm/workstation/gdm.conf"); + + $configHash = $self->{distro}->GDMConfigHashForKiosk(); + $self->_writeConfigHash($configHash, "$repoPath/gdm/kiosk/gdm.conf"); + + $configHash = $self->{distro}->GDMConfigHashForChooser(); + $self->_writeConfigHash($configHash, "$repoPath/gdm/chooser/gdm.conf"); + + return; } sub _setupGDMScript { - my $self = shift; - my $pathInfo = shift; - - my $repoPath = $self->{pluginRepositoryPath}; - my $configFile = $pathInfo->{config}; - my $paths - = join( - ' ', - map { '/mnt' . $_ } ( dirname($configFile), @{$pathInfo->{paths}} ) - ); - my $script = unshiftHereDoc(<<" End-of-Here"); - #!/bin/ash - # written by OpenSLX-plugin 'desktop' - mkdir -p $paths 2>/dev/null - ln -sf $repoPath/gdm/\$desktop_mode/gdm.conf /mnt$configFile - rllinker gdm 1 15 - End-of-Here - spitFile("$repoPath/gdm/desktop.sh", $script); - return; + my $self = shift; + my $pathInfo = shift; + + my $repoPath = $self->{pluginRepositoryPath}; + my $configFile = $pathInfo->{config}; + my $paths + = join( + ' ', + map { '/mnt' . $_ } ( dirname($configFile), @{$pathInfo->{paths}} ) + ); + my $script = unshiftHereDoc(<<" End-of-Here"); + #!/bin/ash + # written by OpenSLX-plugin 'desktop' + mkdir -p $paths 2>/dev/null + ln -sf $repoPath/gdm/\$desktop_mode/gdm.conf /mnt$configFile + rllinker gdm 1 15 + End-of-Here + spitFile("$repoPath/gdm/desktop.sh", $script); + return; } sub _setupKDM { - my $self = shift; - my $attrs = shift; - + my $self = shift; + my $attrs = shift; + } sub _setupXDM { - my $self = shift; - my $attrs = shift; + my $self = shift; + my $attrs = shift; } sub _writeConfigHash { - my $self = shift; - my $hash = shift || {}; - my $file = shift; - - my $content = ''; - for my $domain (sort keys %$hash) { - $content .= "[$domain]\n"; - for my $key (sort keys %{$hash->{$domain}}) { - my $value - = defined $hash->{$domain}->{$key} - ? $hash->{$domain}->{$key} - : ''; - $content .= "$key=$value\n"; - } - $content .= "\n"; - } - spitFile($file, $content); + my $self = shift; + my $hash = shift || {}; + my $file = shift; + + my $content = ''; + for my $domain (sort keys %$hash) { + $content .= "[$domain]\n"; + for my $key (sort keys %{$hash->{$domain}}) { + my $value + = defined $hash->{$domain}->{$key} + ? $hash->{$domain}->{$key} + : ''; + $content .= "$key=$value\n"; + } + $content .= "\n"; + } + spitFile($file, $content); } 1; diff --git a/os-plugins/plugins/displaymanager/OpenSLX/OSPlugin/displaymanager.pm b/os-plugins/plugins/displaymanager/OpenSLX/OSPlugin/displaymanager.pm index 5660d91b..ee1b503b 100644 --- a/os-plugins/plugins/displaymanager/OpenSLX/OSPlugin/displaymanager.pm +++ b/os-plugins/plugins/displaymanager/OpenSLX/OSPlugin/displaymanager.pm @@ -9,10 +9,10 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # displaymanager.pm -# - implementation of the 'displaymanager' plugin, which installs +# - implementation of the 'displaymanager' plugin, which installs # all needed information for a displaymanager. Further possibilities: -# change xdmcp to (gdm, kdm, ...) -# change theme for this xdmcp +# change xdmcp to (gdm, kdm, ...) +# change theme for this xdmcp # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::displaymanager; @@ -26,117 +26,117 @@ use OpenSLX::Utils; sub new { - my $class = shift; + my $class = shift; - my $self = { - name => 'displaymanager', - }; + my $self = { + name => 'displaymanager', + }; - return bless $self, $class; + return bless $self, $class; } sub getInfo { - my $self = shift; + my $self = shift; - return { - description => unshiftHereDoc(<<' End-of-Here'), - Sets a displaymanager and creates needed configs, theme can be set as well. - End-of-Here - mustRunAfter => [], - }; + return { + description => unshiftHereDoc(<<' End-of-Here'), + Sets a displaymanager and creates needed configs, theme can be set as well. + End-of-Here + mustRunAfter => [], + }; } sub getAttrInfo { - my $self = shift; + my $self = shift; - return { - 'displaymanager::active' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'displaymanager'-plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - 'displaymanager::precedence' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - the execution precedence of the 'displaymanager' plugin - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'allowed range is from 01-99', - default => 40, - }, - 'displaymanager::xdmcp' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - which xdmcp to configure, gdm, kdm, xdm?) - End-of-Here - content_regex => qr{^(g|k|x)dm$}, - content_descr => 'allowed: gdm, kdm, xdm', - default => 'xdm', - }, - 'displaymanager::theme' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - name of the theme to apply to the displaymanager (unset for no theme) - End-of-Here - content_regex => undef, - content_descr => undef, - default => 'openslx', - }, - }; + return { + 'displaymanager::active' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'displaymanager'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + 'displaymanager::precedence' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'displaymanager' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 40, + }, + 'displaymanager::xdmcp' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + which xdmcp to configure, gdm, kdm, xdm?) + End-of-Here + content_regex => qr{^(g|k|x)dm$}, + content_descr => 'allowed: gdm, kdm, xdm', + default => 'xdm', + }, + 'displaymanager::theme' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to the displaymanager (unset for no theme) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'openslx', + }, + }; } sub copyRequiredFilesIntoInitramfs { - my $self = shift; - my $targetPath = shift; - my $attrs = shift; - my $makeInitRamFSEngine = shift; - - my $themeDir = "$openslxConfig{'base-path'}/share/themes"; + my $self = shift; + my $targetPath = shift; + my $attrs = shift; + my $makeInitRamFSEngine = shift; + + my $themeDir = "$openslxConfig{'base-path'}/share/themes"; my $displaymanagerXdmcp = $attrs->{'displaymanager::xdmcp'} || ''; - my $xdmcpConfigDir = "$openslxConfig{'base-path'}/lib/plugins/displaymanager/files/$displaymanagerXdmcp"; - my $displaymanagerTheme = $attrs->{'displaymanager::theme'} || ''; - if ($displaymanagerTheme) { - my $displaymanagerThemeDir - = "$themeDir/$displaymanagerTheme/displaymanager/$displaymanagerXdmcp"; - if (-d $displaymanagerThemeDir) { + my $xdmcpConfigDir = "$openslxConfig{'base-path'}/lib/plugins/displaymanager/files/$displaymanagerXdmcp"; + my $displaymanagerTheme = $attrs->{'displaymanager::theme'} || ''; + if ($displaymanagerTheme) { + my $displaymanagerThemeDir + = "$themeDir/$displaymanagerTheme/displaymanager/$displaymanagerXdmcp"; + if (-d $displaymanagerThemeDir) { $makeInitRamFSEngine->addCMD( "mkdir -p $targetPath/usr/share/files" ); - $makeInitRamFSEngine->addCMD( - "mkdir -p $targetPath/usr/share/themes" - ); - $makeInitRamFSEngine->addCMD( - "cp -a $displaymanagerThemeDir $targetPath/usr/share/themes/" - ); + $makeInitRamFSEngine->addCMD( + "mkdir -p $targetPath/usr/share/themes" + ); + $makeInitRamFSEngine->addCMD( + "cp -a $displaymanagerThemeDir $targetPath/usr/share/themes/" + ); $makeInitRamFSEngine->addCMD( "cp -a $xdmcpConfigDir $targetPath/usr/share/files" ); - } - } - else { - $displaymanagerTheme = ''; - } + } + } + else { + $displaymanagerTheme = ''; + } - vlog( - 1, - _tr( - "displaymanager-plugin: displaymanager=%s", - $displaymanagerTheme - ) - ); + vlog( + 1, + _tr( + "displaymanager-plugin: displaymanager=%s", + $displaymanagerTheme + ) + ); - return; + return; } 1; diff --git a/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm b/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm index 69c5c2c7..dad6756c 100644 --- a/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm +++ b/os-plugins/plugins/example/OpenSLX/OSPlugin/example.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # example.pm -# - an example implementation of the OSPlugin API (i.e. an os-plugin) +# - an example implementation of the OSPlugin API (i.e. an os-plugin) # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::example; @@ -28,127 +28,127 @@ use OpenSLX::Utils; ################################################################################ sub new { - my $class = shift; + my $class = shift; - my $self = { - name => 'example', - }; + my $self = { + name => 'example', + }; - return bless $self, $class; + return bless $self, $class; } sub getInfo { - my $self = shift; - - return { - description => unshiftHereDoc(<<' End-of-Here'), - just an exemplary plugin that prints a smiley when the client boots - End-of-Here - mustRunAfter => [], - }; + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + just an exemplary plugin that prints a smiley when the client boots + End-of-Here + mustRunAfter => [], + }; } sub getAttrInfo -{ # returns a hash-ref with information about all attributes supported - # by this specific plugin - my $self = shift; - - # This default configuration will be added as attributes to the default - # system, such that it can be overruled for any specific system by means - # of slxconfig. - return { - # attribute 'active' is mandatory for all plugins - 'example::active' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'example'-plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - # attribute 'precedence' is mandatory for all plugins - 'example::precedence' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - the execution precedence of the 'example' plugin - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'allowed range is from 01-99', - default => 50, - }, - - # plugin specific attributes start here ... - 'example::preferred_side' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - determines to which side you have to tilt your head in order - to read the smiley - End-of-Here - content_regex => qr{^(left|right)$}, - content_descr => q{'left' will print ';-)' - 'right' will print '(-;'}, - default => 'left', - }, - }; +{ # returns a hash-ref with information about all attributes supported + # by this specific plugin + my $self = shift; + + # This default configuration will be added as attributes to the default + # system, such that it can be overruled for any specific system by means + # of slxconfig. + return { + # attribute 'active' is mandatory for all plugins + 'example::active' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'example'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + # attribute 'precedence' is mandatory for all plugins + 'example::precedence' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'example' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 50, + }, + + # plugin specific attributes start here ... + 'example::preferred_side' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + determines to which side you have to tilt your head in order + to read the smiley + End-of-Here + content_regex => qr{^(left|right)$}, + content_descr => q{'left' will print ';-)' - 'right' will print '(-;'}, + default => 'left', + }, + }; } sub installationPhase -{ # called while chrooted to the vendor-OS root in order to give the plugin - # a chance to install required files into the vendor-OS. - my $self = shift; - - my $pluginRepositoryPath = shift; - # The folder where the stage1-plugin should store all files - # required by the corresponding stage3 runlevel script. - # As this method is being executed while chrooted into the vendor-OS, - # this path is relative to that root (i.e. directly usable). - my $pluginTempPath = shift; - # A temporary playground that will be cleaned up automatically. - # As this method is being executed while chrooted into the vendor-OS, - # this path is relative to that root (i.e. directly usable). - my $openslxPath = shift; - # the openslx base path bind-mounted into the chroot (/mnt/openslx) - - # for this example plugin, we simply create two files: - spitFile("$pluginRepositoryPath/right", "(-;\n"); - spitFile("$pluginRepositoryPath/left", ";-)\n"); - - # Some plugins have to copy files from their plugin folder into the - # vendor-OS. In order to make this possible while chrooted, the host's - # /opt/openslx folder will be mounted to /mnt/openslx in the vendor-OS. - # So each plugin could copy some files like this: - # - # # get our own name: - # my $pluginName = $self->{'name'}; - # - # # get our own base path: - # my $pluginBasePath = "/mnt/openslx/lib/plugins/$pluginName"; - # - # # copy all needed files now: - # foreach my $file ( qw( file1, file2 ) ) { - # copyFile("$pluginBasePath/$file", "$pluginRepositoryPath/"); - # } - - # name of current os - # $self->{'os-plugin-engine'}->{'vendor-os-name'} - - return; +{ # called while chrooted to the vendor-OS root in order to give the plugin + # a chance to install required files into the vendor-OS. + my $self = shift; + + my $pluginRepositoryPath = shift; + # The folder where the stage1-plugin should store all files + # required by the corresponding stage3 runlevel script. + # As this method is being executed while chrooted into the vendor-OS, + # this path is relative to that root (i.e. directly usable). + my $pluginTempPath = shift; + # A temporary playground that will be cleaned up automatically. + # As this method is being executed while chrooted into the vendor-OS, + # this path is relative to that root (i.e. directly usable). + my $openslxPath = shift; + # the openslx base path bind-mounted into the chroot (/mnt/openslx) + + # for this example plugin, we simply create two files: + spitFile("$pluginRepositoryPath/right", "(-;\n"); + spitFile("$pluginRepositoryPath/left", ";-)\n"); + + # Some plugins have to copy files from their plugin folder into the + # vendor-OS. In order to make this possible while chrooted, the host's + # /opt/openslx folder will be mounted to /mnt/openslx in the vendor-OS. + # So each plugin could copy some files like this: + # + # # get our own name: + # my $pluginName = $self->{'name'}; + # + # # get our own base path: + # my $pluginBasePath = "/mnt/openslx/lib/plugins/$pluginName"; + # + # # copy all needed files now: + # foreach my $file ( qw( file1, file2 ) ) { + # copyFile("$pluginBasePath/$file", "$pluginRepositoryPath/"); + # } + + # name of current os + # $self->{'os-plugin-engine'}->{'vendor-os-name'} + + return; } sub removalPhase -{ # called while chrooted to the vendor-OS root in order to give the plugin - # a chance to uninstall no longer required files from the vendor-OS. - my $self = shift; - my $pluginRepositoryPath = shift; - # the repository folder, relative to the vendor-OS root - my $pluginTempPath = shift; - # the temporary folder, relative to the vendor-OS root - - return; +{ # called while chrooted to the vendor-OS root in order to give the plugin + # a chance to uninstall no longer required files from the vendor-OS. + my $self = shift; + my $pluginRepositoryPath = shift; + # the repository folder, relative to the vendor-OS root + my $pluginTempPath = shift; + # the temporary folder, relative to the vendor-OS root + + return; } 1; diff --git a/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm b/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm index 11bef626..d4610a4c 100644 --- a/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm +++ b/os-plugins/plugins/theme/OpenSLX/OSPlugin/theme.pm @@ -9,11 +9,11 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # theme.pm -# - implementation of the 'theme' plugin, which applies theming to the +# - implementation of the 'theme' plugin, which applies theming to the # following places: -# + bootsplash (via splashy) -# + displaymanager (gdm, kdm, ...) -# + desktop (to be done) +# + bootsplash (via splashy) +# + displaymanager (gdm, kdm, ...) +# + desktop (to be done) # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::theme; @@ -27,175 +27,175 @@ use OpenSLX::Utils; sub new { - my $class = shift; + my $class = shift; - my $self = { - name => 'theme', - }; + my $self = { + name => 'theme', + }; - return bless $self, $class; + return bless $self, $class; } sub getInfo { - my $self = shift; - - return { - description => unshiftHereDoc(<<' End-of-Here'), - Applies a graphical theme to the bootsplash and the displaymanager. - End-of-Here - mustRunAfter => [], - }; + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + Applies a graphical theme to the bootsplash and the displaymanager. + End-of-Here + mustRunAfter => [], + }; } sub getAttrInfo { - my $self = shift; - - return { - 'theme::active' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'theme'-plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - 'theme::precedence' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - the execution precedence of the 'theme' plugin - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'allowed range is from 01-99', - default => 30, - }, - - 'theme::splash' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - name of the theme to apply to bootsplash (unset for no theme) - End-of-Here - content_regex => undef, - content_descr => undef, - default => 'openslx', - }, - 'theme::displaymanager' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - name of the theme to apply to displaymanager (unset for no theme) - End-of-Here - content_regex => undef, - content_descr => undef, - default => 'openslx', - }, - 'theme::desktop' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - name of the theme to apply to desktop (unset for no theme) - End-of-Here - content_regex => undef, - content_descr => undef, - default => 'openslx', - }, - }; + my $self = shift; + + return { + 'theme::active' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'theme'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + 'theme::precedence' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'theme' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 30, + }, + + 'theme::splash' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to bootsplash (unset for no theme) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'openslx', + }, + 'theme::displaymanager' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to displaymanager (unset for no theme) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'openslx', + }, + 'theme::desktop' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to desktop (unset for no theme) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'openslx', + }, + }; } sub suggestAdditionalKernelParams { - my $self = shift; - my $makeInitRamFSEngine = shift; - - my @suggestedParams; - - # add vga=0x317 unless explicit vga-mode is already set - if (!$makeInitRamFSEngine->haveKernelParam(qr{\bvga=})) { - push @suggestedParams, 'vga=0x317'; - } - - # add quiet, if not already set - if (!$makeInitRamFSEngine->haveKernelParam('quiet')) { - push @suggestedParams, 'quiet'; - } - - return @suggestedParams; + my $self = shift; + my $makeInitRamFSEngine = shift; + + my @suggestedParams; + + # add vga=0x317 unless explicit vga-mode is already set + if (!$makeInitRamFSEngine->haveKernelParam(qr{\bvga=})) { + push @suggestedParams, 'vga=0x317'; + } + + # add quiet, if not already set + if (!$makeInitRamFSEngine->haveKernelParam('quiet')) { + push @suggestedParams, 'quiet'; + } + + return @suggestedParams; } sub suggestAdditionalKernelModules { - my $self = shift; - my $makeInitRamFSEngine = shift; - - my @suggestedModules; - - # Ubuntu needs vesafb and fbcon (which drags along some others) - if ($makeInitRamFSEngine->{'distro-name'} =~ m{^ubuntu}i) { - push @suggestedModules, qw( vesafb fbcon ) - } - - return @suggestedModules; + my $self = shift; + my $makeInitRamFSEngine = shift; + + my @suggestedModules; + + # Ubuntu needs vesafb and fbcon (which drags along some others) + if ($makeInitRamFSEngine->{'distro-name'} =~ m{^ubuntu}i) { + push @suggestedModules, qw( vesafb fbcon ) + } + + return @suggestedModules; } sub copyRequiredFilesIntoInitramfs { - my $self = shift; - my $targetPath = shift; - my $attrs = shift; - my $makeInitRamFSEngine = shift; - - my $themeDir = "$openslxConfig{'base-path'}/share/themes"; - my $splashTheme = $attrs->{'theme::splash'} || ''; - if ($splashTheme) { - my $splashThemeDir = "$themeDir/$splashTheme/bootsplash"; - if (-d $splashThemeDir) { - my $splashyPath = "$openslxConfig{'base-path'}/share/splashy"; - $makeInitRamFSEngine->addCMD( - "cp -p $splashyPath/* $targetPath/bin/" - ); - $makeInitRamFSEngine->addCMD( - "mkdir -p $targetPath/etc/splashy" - ); - $makeInitRamFSEngine->addCMD( - "cp -a $splashThemeDir/* $targetPath/etc/splashy/" - ); - } - } - else { - $splashTheme = ''; - } - - my $displayManagerTheme = $attrs->{'theme::displaymanager'} || ''; - if ($displayManagerTheme) { - my $displayManagerThemeDir - = "$themeDir/$displayManagerTheme/displaymanager"; - if (-d $displayManagerThemeDir) { - $makeInitRamFSEngine->addCMD( - "mkdir -p $targetPath/usr/share/themes" - ); - $makeInitRamFSEngine->addCMD( - "cp -a $displayManagerThemeDir $targetPath/usr/share/themes/" - ); - } - } - else { - $displayManagerTheme = ''; - } - - vlog( - 1, - _tr( - "theme-plugin: bootsplash=%s displaymanager=%s", - $splashTheme, $displayManagerTheme - ) - ); - - return; + my $self = shift; + my $targetPath = shift; + my $attrs = shift; + my $makeInitRamFSEngine = shift; + + my $themeDir = "$openslxConfig{'base-path'}/share/themes"; + my $splashTheme = $attrs->{'theme::splash'} || ''; + if ($splashTheme) { + my $splashThemeDir = "$themeDir/$splashTheme/bootsplash"; + if (-d $splashThemeDir) { + my $splashyPath = "$openslxConfig{'base-path'}/share/splashy"; + $makeInitRamFSEngine->addCMD( + "cp -p $splashyPath/* $targetPath/bin/" + ); + $makeInitRamFSEngine->addCMD( + "mkdir -p $targetPath/etc/splashy" + ); + $makeInitRamFSEngine->addCMD( + "cp -a $splashThemeDir/* $targetPath/etc/splashy/" + ); + } + } + else { + $splashTheme = ''; + } + + my $displayManagerTheme = $attrs->{'theme::displaymanager'} || ''; + if ($displayManagerTheme) { + my $displayManagerThemeDir + = "$themeDir/$displayManagerTheme/displaymanager"; + if (-d $displayManagerThemeDir) { + $makeInitRamFSEngine->addCMD( + "mkdir -p $targetPath/usr/share/themes" + ); + $makeInitRamFSEngine->addCMD( + "cp -a $displayManagerThemeDir $targetPath/usr/share/themes/" + ); + } + } + else { + $displayManagerTheme = ''; + } + + vlog( + 1, + _tr( + "theme-plugin: bootsplash=%s displaymanager=%s", + $splashTheme, $displayManagerTheme + ) + ); + + return; } 1; diff --git a/os-plugins/plugins/vmchooser/OpenSLX/OSPlugin/vmchooser.pm b/os-plugins/plugins/vmchooser/OpenSLX/OSPlugin/vmchooser.pm index adbc5557..b18aaa02 100644 --- a/os-plugins/plugins/vmchooser/OpenSLX/OSPlugin/vmchooser.pm +++ b/os-plugins/plugins/vmchooser/OpenSLX/OSPlugin/vmchooser.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # vmchooser.pm -# - allows user to pick from a list of virtual machin images +# - allows user to pick from a list of virtual machin images # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::vmchooser; @@ -23,112 +23,112 @@ use OpenSLX::Utils; sub new { - my $class = shift; + my $class = shift; - my $self = { - name => 'vmchooser', - }; + my $self = { + name => 'vmchooser', + }; - return bless $self, $class; + return bless $self, $class; } sub getInfo { - my $self = shift; - - return { - description => unshiftHereDoc(<<' End-of-Here'), - allows user to pick from a list of different virtual machine images - based on xml-files, which tell about available images. - End-of-Here - mustRunAfter => [] - }; + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + allows user to pick from a list of different virtual machine images + based on xml-files, which tell about available images. + End-of-Here + mustRunAfter => [] + }; } sub getAttrInfo { - my $self = shift; - - return { - 'vmchooser::active' => { - applies_to_systems => 0, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'vmchooser'-plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - 'vmchooser::precedence' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - the execution precedence of the 'vmchooser' plugin - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'allowed range is from 01-99', - default => 50, - }, - }; + my $self = shift; + + return { + 'vmchooser::active' => { + applies_to_systems => 0, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'vmchooser'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + 'vmchooser::precedence' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'vmchooser' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 50, + }, + }; } sub installationPhase -{ # called while chrooted to the vendor-OS root in order to give the plugin - # a chance to install required files into the vendor-OS. - my $self = shift; - - my $pluginRepositoryPath = shift; - # The folder where the stage1-plugin should store all files - # required by the corresponding stage3 runlevel script. - # As this method is being executed while chrooted into the vendor-OS, - # this path is relative to that root (i.e. directly usable). - my $pluginTempPath = shift; - # A temporary playground that will be cleaned up automatically. - # As this method is being executed while chrooted into the vendor-OS, - # this path is relative to that root (i.e. directly usable). - my $openslxPath = shift; - # the openslx base path bind-mounted into the chroot (/mnt/openslx) - - # for this example plugin, we simply create two files: - spitFile("$pluginRepositoryPath/right", "(-;\n"); - spitFile("$pluginRepositoryPath/left", ";-)\n"); - - # Some plugins have to copy files from their plugin folder into the - # vendor-OS. In order to make this possible while chrooted, the host's - # /opt/openslx folder will be mounted to /mnt/openslx in the vendor-OS. - # So each plugin could copy some files like this: - # - - # get our own name: - my $pluginName = $self->{'name'}; - - - # get our own base path: - my $pluginBasePath = "/mnt/openslx/lib/plugins/$pluginName"; - - # copy all needed files now: - foreach my $file ( qw( vmchooser ) ) { - copyFile("$pluginBasePath/$file", "$pluginRepositoryPath/"); - } - - # name of current os - # $self->{'os-plugin-engine'}->{'vendor-os-name'} - - return; +{ # called while chrooted to the vendor-OS root in order to give the plugin + # a chance to install required files into the vendor-OS. + my $self = shift; + + my $pluginRepositoryPath = shift; + # The folder where the stage1-plugin should store all files + # required by the corresponding stage3 runlevel script. + # As this method is being executed while chrooted into the vendor-OS, + # this path is relative to that root (i.e. directly usable). + my $pluginTempPath = shift; + # A temporary playground that will be cleaned up automatically. + # As this method is being executed while chrooted into the vendor-OS, + # this path is relative to that root (i.e. directly usable). + my $openslxPath = shift; + # the openslx base path bind-mounted into the chroot (/mnt/openslx) + + # for this example plugin, we simply create two files: + spitFile("$pluginRepositoryPath/right", "(-;\n"); + spitFile("$pluginRepositoryPath/left", ";-)\n"); + + # Some plugins have to copy files from their plugin folder into the + # vendor-OS. In order to make this possible while chrooted, the host's + # /opt/openslx folder will be mounted to /mnt/openslx in the vendor-OS. + # So each plugin could copy some files like this: + # + + # get our own name: + my $pluginName = $self->{'name'}; + + + # get our own base path: + my $pluginBasePath = "/mnt/openslx/lib/plugins/$pluginName"; + + # copy all needed files now: + foreach my $file ( qw( vmchooser ) ) { + copyFile("$pluginBasePath/$file", "$pluginRepositoryPath/"); + } + + # name of current os + # $self->{'os-plugin-engine'}->{'vendor-os-name'} + + return; } sub removalPhase -{ # called while chrooted to the vendor-OS root in order to give the plugin - # a chance to uninstall no longer required files from the vendor-OS. - my $self = shift; - my $pluginRepositoryPath = shift; - # the repository folder, relative to the vendor-OS root - my $pluginTempPath = shift; - # the temporary folder, relative to the vendor-OS root - - return; +{ # called while chrooted to the vendor-OS root in order to give the plugin + # a chance to uninstall no longer required files from the vendor-OS. + my $self = shift; + my $pluginRepositoryPath = shift; + # the repository folder, relative to the vendor-OS root + my $pluginTempPath = shift; + # the temporary folder, relative to the vendor-OS root + + return; } 1; diff --git a/os-plugins/plugins/vmware/OpenSLX/Distro/base.pm b/os-plugins/plugins/vmware/OpenSLX/Distro/base.pm index 7bcdc1f0..2888c007 100644 --- a/os-plugins/plugins/vmware/OpenSLX/Distro/base.pm +++ b/os-plugins/plugins/vmware/OpenSLX/Distro/base.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # base.pm -# - provides empty base of the OpenSLX OSPlugin Distro API for the vmware +# - provides empty base of the OpenSLX OSPlugin Distro API for the vmware # plugin. # ----------------------------------------------------------------------------- package OpenSLX::Distro::base; @@ -17,7 +17,7 @@ package OpenSLX::Distro::base; use strict; use warnings; -our $VERSION = 1.01; # API-version . implementation-version +our $VERSION = 1.01; # API-version . implementation-version use OpenSLX::Basics; use OpenSLX::Utils; @@ -27,15 +27,15 @@ use OpenSLX::Utils; ################################################################################ sub new { - confess "Creating OpenSLX::OSPlugin::Distro::Base-objects directly makes no sense!"; + confess "Creating OpenSLX::OSPlugin::Distro::Base-objects directly makes no sense!"; } sub initialize { - my $self = shift; - my $engine = shift; - - return 1; + my $self = shift; + my $engine = shift; + + return 1; } diff --git a/os-plugins/plugins/vmwarebinary/OpenSLX/OSPlugin/vmwarebinary.pm b/os-plugins/plugins/vmwarebinary/OpenSLX/OSPlugin/vmwarebinary.pm index bf6a9252..5773b1ce 100644 --- a/os-plugins/plugins/vmwarebinary/OpenSLX/OSPlugin/vmwarebinary.pm +++ b/os-plugins/plugins/vmwarebinary/OpenSLX/OSPlugin/vmwarebinary.pm @@ -9,7 +9,7 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # vmwarebinary.pm -# - declares necessary information for the vmware plugin +# - declares necessary information for the vmware plugin # ----------------------------------------------------------------------------- package OpenSLX::OSPlugin::vmwarebinary; @@ -25,106 +25,106 @@ use OpenSLX::Utils; sub new { - my $class = shift; + my $class = shift; - my $self = { - name => 'vmwarebinary', - }; + my $self = { + name => 'vmwarebinary', + }; - return bless $self, $class; + return bless $self, $class; } sub getInfo { - my $self = shift; - - return { - description => unshiftHereDoc(<<' End-of-Here'), - !!! descriptive text missing here !!! - End-of-Here - mustRunAfter => [], - }; + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + !!! descriptive text missing here !!! + End-of-Here + mustRunAfter => [], + }; } sub getAttrInfo -{ # returns a hash-ref with information about all attributes supported - # by this specific plugin - my $self = shift; - - # This default configuration will be added as attributes to the default - # system, such that it can be overruled for any specific system by means - # of slxconfig. - return { - # attribute 'active' is mandatory for all plugins - 'vmwarebinary::active' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'vmwarebinary'-plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - # attribute 'precedence' is mandatory for all plugins - 'vmwarebinary::precedence' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - the execution precedence of the 'vmwarebinary' plugin - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'allowed range is from 01-99', - default => 70, - }, - # attribute 'imagesrc' defines where we can find vmware images - 'vmwarebinary::imagessrc' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - Where do we store our vmware images? NFS? Filesystem? - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'Allowed values: path or URI', - default => "", - }, - - }; +{ # returns a hash-ref with information about all attributes supported + # by this specific plugin + my $self = shift; + + # This default configuration will be added as attributes to the default + # system, such that it can be overruled for any specific system by means + # of slxconfig. + return { + # attribute 'active' is mandatory for all plugins + 'vmwarebinary::active' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'vmwarebinary'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + # attribute 'precedence' is mandatory for all plugins + 'vmwarebinary::precedence' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'vmwarebinary' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 70, + }, + # attribute 'imagesrc' defines where we can find vmware images + 'vmwarebinary::imagessrc' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + Where do we store our vmware images? NFS? Filesystem? + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'Allowed values: path or URI', + default => "", + }, + + }; } sub installationPhase { - my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; - my $openslxPath = shift; + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; + my $openslxPath = shift; - # get path of files we need to install - my $pluginFilesPath = "$openslxPath/lib/plugins/$self->{'name'}/files"; + # get path of files we need to install + my $pluginFilesPath = "$openslxPath/lib/plugins/$self->{'name'}/files"; - # copy all needed files now - my @files = qw( installbinary.sh locations - VMware-player-2.0.2-59824.i386.tar.gz depmod.sh uname.sh - nvram.5.0 insmod.sh runvmware-v2 ); - foreach my $file (@files) { - copyFile("$pluginFilesPath/$file", $pluginRepositoryPath); - } + # copy all needed files now + my @files = qw( installbinary.sh locations + VMware-player-2.0.2-59824.i386.tar.gz depmod.sh uname.sh + nvram.5.0 insmod.sh runvmware-v2 ); + foreach my $file (@files) { + copyFile("$pluginFilesPath/$file", $pluginRepositoryPath); + } - system("/bin/sh /opt/openslx/plugin-repo/$self->{'name'}/installbinary.sh"); + system("/bin/sh /opt/openslx/plugin-repo/$self->{'name'}/installbinary.sh"); - return; + return; } sub removalPhase { - my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; - my $openslxPath = shift; - - rmtree ( [ $pluginRepositoryPath ] ); - - return; + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; + my $openslxPath = shift; + + rmtree ( [ $pluginRepositoryPath ] ); + + return; } 1; diff --git a/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm b/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm index 8accd45d..7d34934f 100644 --- a/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm +++ b/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm @@ -22,214 +22,214 @@ use OpenSLX::Utils; sub new { - my $class = shift; - my $self = { - name => 'x11vnc', - }; + my $class = shift; + my $self = { + name => 'x11vnc', + }; - return bless $self, $class; + return bless $self, $class; } sub getInfo { - my $self = shift; - return { - description => unshiftHereDoc(<<' End-of-Here'), - enables x11vnc server - End-of-Here - mustRunAfter => [], - }; + my $self = shift; + return { + description => unshiftHereDoc(<<' End-of-Here'), + enables x11vnc server + End-of-Here + mustRunAfter => [], + }; } sub getAttrInfo { - my $self = shift; - - return { - 'x11vnc::active' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - should the 'x11vnc' plugin be executed during boot? - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', - default => '1', - }, - - 'x11vnc::precedence' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - the execution precedence of the 'x11vnc' plugin - End-of-Here - content_regex => qr{^\d\d$}, - content_descr => 'allowed range is from 01-99', - default => 50, - }, - - 'x11vnc::mode' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - set x11vnc to listen on X11(default) or console fb - End-of-Here - content_regex => qr{^(x11|fb)$}, - content_descr => 'x11 means listen current X session - fb means listen to tty1 console', - default => 'x11', - }, - - 'x11vnc::scale' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - scale screen size (e.g. as fraction 2/3 or as decimal 0.5) - End-of-Here - content_regex => undef, - content_descr => undef, - default => '', - }, - - 'x11vnc::shared' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - by default x11vnc is always called with the -shared option - End-of-Here - content_regex => qr{^(yes|no|1|0)$}, - content_descr => 'use 1 or yes to enable - 0 or no to disable', - default => 'yes', - }, - - 'x11vnc::force_viewonly' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - disable user interaction with vnc - End-of-Here - content_regex => qr{^(yes|no|1|0)$}, - content_descr => 'use 1 or yes to enable - 0 or no to disable', - default => 'no', - }, - - 'x11vnc::auth_type' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - set authentication type of the vnc connection - End-of-Here - content_regex => qr{^(passwd|rfbauth|none)$}, - content_descr => 'choose: passwd, rfbauth, none', - default => 'passwd', - }, - - 'x11vnc::allowed_hosts' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - set allowed hosts (multiple hosts are seperated by semicolons, (simple) subnets are possible too - e.g. "192.168.") - End-of-Here - content_regex => undef, - content_descr => undef, - default => '', - }, - - 'x11vnc::force_localhost' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - force x11vnc to only accept local connections and only listen on the loopback device - End-of-Here - content_regex => qr{^(1|0|yes|no)$}, - content_descr => 'use 1 or yes to enable - 0 or no to disable', - default => 'no', - }, - - 'x11vnc::pass' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - viewonly password (you can add multiple passwords seperated by semicolons) - (if you're using rfb-auth only the first one is used) - End-of-Here - content_regex => undef, - content_descr => undef, - default => '', - }, - - 'x11vnc::viewonlypass' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - viewonly password (you can add multiple passwords seperated by semicolons) - (disabled with rfb-auth) - End-of-Here - content_regex => undef, - content_descr => undef, - default => 'viewonly', - }, - - 'x11vnc::logging' => { - applies_to_systems => 1, - applies_to_clients => 0, - description => unshiftHereDoc(<<' End-of-Here'), - enable logging - End-of-Here - content_regex => qr{^(1|0|yes|no)$}, - content_descr => 'use 1 or yes to enable - 0 or no to disable', - default => 'yes', - }, - - }; + my $self = shift; + + return { + 'x11vnc::active' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'x11vnc' plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + + 'x11vnc::precedence' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'x11vnc' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 50, + }, + + 'x11vnc::mode' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + set x11vnc to listen on X11(default) or console fb + End-of-Here + content_regex => qr{^(x11|fb)$}, + content_descr => 'x11 means listen current X session - fb means listen to tty1 console', + default => 'x11', + }, + + 'x11vnc::scale' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + scale screen size (e.g. as fraction 2/3 or as decimal 0.5) + End-of-Here + content_regex => undef, + content_descr => undef, + default => '', + }, + + 'x11vnc::shared' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + by default x11vnc is always called with the -shared option + End-of-Here + content_regex => qr{^(yes|no|1|0)$}, + content_descr => 'use 1 or yes to enable - 0 or no to disable', + default => 'yes', + }, + + 'x11vnc::force_viewonly' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + disable user interaction with vnc + End-of-Here + content_regex => qr{^(yes|no|1|0)$}, + content_descr => 'use 1 or yes to enable - 0 or no to disable', + default => 'no', + }, + + 'x11vnc::auth_type' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + set authentication type of the vnc connection + End-of-Here + content_regex => qr{^(passwd|rfbauth|none)$}, + content_descr => 'choose: passwd, rfbauth, none', + default => 'passwd', + }, + + 'x11vnc::allowed_hosts' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + set allowed hosts (multiple hosts are seperated by semicolons, (simple) subnets are possible too + e.g. "192.168.") + End-of-Here + content_regex => undef, + content_descr => undef, + default => '', + }, + + 'x11vnc::force_localhost' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + force x11vnc to only accept local connections and only listen on the loopback device + End-of-Here + content_regex => qr{^(1|0|yes|no)$}, + content_descr => 'use 1 or yes to enable - 0 or no to disable', + default => 'no', + }, + + 'x11vnc::pass' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + viewonly password (you can add multiple passwords seperated by semicolons) + (if you're using rfb-auth only the first one is used) + End-of-Here + content_regex => undef, + content_descr => undef, + default => '', + }, + + 'x11vnc::viewonlypass' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + viewonly password (you can add multiple passwords seperated by semicolons) + (disabled with rfb-auth) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'viewonly', + }, + + 'x11vnc::logging' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + enable logging + End-of-Here + content_regex => qr{^(1|0|yes|no)$}, + content_descr => 'use 1 or yes to enable - 0 or no to disable', + default => 'yes', + }, + + }; } sub installationPhase { - my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; - my $openslxPath = shift; - - # get path of files we need to install - my $pluginFilesPath = "$openslxPath/lib/plugins/$self->{'name'}/files"; - - # copy all needed files now - copyFile("$pluginFilesPath/x11vnc", "/etc/init.d"); - vlog(3, "install init file"); - - if ( !-x "/usr/bin/x11vnc" ) { - # let's install x11vnc - if ( $self->{'os-plugin-engine'}->{'vendor-os-name'} =~ m/(debian|ubuntu)/i ) { - my $cmd = "aptitude -y install x11vnc"; - vlog(3, "executing: $cmd"); - if (slxsystem($cmd)) { - die _tr( - "unable to execute shell-cmd\n\t%s", $cmd - ); - } - } - if ( $self->{'os-plugin-engine'}->{'vendor-os-name'} =~ m/suse/i ) { - # PLEASE TEST THIS!!! - my $cmd = "zypper -n in x11vnc"; - vlog(3, "executing: $cmd"); - if (slxsystem($cmd)) { - die _tr( - "unable to execute shell-cmd\n\t%s", $cmd - ); - } - } - } else { - vlog(3, "x11vnc is already installed"); - } + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; + my $openslxPath = shift; + + # get path of files we need to install + my $pluginFilesPath = "$openslxPath/lib/plugins/$self->{'name'}/files"; + + # copy all needed files now + copyFile("$pluginFilesPath/x11vnc", "/etc/init.d"); + vlog(3, "install init file"); + + if ( !-x "/usr/bin/x11vnc" ) { + # let's install x11vnc + if ( $self->{'os-plugin-engine'}->{'vendor-os-name'} =~ m/(debian|ubuntu)/i ) { + my $cmd = "aptitude -y install x11vnc"; + vlog(3, "executing: $cmd"); + if (slxsystem($cmd)) { + die _tr( + "unable to execute shell-cmd\n\t%s", $cmd + ); + } + } + if ( $self->{'os-plugin-engine'}->{'vendor-os-name'} =~ m/suse/i ) { + # PLEASE TEST THIS!!! + my $cmd = "zypper -n in x11vnc"; + vlog(3, "executing: $cmd"); + if (slxsystem($cmd)) { + die _tr( + "unable to execute shell-cmd\n\t%s", $cmd + ); + } + } + } else { + vlog(3, "x11vnc is already installed"); + } } sub removalPhase { - my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; } 1; diff --git a/os-plugins/slxos-plugin b/os-plugins/slxos-plugin index 4f242ad1..e94be5d4 100755 --- a/os-plugins/slxos-plugin +++ b/os-plugins/slxos-plugin @@ -37,22 +37,22 @@ use OpenSLX::Utils; my %option; GetOptions( - 'help|?' => \$option{helpReq}, - 'man' => \$option{manReq}, - 'verbose' => \$option{verbose}, - 'version' => \$option{versionReq}, - ) + 'help|?' => \$option{helpReq}, + 'man' => \$option{manReq}, + 'verbose' => \$option{verbose}, + 'version' => \$option{versionReq}, +) or pod2usage(2); pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $option{helpReq}; if ($option{manReq}) { - # avoid dubious problem with perldoc in combination with UTF-8 that - # leads to strange dashes and single-quotes being used - $ENV{LC_ALL} = 'POSIX'; - pod2usage(-verbose => 2); + # avoid dubious problem with perldoc in combination with UTF-8 that + # leads to strange dashes and single-quotes being used + $ENV{LC_ALL} = 'POSIX'; + pod2usage(-verbose => 2); } if ($option{versionReq}) { - system('slxversion'); - exit 1; + system('slxversion'); + exit 1; } openslxInit(); @@ -60,239 +60,239 @@ openslxInit(); my $action = shift @ARGV || ''; if ($action =~ m[^list-at]i) { - my $plugin = shift @ARGV; - print - $plugin - ? _tr("List of attributes supported by '%s' plugin:\n", $plugin) - : _tr("List of plugin attributes:\n"); - my $attrs = {}; - require OpenSLX::OSPlugin::Roster; - OpenSLX::OSPlugin::Roster->addAllAttributesToHash($attrs, $plugin); - print join( - '', - map { - my $attr = $attrs->{$_}; - my $stage - = $attr->{applies_to_vendor_os} ? '[stage 1]' : '[stage 3]'; - - if ($option{verbose}) { - my $output; - my $fill = ' ' x 28; - for my $key (qw( description content_descr content_regex )) { - $output .= "\n\t $key:" . ( ' ' x (15 - length($key)) ); - chomp(my $value = $attr->{$key} || ''); - $value =~ s{\n}{\n$fill}igms; - $output .= $value; - } - "\n\t$stage: $_$output\n"; - } - else { - "\t$stage: $_\n"; - } - } - sort { - my $stageDiff - = ($attrs->{$b}->{applies_to_vendor_os} || '') - cmp ($attrs->{$a}->{applies_to_vendor_os} || ''); - return $stageDiff ? $stageDiff : $a cmp $b; - } - keys %$attrs - ); + my $plugin = shift @ARGV; + print + $plugin + ? _tr("List of attributes supported by '%s' plugin:\n", $plugin) + : _tr("List of plugin attributes:\n"); + my $attrs = {}; + require OpenSLX::OSPlugin::Roster; + OpenSLX::OSPlugin::Roster->addAllAttributesToHash($attrs, $plugin); + print join( + '', + map { + my $attr = $attrs->{$_}; + my $stage + = $attr->{applies_to_vendor_os} ? '[stage 1]' : '[stage 3]'; + + if ($option{verbose}) { + my $output; + my $fill = ' ' x 28; + for my $key (qw( description content_descr content_regex )) { + $output .= "\n\t $key:" . ( ' ' x (15 - length($key)) ); + chomp(my $value = $attr->{$key} || ''); + $value =~ s{\n}{\n$fill}igms; + $output .= $value; + } + "\n\t$stage: $_$output\n"; + } + else { + "\t$stage: $_\n"; + } + } + sort { + my $stageDiff + = ($attrs->{$b}->{applies_to_vendor_os} || '') + cmp ($attrs->{$a}->{applies_to_vendor_os} || ''); + return $stageDiff ? $stageDiff : $a cmp $b; + } + keys %$attrs + ); } elsif ($action =~ m[^list-av]i) { - print _tr("List of available plugins:\n"); - require OpenSLX::OSPlugin::Roster; - my $pluginInfo = OpenSLX::OSPlugin::Roster->getAvailablePlugins(); - print join( - '', - map { - if ($option{verbose}) { - my $fill = ' ' x 12; - chomp(my $descr = $pluginInfo->{$_}->{description} || ''); - $descr =~ s{\n}{\n$fill}igms; - "\n\t$_\n\t $descr\n"; - } - else { - "\t$_\n"; - } - } - sort keys %$pluginInfo - ); + print _tr("List of available plugins:\n"); + require OpenSLX::OSPlugin::Roster; + my $pluginInfo = OpenSLX::OSPlugin::Roster->getAvailablePlugins(); + print join( + '', + map { + if ($option{verbose}) { + my $fill = ' ' x 12; + chomp(my $descr = $pluginInfo->{$_}->{description} || ''); + $descr =~ s{\n}{\n$fill}igms; + "\n\t$_\n\t $descr\n"; + } + else { + "\t$_\n"; + } + } + sort keys %$pluginInfo + ); } elsif ($action =~ m[^list-i]i) { - if (scalar(@ARGV) != 1) { - print STDERR _tr( - "You need to specify exactly one vendor-OS!\n" - ); - pod2usage(2); - } - my $vendorOSName = shift @ARGV; - - # we chdir into the script's folder such that all relative paths have - # a known starting point: - chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); - - # create OSPlugin-engine for given vendor-OS and ask it for the installed - # plugins: - my $engine = OpenSLX::OSPlugin::Engine->new; - $engine->initialize(undef, $vendorOSName); - my @installedPlugins = $engine->getInstalledPlugins(); - - if (!@installedPlugins) { - push @installedPlugins, { plugin_name => '' }; - } - print _tr("List of plugins installed in vendor-OS '$vendorOSName':\n"); - print join( - '', - map { - if ($option{verbose}) { - my $attributes - = _tr("The following attributes were applied:") - . "\n\t "; - my $attrs = $_->{attrs}; - my $attrInfo = {}; - OpenSLX::OSPlugin::Roster->addAllStage1AttributesToHash( - $attrInfo, $_->{plugin_name} - ); - $attributes .= join( - "\n\t ", - map { - my $stage - = $attrInfo->{$_}->{applies_to_vendor_os} - ? '[stage 1]' - : '[stage 3]'; - "$stage $_=" - . (defined $attrs->{$_} ? $attrs->{$_} : '-') - } - sort { - (($attrInfo->{$b}->{applies_to_vendor_os} || '') - cmp ($attrInfo->{$a}->{applies_to_vendor_os} || '')) - || ($a cmp $b); - } - keys %$attrs - ); - "\n\t$_->{plugin_name}\n\t $attributes\n"; - } - else { - "\t$_->{plugin_name}\n"; - } - } - sort @installedPlugins - ); + if (scalar(@ARGV) != 1) { + print STDERR _tr( + "You need to specify exactly one vendor-OS!\n" + ); + pod2usage(2); + } + my $vendorOSName = shift @ARGV; + + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + + # create OSPlugin-engine for given vendor-OS and ask it for the installed + # plugins: + my $engine = OpenSLX::OSPlugin::Engine->new; + $engine->initialize(undef, $vendorOSName); + my @installedPlugins = $engine->getInstalledPlugins(); + + if (!@installedPlugins) { + push @installedPlugins, { plugin_name => '' }; + } + print _tr("List of plugins installed in vendor-OS '$vendorOSName':\n"); + print join( + '', + map { + if ($option{verbose}) { + my $attributes + = _tr("The following attributes were applied:") + . "\n\t "; + my $attrs = $_->{attrs}; + my $attrInfo = {}; + OpenSLX::OSPlugin::Roster->addAllStage1AttributesToHash( + $attrInfo, $_->{plugin_name} + ); + $attributes .= join( + "\n\t ", + map { + my $stage + = $attrInfo->{$_}->{applies_to_vendor_os} + ? '[stage 1]' + : '[stage 3]'; + "$stage $_=" + . (defined $attrs->{$_} ? $attrs->{$_} : '-') + } + sort { + (($attrInfo->{$b}->{applies_to_vendor_os} || '') + cmp ($attrInfo->{$a}->{applies_to_vendor_os} || '')) + || ($a cmp $b); + } + keys %$attrs + ); + "\n\t$_->{plugin_name}\n\t $attributes\n"; + } + else { + "\t$_->{plugin_name}\n"; + } + } + sort @installedPlugins + ); } elsif ($action =~ m[^install]i) { - if (scalar(@ARGV) < 2) { - print STDERR _tr( - "You need to specify a vendor-OS and at least one plugin-name!\n" - ); - pod2usage(2); - } - my $vendorOSName = shift @ARGV; - my $pluginAttrs = parsePluginAttrs(1); - - # we chdir into the script's folder such that all relative paths have - # a known starting point: - chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); - - for my $pluginName (keys %$pluginAttrs) { - # create & start OSPlugin-engine for vendor-OS and current plugin: - my $engine = OpenSLX::OSPlugin::Engine->new; - $engine->initialize( - $pluginName, $vendorOSName, $pluginAttrs->{$pluginName} - ); - if (!-e $engine->{'plugin-path'}) { - die _tr("plugin '%s' doesn't exist, giving up!\n", - $engine->{'plugin-path'}); - } - if ($vendorOSName ne '<<>>' - && !-e $engine->{'vendor-os-path'}) { - die _tr( - "vendor-OS '%s' doesn't exist, giving up!\n", - $engine->{'vendor-os-path'} - ); - } - if ($engine->installPlugin()) { - print _tr( - "Plugin $pluginName has been installed into vendor-OS '$vendorOSName'.\n" - ); - } - } + if (scalar(@ARGV) < 2) { + print STDERR _tr( + "You need to specify a vendor-OS and at least one plugin-name!\n" + ); + pod2usage(2); + } + my $vendorOSName = shift @ARGV; + my $pluginAttrs = parsePluginAttrs(1); + + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + + for my $pluginName (keys %$pluginAttrs) { + # create & start OSPlugin-engine for vendor-OS and current plugin: + my $engine = OpenSLX::OSPlugin::Engine->new; + $engine->initialize( + $pluginName, $vendorOSName, $pluginAttrs->{$pluginName} + ); + if (!-e $engine->{'plugin-path'}) { + die _tr("plugin '%s' doesn't exist, giving up!\n", + $engine->{'plugin-path'}); + } + if ($vendorOSName ne '<<>>' + && !-e $engine->{'vendor-os-path'}) { + die _tr( + "vendor-OS '%s' doesn't exist, giving up!\n", + $engine->{'vendor-os-path'} + ); + } + if ($engine->installPlugin()) { + print _tr( + "Plugin $pluginName has been installed into vendor-OS '$vendorOSName'.\n" + ); + } + } } elsif ($action =~ m[^remove]i) { - if (scalar(@ARGV) < 2) { - print STDERR _tr( - "You need to specify a vendor-OS and at least one plugin-name!\n" - ); - pod2usage(2); - } - my $vendorOSName = shift @ARGV; - my $pluginAttrs = parsePluginAttrs(0); - - # we chdir into the script's folder such that all relative paths have - # a known starting point: - chdir($FindBin::RealBin) - or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); - - for my $pluginName (keys %$pluginAttrs) { - # create & start OSPlugin-engine for vendor-OS and current plugin: - my $engine = OpenSLX::OSPlugin::Engine->new; - $engine->initialize( - $pluginName, $vendorOSName, $pluginAttrs->{$pluginName} - ); - if (!-e $engine->{'plugin-path'}) { - die _tr("plugin '%s' doesn't exist, giving up!\n", - $engine->{'plugin-path'}); - } - if ($vendorOSName ne '<<>>' && !-e $engine->{'vendor-os-path'}) { - die _tr("vendor-OS '%s' doesn't exist, giving up!\n", - $engine->{'vendor-os-path'}); - } - if ($engine->removePlugin()) { - print _tr( - "Plugin $pluginName has been removed from vendor-OS '$vendorOSName'.\n" - ); - } - } + if (scalar(@ARGV) < 2) { + print STDERR _tr( + "You need to specify a vendor-OS and at least one plugin-name!\n" + ); + pod2usage(2); + } + my $vendorOSName = shift @ARGV; + my $pluginAttrs = parsePluginAttrs(0); + + # we chdir into the script's folder such that all relative paths have + # a known starting point: + chdir($FindBin::RealBin) + or die _tr("can't chdir to script-path <%> (%s)", $FindBin::RealBin, $!); + + for my $pluginName (keys %$pluginAttrs) { + # create & start OSPlugin-engine for vendor-OS and current plugin: + my $engine = OpenSLX::OSPlugin::Engine->new; + $engine->initialize( + $pluginName, $vendorOSName, $pluginAttrs->{$pluginName} + ); + if (!-e $engine->{'plugin-path'}) { + die _tr("plugin '%s' doesn't exist, giving up!\n", + $engine->{'plugin-path'}); + } + if ($vendorOSName ne '<<>>' && !-e $engine->{'vendor-os-path'}) { + die _tr("vendor-OS '%s' doesn't exist, giving up!\n", + $engine->{'vendor-os-path'}); + } + if ($engine->removePlugin()) { + print _tr( + "Plugin $pluginName has been removed from vendor-OS '$vendorOSName'.\n" + ); + } + } } else { - vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0)); - You need to specify exactly one action: - install [= ...] - list-attributes [] - list-available - list-installed - remove - Try '%s --help' for more info. - END-OF-HERE + vlog(0, _tr(unshiftHereDoc(<<' END-OF-HERE'), $0)); + You need to specify exactly one action: + install [= ...] + list-attributes [] + list-available + list-installed + remove + Try '%s --help' for more info. + END-OF-HERE } sub parsePluginAttrs { - my $acceptAttributes = shift; - - my (%pluginAttrs, $pluginName, @attrSpecs); - for my $arg (@ARGV) { - if ($arg =~ m{^(.+)=(.*)$}) { - next if !$acceptAttributes; - my $attr = $1; - my $value = $2; - if ($value =~ m{^(-|undef)$}) { - $value = undef; - } - if ($attr =~ m{^(.+)::}) { - $pluginName = $1; - } - else { - if (!defined $pluginName) { - die _tr('You have to give a plugin-name before you can specify unscoped attributes!'); - } - $attr = $pluginName . '::' . $attr; - } - $pluginAttrs{$pluginName}->{$attr} = $value; - } - else { - $pluginName = $arg; - $pluginAttrs{$pluginName} = {}; - } - } - return \%pluginAttrs; + my $acceptAttributes = shift; + + my (%pluginAttrs, $pluginName, @attrSpecs); + for my $arg (@ARGV) { + if ($arg =~ m{^(.+)=(.*)$}) { + next if !$acceptAttributes; + my $attr = $1; + my $value = $2; + if ($value =~ m{^(-|undef)$}) { + $value = undef; + } + if ($attr =~ m{^(.+)::}) { + $pluginName = $1; + } + else { + if (!defined $pluginName) { + die _tr('You have to give a plugin-name before you can specify unscoped attributes!'); + } + $attr = $pluginName . '::' . $attr; + } + $pluginAttrs{$pluginName}->{$attr} = $value; + } + else { + $pluginName = $arg; + $pluginAttrs{$pluginName} = {}; + } + } + return \%pluginAttrs; } =head1 NAME -- cgit v1.2.3-55-g7522