summaryrefslogtreecommitdiffstats
path: root/lib/OpenSLX/ConfigFolder.pm
diff options
context:
space:
mode:
authorOliver Tappe2007-06-17 12:29:17 +0200
committerOliver Tappe2007-06-17 12:29:17 +0200
commit9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b (patch)
tree176dc068777af9af1119c55648ec73e78517393e /lib/OpenSLX/ConfigFolder.pm
parentEnabled busybox option to allow longer filenames in tar archives (see (diff)
downloadcore-9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b.tar.gz
core-9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b.tar.xz
core-9ba85d5dc63dfd1e16b9ec85d532fe89ee58fd9b.zip
largish change with respect to configurable paths:
* instead of supporting configurable paths at different hierarchy levels, there are now only five configurable folder: + base-path (/opt/openslx), fixed at installation time + config-path (/etc/opt/openslx), fixed at installation time + private-path (/var/opt/openslx), freely configurable by user + public-path (/srv/openslx), freely configurable by user + temp-path (/tmp), freely configurable by user this closes ticket#143 * several holes have been plugged concerning the creation of folders before they are accessed, closing ticket#142 * the functionality of generating config default folders has been moved from the Makefile into a new Perl-module (ConfigFolder.pm), in order to be available to the Perl-scripts, too * slxsettings has been changed to reflect the nature of base-path and config-path as fixed paths git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1172 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'lib/OpenSLX/ConfigFolder.pm')
-rw-r--r--lib/OpenSLX/ConfigFolder.pm110
1 files changed, 110 insertions, 0 deletions
diff --git a/lib/OpenSLX/ConfigFolder.pm b/lib/OpenSLX/ConfigFolder.pm
new file mode 100644
index 00000000..0c957ef5
--- /dev/null
+++ b/lib/OpenSLX/ConfigFolder.pm
@@ -0,0 +1,110 @@
+# Copyright (c) 2006, 2007 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# ConfigFolder.pm
+# - provides utility functions for generation of configuration folders
+# -----------------------------------------------------------------------------
+package OpenSLX::ConfigFolder;
+
+use strict;
+use vars qw(@ISA @EXPORT $VERSION);
+
+use Exporter;
+$VERSION = 1.01;
+@ISA = qw(Exporter);
+
+@EXPORT = qw(
+ &createConfigFolderForDefaultSystem
+ &createConfigFolderForSystem
+);
+
+################################################################################
+### Module implementation
+################################################################################
+use Carp;
+use OpenSLX::Basics;
+
+sub createConfigFolderForDefaultSystem
+{
+ my $result = 0;
+ my $defaultConfigPath = "$openslxConfig{'private-path'}/config/default";
+ if (!-e "$defaultConfigPath/initramfs") {
+ slxsystem("mkdir -p $defaultConfigPath/initramfs");
+ $result = 1;
+ }
+ if (!-e "$defaultConfigPath/rootfs") {
+ slxsystem("mkdir -p $defaultConfigPath/rootfs");
+ $result = 1;
+ }
+
+ # create default pre-/postinit scripts for us in initramfs:
+ my $preInitFile = "$defaultConfigPath/initramfs/preinit.local";
+ if (!-e $preInitFile) {
+ open(PREINIT, "> $preInitFile")
+ or die _tr("Unable to create file '%s'!", $preInitFile);
+ my $preInit = <<' END'
+ #!/bin/sh
+ #
+ # This script allows the local admin to extend the
+ # capabilities at the beginning of the initramfs (stage3).
+ # The toolset is rather limited and you have to keep in mind
+ # that stage4 rootfs has the prefix '/mnt'.
+ END
+ ;
+ $preInit =~ s[^\s+][]igms;
+ print PREINIT $preInit;
+ close(PREINIT);
+ slxsystem("chmod u+x $preInitFile");
+ $result = 1;
+ }
+
+ my $postInitFile = "$defaultConfigPath/initramfs/postinit.local";
+ if (!-e $postInitFile) {
+ open(POSTINIT, "> $postInitFile")
+ or die _tr("Unable to create file '%s'!", $postInitFile);
+ my $postInit = <<' END'
+ #!/bin/sh
+ #
+ # This script allows the local admin to extend the
+ # capabilities at the end of the initramfs (stage3).
+ # The toolset is rather limited and you have to keep in mind
+ # that stage4 rootfs has the prefix '/mnt'.
+ # But you may use some special slx-functions available via
+ # inclusion: '. /etc/functions' ...
+ END
+ ;
+ $postInit =~ s[^\s+][]igms;
+ print POSTINIT $postInit;
+ close(POSTINIT);
+ slxsystem("chmod u+x $postInitFile");
+ $result = 1;
+ }
+ return $result;
+}
+
+sub createConfigFolderForSystem
+{
+ my $systemName = shift || confess "need to pass in system-name!";
+
+ my $result = 0;
+ my $systemConfigPath
+ = "$openslxConfig{'private-path'}/config/$systemName/default";
+ if (!-e "$systemConfigPath/initramfs") {
+ slxsystem("mkdir -p $systemConfigPath/initramfs");
+ $result = 1;
+ }
+ if (!-e "$systemConfigPath/rootfs") {
+ slxsystem("mkdir -p $systemConfigPath/rootfs");
+ $result = 1;
+ }
+ return $result;
+}
+
+1;