From d7e11726bbd2f8ce5fb6d756fd9bad9a709d988f Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sat, 15 Mar 2008 18:35:27 +0000 Subject: * intermediate checking for new desktop plugin (successor of displaymanager with extended scope) - does not work yet, so please do not use! git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1634 95ad53e4-c205-0410-b2fa-d234c58c8868 --- os-plugins/OpenSLX/OSPlugin/Base.pm | 17 + os-plugins/OpenSLX/OSPlugin/Engine.pm | 61 +++- os-plugins/plugins/desktop/OpenSLX/Distro/base.pm | 170 +++++++++ .../plugins/desktop/OpenSLX/Distro/debian.pm | 116 ++++++ .../plugins/desktop/OpenSLX/Distro/fedora.pm | 48 +++ .../plugins/desktop/OpenSLX/Distro/gentoo.pm | 58 +++ os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm | 27 ++ .../plugins/desktop/OpenSLX/Distro/ubuntu.pm | 100 ++++++ .../plugins/desktop/OpenSLX/OSPlugin/desktop.pm | 398 +++++++++++++++++++++ os-plugins/plugins/desktop/XX_desktop.sh | 34 ++ 10 files changed, 1019 insertions(+), 10 deletions(-) create mode 100644 os-plugins/plugins/desktop/OpenSLX/Distro/base.pm create mode 100644 os-plugins/plugins/desktop/OpenSLX/Distro/debian.pm create mode 100644 os-plugins/plugins/desktop/OpenSLX/Distro/fedora.pm create mode 100644 os-plugins/plugins/desktop/OpenSLX/Distro/gentoo.pm create mode 100644 os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm create mode 100644 os-plugins/plugins/desktop/OpenSLX/Distro/ubuntu.pm create mode 100644 os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm create mode 100644 os-plugins/plugins/desktop/XX_desktop.sh (limited to 'os-plugins') diff --git a/os-plugins/OpenSLX/OSPlugin/Base.pm b/os-plugins/OpenSLX/OSPlugin/Base.pm index f1854f2e..5da72f2a 100644 --- a/os-plugins/OpenSLX/OSPlugin/Base.pm +++ b/os-plugins/OpenSLX/OSPlugin/Base.pm @@ -94,6 +94,7 @@ sub initialize my $self = shift; $self->{'os-plugin-engine'} = shift; + $self->{'distro'} = shift; return; } @@ -158,6 +159,22 @@ sub getAttrInfo }; } +=item getDefaultAttrsForVendorOS() + +Returns a hash-ref with the default attribute values for the given vendor-OS. + + + +=cut + +sub getDefaultAttrsForVendorOS +{ + my $self = shift; + + # the default implementation does not change the default values at all: + return $self->getAttrInfo(); +} + =back =head2 Vendor-OS Interface diff --git a/os-plugins/OpenSLX/OSPlugin/Engine.pm b/os-plugins/OpenSLX/OSPlugin/Engine.pm index d42141a7..6211bacd 100644 --- a/os-plugins/OpenSLX/OSPlugin/Engine.pm +++ b/os-plugins/OpenSLX/OSPlugin/Engine.pm @@ -81,6 +81,11 @@ sub initialize = "$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'}; @@ -104,8 +109,13 @@ sub initialize $pluginName, join(',', @unknownAttrs) ); } + + # merge attributes that were not given on cmdline with the ones that + # already exists in the DB and finally with the default values $self->{'plugin-attrs'} = $givenAttrs; - my $defaultAttrs = $self->{plugin}->getAttrInfo(); + my $defaultAttrs = $self->{plugin}->getDefaultAttrsForVendorOS( + $vendorOSName + ); my $dbAttrs = $self->_fetchInstalledPluginAttrs($vendorOSName); for my $attrName (keys %$defaultAttrs) { next if exists $givenAttrs->{$attrName}; @@ -314,6 +324,15 @@ sub getInstalledPackages return $metaPackager->getInstalledPackages(); } +sub getPackagesForSelection +{ + my $self = shift; + my $selection = shift; + + return $self->{'ossetup-engine'}->getPackagesForSelection($selection); +} + + =item installPackages($packages) Installs the given packages into the vendor-OS. @@ -395,7 +414,30 @@ sub _loadPlugin ); return if !$plugin; - $plugin->initialize($self); + # if there's a distro folder, instantiate the most appropriate distro class + my $distro; + if (-d "$self->{'plugin-path'}/OpenSLX/Distro") { + 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) { +print "trying $distroModule...\n"; + last if eval { + $distro = instantiateClass( + $distroModule, { pathToClass => $self->{'plugin-path'} } + ); + 1; + }; + } + } + + $plugin->initialize($self, $distro); return $plugin; } @@ -405,11 +447,6 @@ sub _callChrootedFunctionForPlugin my $self = shift; my $function = shift; - # create ossetup-engine for given vendor-OS: - my $osSetupEngine = OpenSLX::OSSetup::Engine->new; - $osSetupEngine->initialize($self->{'vendor-os-name'}, 'plugin'); - $self->{'os-setup-engine'} = $osSetupEngine; - # bind-mount openslx basepath to /mnt/openslx of vendor-OS: my $basePath = $openslxConfig{'base-path'}; my $openslxPathInChroot = "$self->{'vendor-os-path'}/mnt/openslx"; @@ -424,14 +461,18 @@ sub _callChrootedFunctionForPlugin } # now let plugin install itself into vendor-OS - $self->{'os-setup-engine'}->callChrootedFunctionForVendorOS($function); + my $ok = eval { + $self->{'ossetup-engine'}->callChrootedFunctionForVendorOS($function); + }; if (slxsystem("umount $openslxPathInChroot")) { croak(_tr("unable to umount '%s'! (%s)", $openslxPathInChroot, $!)); } - delete $self->{'os-setup-engine'}; - + if (!$ok) { + die $@; + } + return; } diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/base.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/base.pm new file mode 100644 index 00000000..b8c7bd8a --- /dev/null +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/base.pm @@ -0,0 +1,170 @@ +# Copyright (c) 2008 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# base.pm +# - provides empty base of the OpenSLX OSPlugin Distro API for the desktop +# plugin. +# ----------------------------------------------------------------------------- +package OpenSLX::Distro::base; + +use strict; +use warnings; + +our $VERSION = 1.01; # API-version . implementation-version + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + confess "Creating OpenSLX::OSPlugin::Distro::Base-objects directly makes no sense!"; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + return 1; +} + +sub isInPath +{ + my $self = shift; + my $binary = shift; + + my $path = qx{which $binary 2>/dev/null}; + + return $path ? 1 : 0; +} + +sub isKDEInstalled +{ + my $self = shift; + + return $self->isInPath('startkde'); +} + +sub isKDMInstalled +{ + my $self = shift; + + return $self->isInPath('kdm'); +} + +sub isGNOMEInstalled +{ + my $self = shift; + + return $self->isInPath('gnome-session'); +} + +sub isGDMInstalled +{ + my $self = shift; + + return $self->isInPath('gdm'); +} + +sub GDMPathInfo +{ + my $self = shift; + + my $pathInfo = { + config => '/etc/gdm/gdm.conf', + paths => [ + '/var/lib/gdm', + '/var/log/gdm', + ], + }; + + 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', + }, + }; +} + +sub GDMConfigHashForKiosk +{ + my $self = shift; + + my $configHash = $self->GDMConfigHashForWorkstation(); + + $configHash->{daemon}->{AutomaticLoginEnable} = 'true'; + $configHash->{daemon}->{AutomaticLogin} = 'nobody'; + + return $configHash; +} + +sub GDMConfigHashForChooser +{ + my $self = shift; + + my $configHash = $self->GDMConfigHashForWorkstation(); + $configHash->{xdmcp}->{Enable} = 'true'; + + return $configHash; +} + +sub isXFCEInstalled +{ + my $self = shift; + + # TODO: implement this! + warn "someone please implement this!"; + return 0; +} + +sub isXDMInstalled +{ + my $self = shift; + + return $self->isInPath('xdm'); +} + +1; diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/debian.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/debian.pm new file mode 100644 index 00000000..a514f10f --- /dev/null +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/debian.pm @@ -0,0 +1,116 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# Debian.pm +# - provides Debian-specific overrides of the OpenSLX OSSetup API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Debian; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->SUPER::initialize($engine); + $self->{'packager-type'} = 'dpkg'; + $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'apt'; + $self->{'stage1c-faked-files'} = []; + return; +} + +sub preSystemInstallationHook +{ + my $self = shift; + + $self->SUPER::preSystemInstallationHook(); + + # fake required /dev-entries + my %devInfo = ( + mem => { type => 'c', major => '1', minor => '1' }, + null => { type => 'c', major => '1', minor => '3' }, + zero => { type => 'c', major => '1', minor => '5' }, + random => { type => 'c', major => '1', minor => '8' }, + urandom => { type => 'c', major => '1', minor => '9' }, + kmsg => { type => 'c', major => '1', minor => '11' }, + console => { type => 'c', major => '5', minor => '1' }, + ptmx => { type => 'c', major => '5', minor => '2' }, + ); + foreach my $dev (keys %devInfo) { + my $info = $devInfo{$dev}; + if (!-e "/dev/$dev") { + if (slxsystem( + "mknod /dev/$dev $info->{type} $info->{major} $info->{minor}" + )) { + croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!)); + } + } + } + foreach my $devDir ('pts', 'shm', '.udevdb', '.udev') { + if (!-e "/dev/$devDir") { + if (slxsystem("mkdir -p /dev/$devDir")) { + croak(_tr("unable to create dev-dir '%s'! (%s)", $devDir, $!)); + } + } + } + + # replace /usr/sbin/invoke-rc.d by a dummy, in order to avoid a whole lot + # of initscripts being started. Wishful thinking: there should be another + # way to stop Debian from doing this, as this is not really very supportive + # of folder-based installations (then again: I may simply be too stupid + # to find out how it is supposed to work ...) + rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d'); + spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n"); + chmod 0755, '/usr/sbin/invoke-rc.d'; +} + +sub postSystemInstallationHook +{ + my $self = shift; + + # restore /usr/sbin/invoke-rc.d + rename('/usr/sbin/_invoke-rc.d', '/usr/sbin/invoke-rc.d'); + $self->SUPER::postSystemInstallationHook(); +} + +sub setPasswordForUser +{ + my $self = shift; + my $username = shift; + my $password = shift; + + # activate shadow passwords + my $activateShadowFunction = sub { + slxsystem('/sbin/shadowconfig', 'on'); + }; + $self->{engine}->callChrootedFunctionForVendorOS($activateShadowFunction); + + # invoke default behaviour + $self->SUPER::setPasswordForUser($username, $password); +} + +1; \ No newline at end of file diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/fedora.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/fedora.pm new file mode 100644 index 00000000..7fe4973c --- /dev/null +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/fedora.pm @@ -0,0 +1,48 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# Fedora.pm +# - provides Fedora-specific overrides of the OpenSLX OSSetup API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Fedora; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + 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; +} + +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 new file mode 100644 index 00000000..4d1032f7 --- /dev/null +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/gentoo.pm @@ -0,0 +1,58 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# SUSE.pm +# - provides SUSE-specific overrides of the OpenSLX OSSetup API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Gentoo; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + 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; +} + +1; diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm new file mode 100644 index 00000000..34363460 --- /dev/null +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/suse.pm @@ -0,0 +1,27 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# SUSE.pm +# - provides SUSE-specific overrides of the OpenSLX OSSetup API. +# ----------------------------------------------------------------------------- +package OpenSLX::Distro::suse; + +use strict; +use warnings; + +use base qw(OpenSLX::Distro::base); + +use OpenSLX::Basics; + +################################################################################ +### interface methods +################################################################################ + +1; diff --git a/os-plugins/plugins/desktop/OpenSLX/Distro/ubuntu.pm b/os-plugins/plugins/desktop/OpenSLX/Distro/ubuntu.pm new file mode 100644 index 00000000..4ab5abbc --- /dev/null +++ b/os-plugins/plugins/desktop/OpenSLX/Distro/ubuntu.pm @@ -0,0 +1,100 @@ +# Copyright (c) 2006, 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# Ubuntu.pm +# - provides Ubuntu-specific overrides of the OpenSLX OSSetup API. +# ----------------------------------------------------------------------------- +package OpenSLX::OSSetup::Distro::Ubuntu; + +use strict; +use warnings; + +use base qw(OpenSLX::OSSetup::Distro::Base); + +use OpenSLX::Basics; +use OpenSLX::Utils; + +################################################################################ +### interface methods +################################################################################ +sub new +{ + my $class = shift; + my $self = {}; + return bless $self, $class; +} + +sub initialize +{ + my $self = shift; + my $engine = shift; + + $self->SUPER::initialize($engine); + $self->{'packager-type'} = 'dpkg'; + $self->{'meta-packager-type'} = $ENV{SLX_META_PACKAGER} || 'apt'; + $self->{'stage1c-faked-files'} = []; + return; +} + +sub preSystemInstallationHook +{ + my $self = shift; + + $self->SUPER::preSystemInstallationHook(); + + # fake required /dev-entries + my %devInfo = ( + mem => { type => 'c', major => '1', minor => '1' }, + null => { type => 'c', major => '1', minor => '3' }, + zero => { type => 'c', major => '1', minor => '5' }, + random => { type => 'c', major => '1', minor => '8' }, + urandom => { type => 'c', major => '1', minor => '9' }, + kmsg => { type => 'c', major => '1', minor => '11' }, + console => { type => 'c', major => '5', minor => '1' }, + ptmx => { type => 'c', major => '5', minor => '2' }, + ); + foreach my $dev (keys %devInfo) { + my $info = $devInfo{$dev}; + if (!-e "/dev/$dev") { + if (slxsystem( + "mknod /dev/$dev $info->{type} $info->{major} $info->{minor}" + )) { + croak(_tr("unable to create dev-node '%s'! (%s)", $dev, $!)); + } + } + } + foreach my $devDir ('pts', 'shm', '.udevdb', '.udev') { + if (!-e "/dev/$devDir") { + if (slxsystem("mkdir -p /dev/$devDir")) { + croak(_tr("unable to create dev-dir '%s'! (%s)", $devDir, $!)); + } + } + } + + # replace /usr/sbin/invoke-rc.d by a dummy, in order to avoid a whole lot + # of initscripts being started. Wishful thinking: there should be another + # way to stop Ubuntu from doing this, as this is not really very supportive + # of folder-based installations (then again: I may simply be too stupid + # to find out how it is supposed to work ...) + rename('/usr/sbin/invoke-rc.d', '/usr/sbin/_invoke-rc.d'); + spitFile('/usr/sbin/invoke-rc.d', "#! /bin/sh\nexit 0\n"); + chmod 0755, '/usr/sbin/invoke-rc.d'; +} + +sub postSystemInstallationHook +{ + my $self = shift; + + # restore /usr/sbin/invoke-rc.d + rename('/usr/sbin/_invoke-rc.d', '/usr/sbin/invoke-rc.d'); + $self->SUPER::postSystemInstallationHook(); +} + +1; \ No newline at end of file diff --git a/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm new file mode 100644 index 00000000..a0dc589c --- /dev/null +++ b/os-plugins/plugins/desktop/OpenSLX/OSPlugin/desktop.pm @@ -0,0 +1,398 @@ +# Copyright (c) 2008 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# desktop.pm +# - implementation of the 'desktop' plugin, which installs +# all needed information for a displaymanager and for the desktop. +# ----------------------------------------------------------------------------- +package OpenSLX::OSPlugin::desktop; + +use strict; +use warnings; + +use base qw(OpenSLX::OSPlugin::Base); + +use File::Basename; +use File::Path; + +use OpenSLX::Basics; +use OpenSLX::Utils; + +sub new +{ + my $class = shift; + + my $self = { + name => 'desktop', + }; + + 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 => [], + }; +} + +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, 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, xfce, ...) + End-of-Here + content_regex => undef, + 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: kiosk, workstation, remote-desktop, ...?) + End-of-Here + content_regex => undef, + content_descr => 'allowed: ...', + default => 'workstation', + }, + 'desktop::theme' => { + applies_to_systems => 1, + description => unshiftHereDoc(<<' End-of-Here'), + name of the theme to apply to the desktop (unset for no theme) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'openslx', + }, + '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 => undef, + content_descr => '1 or 0', + 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 => undef, + content_descr => '1 or 0', + 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 => undef, + content_descr => '1 or 0', + 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 => undef, + content_descr => '1 or 0', + 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 => undef, + content_descr => '1 or 0', + 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 => undef, + content_descr => '1 or 0', + 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; +} + +sub installationPhase +{ + my $self = shift; + + $self->{pluginRepositoryPath} = shift; + $self->{pluginTempPath} = shift; + $self->{openslxPath} = shift; + $self->{attrs} = shift; + + $self->_installRequiredPackages(); + $self->_determineAttrsByInstalledPackages(); + +use Data::Dumper; print Dumper $self->{attrs}; + + if ($self->{attrs}->{'desktop::gdm'}) { + $self->_setupGDM(); + } + if ($self->{attrs}->{'desktop::kdm'}) { + $self->_setupKDM(); + } + if ($self->{attrs}->{'desktop::xdm'}) { + $self->_setupXDM(); + } + + return; +} + +sub removalPhase +{ + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; + + return; +} + +sub copyRequiredFilesIntoInitramfs +{ + 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) { + $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( + "cp -a $xdmcpConfigDir $targetPath/usr/share/files" + ); + } + } + else { + $desktopTheme = ''; + } + + vlog( + 1, + _tr( + "desktop-plugin: desktop=%s", + $desktopTheme + ) + ); + + return; +} + +sub _installRequiredPackages +{ + my $self = shift; + + my $engine = $self->{'os-plugin-engine'}; + + for my $desktop (qw( gnome kde xfce )) { + next if !$self->{attrs}->{"desktop::$desktop"}; + my $packages = $engine->getPackagesForSelection($desktop); + $engine->installPackages($packages); + } + + for my $dm (qw( gdm kdm xdm )) { + next if !$self->{attrs}->{"desktop::$dm"}; + $engine->installPackages($dm); + } + + return 1; +} + +sub _determineAttrsByInstalledPackages +{ + my $self = shift; + my $attrs = shift; + + if (!defined $attrs->{'desktop::gnome'}) { + $attrs->{'desktop::gnome'} = $self->{distro}->isGNOMEInstalled(); + } + if (!defined $attrs->{'desktop::gdm'}) { + $attrs->{'desktop::gdm'} = $self->{distro}->isGDMInstalled(); + } + if (!defined $attrs->{'desktop::kde'}) { + $attrs->{'desktop::kde'} = $self->{distro}->isKDEInstalled(); + } + if (!defined $attrs->{'desktop::kdm'}) { + $attrs->{'desktop::kdm'} = $self->{distro}->isKDMInstalled(); + } + if (!defined $attrs->{'desktop::xfce'}) { + $attrs->{'desktop::xfde'} = $self->{distro}->isXFCEInstalled(); + } + if (!defined $attrs->{'desktop::xdm'}) { + $attrs->{'desktop::xdm'} = $self->{distro}->isXDMInstalled(); + } + + return 1; +} + +sub _setupGDM +{ + my $self = shift; + my $attrs = shift; + + my $repoPath = $self->{pluginRepositoryPath}; + mkpath([ "$repoPath/gdm" ]); + + 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(' ', ( dirname($configFile), @{$pathInfo->{paths}} )); + my $script = unshiftHereDoc(<<" End-of-Here"); + #!/bin/ash + # written by OpenSLX-plugin 'desktop' + mkdir -p $paths + ln -sf /mnt$repoPath/gdm/\$desktop_kind/gdm.conf $configFile + End-of-Here + spitFile("$repoPath/gdm/desktop.sh", $script); + return; +} + +sub _setupKDM +{ + my $self = shift; + my $attrs = shift; + +} + +sub _setupXDM +{ + 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"; + } + } + spitFile($file, $content); +} + +1; diff --git a/os-plugins/plugins/desktop/XX_desktop.sh b/os-plugins/plugins/desktop/XX_desktop.sh new file mode 100644 index 00000000..0a4a3267 --- /dev/null +++ b/os-plugins/plugins/desktop/XX_desktop.sh @@ -0,0 +1,34 @@ +#! /bin/sh +# +# stage3 part of 'displaymanager' plugin - the runlevel script +# +. /etc/functions +. /etc/distro-functions +. /etc/sysconfig/config +if [ -e /initramfs/plugin-conf/displaymanager.conf ]; then + . /initramfs/plugin-conf/displaymanager.conf + if [ $displaymanager_active -ne 0 ]; then + [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'displaymanager' os-plugin ..."; + + testmkd /mnt/var/lib/openslx/themes + testmkd /mnt/var/lib/openslx/config + + if [ "${displaymanager_xdmcp}" = "gdm" ]; then + cp /usr/share/config/gdm.conf /mnt/etc/gdm/gdm.conf + cp -a /usr/share/themes/gdm /mnt/var/lib/openslx/themes + sed -i "s,GraphicalThemeDir=.*,GraphicalThemeDir=/var/lib/openslx/themes," \ + /mnt/etc/gdm/gdm.conf + sed -i "s,GraphicalTheme=.*GraphicalTheme=gdm," /mnt/etc/gdm/gdm.conf + fi + + if [ "${displaymanager_xdmcp}" = "kdm" ]; then + cp /usr/share/config/kdmrc /mnt/etc/kde3/kdm/kdmrc + cp -a /usr/share/themes/kdm /mnt/var/lib/openslx/themes + sed -i "s,Theme=.*,Theme=/var/lib/openslx/themes/kdm," /mnt/etc/kde3/kdm/kdmrc + sed -i "s,UseTheme=.*,UseTheme=true," /mnt/etc/kde3/kdm/kdmrc + fi + + [ $DEBUGLEVEL -gt 0 ] && echo "done with 'displaymanager' os-plugin ..."; + + fi +fi -- cgit v1.2.3-55-g7522