summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins
diff options
context:
space:
mode:
authorOliver Tappe2007-07-03 01:48:23 +0200
committerOliver Tappe2007-07-03 01:48:23 +0200
commit041f05422528bad639db5c2668bf3313643be244 (patch)
treee94ea7edff715ce90b7b5b3c3a1938a9b52817cc /os-plugins/plugins
parent* added support for os-plugins: (diff)
downloadcore-041f05422528bad639db5c2668bf3313643be244.tar.gz
core-041f05422528bad639db5c2668bf3313643be244.tar.xz
core-041f05422528bad639db5c2668bf3313643be244.zip
* added the 'os-plugins'-folder I missed with last commit
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1221 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/plugins')
-rw-r--r--os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm122
-rw-r--r--os-plugins/plugins/Example/XX_Example.sh38
2 files changed, 160 insertions, 0 deletions
diff --git a/os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm b/os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm
new file mode 100644
index 00000000..bd90d306
--- /dev/null
+++ b/os-plugins/plugins/Example/OpenSLX/OSPlugin/Example.pm
@@ -0,0 +1,122 @@
+# Copyright (c) 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/
+# -----------------------------------------------------------------------------
+# Example.pm
+# - an example implementation of the OSPlugin API (i.e. an os-plugin)
+# -----------------------------------------------------------------------------
+package OpenSLX::OSPlugin::Example;
+
+use strict;
+use warnings;
+
+our $VERSION = 1.01; # API-version . implementation-version
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+# if you have any questions regarding the concept of OS-plugins and their
+# implementation, please drop a mail to: ot@openslx.com, or join the IRC-channel
+# '#openslx' (on freenode).
+################################################################################
+### interface methods
+################################################################################
+sub new
+{
+ my $class = shift;
+
+ my $self = {};
+
+ return bless $self, $class;
+}
+
+sub initialize
+{
+ my $self = shift;
+
+ # The os-plugin-engine drives us, it provides some useful services relevant
+ # to installing stuff into the vendor-OS, like downloading functionality,
+ # access to meta-packager, ...
+ $self->{'os-plugin-engine'} = shift;
+
+ # Any other static initialization necessary for a plugin should be done
+ # here, more often than not, this will involve a configurational hash
+ # representing the default settings for this plugin.
+ # At a later stage, the user will be able to change plugin-specific settings
+ # (on a per-system/client basis) via slxconfig, such that the actual
+ # configuration will be stored in the DB.
+ # Currently, though, you have to change the settings here:
+ $self->{config} = {
+ 'active' => 1, # set to 0 in order to deactivate
+ 'precedence' => 10, # runlevel precedence
+ 'preferred_side' => 'left', # just a silly example
+ }
+}
+
+sub preInstallationPhase
+{ # called before chrooting into vendor-OS root, should be used if any files
+ # have to be downloaded outside of the chroot (which might be necessary
+ # if the required files can't be installed via the meta-packager)
+ my $self = shift;
+ my $pluginRepositoryPath = shift;
+ # the folder where the stage1-plugin should store all files
+ # required by the corresponding stage3 runlevel script
+ my $pluginTempPath = shift;
+ # a temporary playground that will be cleaned up automatically
+
+ # in this example plugin, there's no need to do anything here ...
+}
+
+sub installationPhase
+{ # called while chrooted to the vendor-OS root, most plugins will do all
+ # their installation work here
+ my $self = shift;
+ my $pluginRepositoryPath = shift;
+ # the repository folder, this time from inside the chroot
+ my $pluginTempPath = shift;
+ # the temporary folder, this time from inside the chroot
+
+ # for this example plugin, we simply create two files:
+ spitFile("$pluginRepositoryPath/left", "(-;\n");
+ spitFile("$pluginRepositoryPath/right", ";-)\n");
+}
+
+sub postInstallationPhase
+{ # called after having returned from chrooted environment, should be used
+ # to cleanup any leftovers, if any such thing is necessary
+ my $self = shift;
+ my $pluginRepositoryPath = shift;
+ my $pluginTempPath = shift;
+
+ # in this example plugin, there's no need to do anything here ...
+}
+
+sub getConfig
+{ # called from the config-demuxer in order ot access the configurational
+ # hash, which will then be written to a file (in this case:
+ # /opt/openslx/plugin-conf/Example.conf), that will be transported to each
+ # client as part of the conf-TGZ.
+ my $self = shift;
+
+ return $self->{config};
+}
+
+sub preRemovalPhase
+{
+}
+
+sub removalPhase
+{
+}
+
+sub postRemovalPhase
+{
+}
+
diff --git a/os-plugins/plugins/Example/XX_Example.sh b/os-plugins/plugins/Example/XX_Example.sh
new file mode 100644
index 00000000..88c991e8
--- /dev/null
+++ b/os-plugins/plugins/Example/XX_Example.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+#
+# stage3 part of 'Example' plugin - the runlevel script
+#
+# This basically is a runlevel script (just like you know them from 'init'),
+# whose purpose is to activate the plugin in stage3. The 'XX' at the beginning
+# of the filename will be replaced with a runlevel precedence number taken
+# from the configuration of the respective plugin. All plugin runlevel scripts
+# will be executed in the order of those precedence numbers.
+#
+# In order to activate the corresponding plugin, each runlevel script should:
+#
+# a) read the corresponding configuration file (in this case:
+# /initramfs/plugin-conf/Example.conf)
+#
+# b) analyse the client (look at the available hardware) and decide what
+# needs to be done, taking into account the settings given in the config
+# file
+#
+# c) activate the plugin by copying/linking appropriate plugin-specific files
+# (in this case: from /mnt/opt/openslx/plugins/Example/), load required kernel
+# modules and whatever else might be necessary.
+#
+# if you have any questions regarding the use of this file, please drop a mail
+# to: ot@openslx.com, or join the IRC-channel '#openslx' (on freenode).
+
+if ! [ -e /initramfs/plugin-conf/Example.conf ]; then
+ exit 1
+fi
+
+echo "executing the 'Example' os-plugin ...";
+# for this example plugin, we simply take a filename from the configuration ...
+. /initramfs/plugin-conf/Example.conf
+
+# ... and cat that file:
+cat /mnt/opt/openslx/plugin-repo/Example/$preferred_side
+
+echo "done with 'Example' os-plugin ...";