From d64b0b37d63d36b1c01613f31466856ed14f80c7 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Thu, 18 Jun 2009 18:06:52 +0000 Subject: Makefile: remove tabs new preboot test version git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2974 95ad53e4-c205-0410-b2fa-d234c58c8868 --- Makefile | 36 ++++----- boot-env/OpenSLX/BootEnvironment/Preboot.pm | 1 + boot-env/preboot/conf/apache-openslx-preboot.conf | 12 ++- boot-env/preboot/http-server/users.pl | 90 +++++++++++++++++++++++ boot-env/preboot/preboot-scripts/dialog.functions | 24 ++++++ boot-env/preboot/preboot.sh | 13 +++- 6 files changed, 155 insertions(+), 21 deletions(-) create mode 100755 boot-env/preboot/http-server/users.pl diff --git a/Makefile b/Makefile index 270e2432..10225266 100644 --- a/Makefile +++ b/Makefile @@ -156,8 +156,8 @@ plain-install: cp tools/uclibc-wrapper $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/bin/; \ tar --exclude=.svn -cp -C lib OpenSLX \ | tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/lib; \ - tar --exclude=.svn -cp -C boot-env OpenSLX \ - | tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/lib; \ + tar --exclude=.svn -cp -C boot-env OpenSLX \ + | tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/lib; \ tar --exclude=.svn -cp -C config-db OpenSLX \ | tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/lib; \ tar --exclude=.svn -cp -C installer OpenSLX \ @@ -181,22 +181,22 @@ plain-install: @ # copy shareable data: @tar --exclude=.svn -cp -C initramfs stage3-stuff/ | \ - tar -xp --strip-components 1 \ - -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/initramfs; \ - tar --exclude=.svn -cp -C initramfs tools | \ - tar -xp --strip-components 1 \ - -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/ramfstools; \ - tar --exclude=.svn -cp -C initramfs distro-specs | \ - tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \ - tar --exclude=.svn -cp -C initramfs uclib-rootfs | \ - tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \ - tar --exclude=.svn --exclude *.example --exclude OpenSLX -cp boot-env | \ - tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/; \ - cp -p boot-env/pxe/menu-*.example boot-env/pxe/Readme.pxe \ - $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH)/boot-env/pxe/; \ - cp -p tools/mksquashfs $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/; \ - tar --exclude=.svn -cp -C initramfs tpm | \ - tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \ + tar -xp --strip-components 1 \ + -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/initramfs; \ + tar --exclude=.svn -cp -C initramfs tools | \ + tar -xp --strip-components 1 \ + -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/ramfstools; \ + tar --exclude=.svn -cp -C initramfs distro-specs | \ + tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \ + tar --exclude=.svn -cp -C initramfs uclib-rootfs | \ + tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \ + tar --exclude=.svn --exclude *.example --exclude OpenSLX -cp boot-env | \ + tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/; \ + cp -p boot-env/pxe/menu-*.example boot-env/pxe/Readme.pxe \ + $(SLX_BUILD_PATH)$(SLX_CONFIG_PATH)/boot-env/pxe/; \ + cp -p tools/mksquashfs $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share/squashfs/; \ + tar --exclude=.svn -cp -C initramfs tpm | \ + tar -xp -C $(SLX_BUILD_PATH)$(SLX_BASE_PATH)/share; \ @ # link the library loader for the uclibc (to use the uclibc busybox) @ ln -sf ${SLX_BASE_PATH}/share/uclib-rootfs/lib/ld-uClibc.so.0 \ diff --git a/boot-env/OpenSLX/BootEnvironment/Preboot.pm b/boot-env/OpenSLX/BootEnvironment/Preboot.pm index 888e32ba..b06de7d2 100644 --- a/boot-env/OpenSLX/BootEnvironment/Preboot.pm +++ b/boot-env/OpenSLX/BootEnvironment/Preboot.pm @@ -119,6 +119,7 @@ sub writeBootloaderMenuFor my $prebootBasePath = "$openslxConfig{'base-path'}/share/boot-env/preboot"; slxsystem(qq{cp $prebootBasePath/preboot.sh $bootloaderConfigPath/}); + slxsystem(qq{cp -r $prebootBasePath/preboot-scripts $bootloaderConfigPath/}); slxsystem(qq{chmod a+x $bootloaderConfigPath/preboot.sh}); # create a tar which can/will be downloaded by prebooting clients diff --git a/boot-env/preboot/conf/apache-openslx-preboot.conf b/boot-env/preboot/conf/apache-openslx-preboot.conf index ed7c5082..4eb58809 100644 --- a/boot-env/preboot/conf/apache-openslx-preboot.conf +++ b/boot-env/preboot/conf/apache-openslx-preboot.conf @@ -1,6 +1,14 @@ ScriptAlias /openslx-preboot/cgi-bin/ "/opt/openslx/share/boot-env/preboot/http-server/" + + Alias "/openslx-preboot/users/" "/srv/openslx/preboot-users/" + + Options -Indexes -ExecCGI FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + + Alias /openslx-preboot/ "/srv/openslx/preboot/" - Options -Indexes -ExecCGI FollowSymLinks MultiViews AllowOverride None @@ -13,4 +21,4 @@ Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all - \ No newline at end of file + diff --git a/boot-env/preboot/http-server/users.pl b/boot-env/preboot/http-server/users.pl new file mode 100755 index 00000000..cde3d227 --- /dev/null +++ b/boot-env/preboot/http-server/users.pl @@ -0,0 +1,90 @@ +#!/usr/bin/perl -w +# Copyright (c) 2009 - 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 feedback to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org +# +# cgi-bin script that accepts user settings and stores them in a special +# folder on the openslx server + +use strict; +use warnings; + +use CGI; +use CGI::Carp qw(fatalsToBrowser); +use File::Path; +use Switch; + +# add openslx stuff to @INC +use FindBin; +use lib "$FindBin::RealBin/../../../../lib"; +use lib "$FindBin::RealBin"; + +# read default config +use OpenSLX::Basics; +openslxInit(); + +my $cgi = CGI->new; +my $mac = $cgi->param('user') || ''; +my $action = $cgi->param('action'); +my $data = $cgi->param('data'); + +# global requirements +die "must give 'mac' ($mac)!\n" + unless $mac; + +my $webPath = "$openslxConfig{'public-path'}/preboot-users"; +my $userConfFile = "$webPath/$mac.conf"; + +# makes only sense if public path is writeable for www-data +# otherwise you have to create directory manualy +if ( ! -e $webPath ) { + mkpath ($webPath) or die _tr("Can't create user config directory (%s). Reason: %s", $webPath, @_); +} + +my $output = ""; +my $error; + +switch ($action) { + case 'set' { + if ($data) { + open (MYFILE, ">$userConfFile"); + print MYFILE $data; + close (MYFILE); + } else { + $error = "no data"; + } + } + case 'read' { + if ( -e $userConfFile ) { + open (MYFILE, $userConfFile); + while () { + chomp; + $output .= "$_\n"; + } + close (MYFILE); + } else { + $error = "foobar"; + } + + } + else { + #default case check if we have a user config + if ( -e $userConfFile ) { $output = "1"; } + else { $output = "0"; }; + } +} + +print $cgi->header('Content-type: text/plain'); +if ($error) { + print $error; +} else { + print $output; +} + +exit 0; diff --git a/boot-env/preboot/preboot-scripts/dialog.functions b/boot-env/preboot/preboot-scripts/dialog.functions index a9e76bdd..7c6dd784 100644 --- a/boot-env/preboot/preboot-scripts/dialog.functions +++ b/boot-env/preboot/preboot-scripts/dialog.functions @@ -79,3 +79,27 @@ ddownload () { echo 100 | dialog --gauge "$dl_title" $DIALOG_HEIGHT $DIALOG_WIDTH; } + + + +menu_firststart () { + while [ "x$(cat result)" = "x" ] ; do + dialog --menu "OpenSLX" 30 60 22 \ + 01 "Kiosk" \ + 02 "Kiosk Setup" \ + 03 "Custom System" \ + 2>result + done +} + +menu_oldconfig () { + oldconf=$1; + while [ "x$(cat result)" = "x" ] ; do + dialog --menu "OpenSLX" 30 60 22 \ + 01 "Kiosk" \ + 02 "Kiosk Setup" \ + 03 "Custom System" \ + 04 "Custom System" + 2>result + done +} diff --git a/boot-env/preboot/preboot.sh b/boot-env/preboot/preboot.sh index 169111ed..703af974 100755 --- a/boot-env/preboot/preboot.sh +++ b/boot-env/preboot/preboot.sh @@ -14,13 +14,24 @@ # get configuration . /etc/initramfs-setup +. ./preboot-scripts/dialog.functions # bring the mac address into the standard format 01- client=$(echo 01-$macaddr|sed "s/:/-/g") # check if already a configuration is available to decide if user interaction # is required (path is to be fixed) -wget -q -O /tmp/cfg-error $boot_uri/genconfig/${client} +wget -q -O /tmp/have-user-config "$boot_uri/users.pl?user=${client}" +have_user_config=$(cat /tmp/have-user-config); + +if [ "x1" == "x$have_user_config" ]; then + wget -q -O /tmp/oldconfig "$boot_uri/users.pl?user=${client}&action=read" + . /tmp/oldconfig + menu_oldconfig $oldconfig +else + menu_firststart +fi +rm result; # Switch here for several boot TYPE=fastboot/directkiosk/cfgkiosk/slxconfig # fastboot - no interaction use system from client config -- cgit v1.2.3-55-g7522