diff options
author | michael pereira | 2011-07-07 14:01:45 +0200 |
---|---|---|
committer | michael pereira | 2011-07-07 14:01:45 +0200 |
commit | b2c5c02e03a8c7ca73e3c787006ad854de5f336a (patch) | |
tree | 6e953f3db08013de4eb2159826a6db49bd43a87f | |
parent | remove parse error (diff) | |
download | pbs2-b2c5c02e03a8c7ca73e3c787006ad854de5f336a.tar.gz pbs2-b2c5c02e03a8c7ca73e3c787006ad854de5f336a.tar.xz pbs2-b2c5c02e03a8c7ca73e3c787006ad854de5f336a.zip |
Bootos zeigt nun an welche Dateien vorhanden sind. iPXE im Resource controller implementiert
-rw-r--r-- | .zfproject.xml | 16 | ||||
-rw-r--r-- | application/controllers/ResourceController.php | 41 | ||||
-rw-r--r-- | application/modules/ipxe/controllers/AuthController.php | 91 | ||||
-rw-r--r-- | application/modules/ipxe/controllers/IndexController.php | 183 | ||||
-rw-r--r-- | application/modules/user/controllers/BootosController.php | 6 | ||||
-rw-r--r-- | application/modules/user/views/scripts/bootos/index.phtml | 6 | ||||
-rw-r--r-- | application/views/scripts/resource/getvesamenu.phtml | 142 |
7 files changed, 484 insertions, 1 deletions
diff --git a/.zfproject.xml b/.zfproject.xml index a81689c..b25c0d5 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -756,6 +756,22 @@ </viewsDirectory> <bootstrapFile filesystemName="Bootstrap.php"/> </moduleDirectory> + <moduleDirectory moduleName="ipxe"> + <apisDirectory enabled="false"/> + <configsDirectory enabled="false"/> + <controllersDirectory/> + <formsDirectory enabled="false"/> + <layoutsDirectory enabled="false"/> + <modelsDirectory> + <dbTableDirectory enabled="false"/> + </modelsDirectory> + <viewsDirectory> + <viewScriptsDirectory/> + <viewScriptsDirectory/> + <viewHelpersDirectory/> + <viewFiltersDirectory/> + </viewsDirectory> + </moduleDirectory> </modulesDirectory> <viewsDirectory> <viewScriptsDirectory> diff --git a/application/controllers/ResourceController.php b/application/controllers/ResourceController.php index e67e008..25bbc8d 100644 --- a/application/controllers/ResourceController.php +++ b/application/controllers/ResourceController.php @@ -574,6 +574,47 @@ class ResourceController extends Zend_Controller_Action $path = "http://" . $_SERVER['SERVER_NAME'] . $path; return $path; } + + public function getvesamenuAction(){ + if(is_dir("../resources/ipxe/")){ + + header('Content-Type: application/octet-stream'); + $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; + header('Content-Disposition: ' . $content_disp . '; filename="vesamenu.c32"'); + header('Pragma: no-cache'); + header('Expires: 0'); + + chdir("../resources/ipxe/"); + + header("Content-Length: ".filesize(getcwd()."/vesamenu.c32")); + + passthru( "cat vesamenu.c32"); + }else{ + header('HTTP/1.0 404 Not Found'); + } + + } + + + public function ipxeAction(){ + + header('Content-Type: text/plain'); + + $vesamenuView = new Zend_View(); + $vesamenuView->addScriptPath(APPLICATION_PATH.'/views/scripts/resource/'); + $vesamenuView->host = $_SERVER['HTTP_HOST']; + $vesamenu = $vesamenuView->render('getvesamenu.phtml'); + + $result = "#!gpxe\n"; + $result .= "imgfree\n"; + + $result .= "chain http://".$_SERVER['HTTP_HOST']."/resource/getvesamenu $vesamenu"; + + header("Content-Length: ".(strlen($result))); + + echo $result; + + } } diff --git a/application/modules/ipxe/controllers/AuthController.php b/application/modules/ipxe/controllers/AuthController.php new file mode 100644 index 0000000..c553566 --- /dev/null +++ b/application/modules/ipxe/controllers/AuthController.php @@ -0,0 +1,91 @@ +<?php +/* + * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg + * This program is free software distributed under the GPL version 2. + * See http://gpl.openslx.org/ + * + * If you have any feedback please consult http://feedback.openslx.org/ and + * send your suggestions, praise, or complaints to feedback@openslx.org + * + * General information about OpenSLX can be found at http://openslx.org/ + */ + +class Ipxe_AuthController extends Zend_Controller_Action +{ + + public function init() + { + $this->db = Zend_Db_Table::getDefaultAdapter(); + $this->personmapper = new Application_Model_PersonMapper(); + } + + public function indexAction() + { + $this->_helper-> viewRenderer-> setNoRender(); + $this->_helper->redirector('login', 'auth'); + } + + public function loginAction() + { + if (Zend_Auth::getInstance()->hasIdentity()) { + $this->_redirect('/fbgui/'); + } else { + if (!isset($_POST["login"])){ + $loginForm = new fbgui_Form_Login(); + } else { + $loginForm = new fbgui_Form_Login($_POST); + + if ($loginForm->isValid($_POST)) { + + $auth = Zend_Auth::getInstance(); + + $adapter = new Zend_Auth_Adapter_DbTable($this->db, 'pbs_person', 'email', 'password', 'MD5(CONCAT(?, password_salt))'); + + + $adapter->setIdentity($loginForm->getValue('email')); + $adapter->setCredential($loginForm->getValue('password')); + + $result = $auth->authenticate($adapter); + + // TODO: erweiterte fehlerbeschreibung des Users + + if ($result->isValid()) { + $this->personmapper = new Application_Model_PersonMapper(); + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); + $person = new Application_Model_Person($result[0]); + $person->setID($result[0]['personID']); + $date = new DateTime(); + $person->setLogindate($date->getTimestamp()); + $this->personmapper->save($person); + $this->_helper->redirector('selectmembership', 'person'); + return; + } else { + echo "Wrong Email or Password."; + } + } + } + $this->view->loginForm = $loginForm; + } + } + + public function logoutAction() + { + $this->_helper-> viewRenderer-> setNoRender(); + $auth = Zend_Auth::getInstance(); + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + Zend_Session::forgetMe(); + $this->_redirect('/fbgui/index'); +# $this->_helper->redirector('fbgui', 'index'); + return; + } +} + + + + + + + + + diff --git a/application/modules/ipxe/controllers/IndexController.php b/application/modules/ipxe/controllers/IndexController.php new file mode 100644 index 0000000..ad24551 --- /dev/null +++ b/application/modules/ipxe/controllers/IndexController.php @@ -0,0 +1,183 @@ +<?php +/* + * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg + * This program is free software distributed under the GPL version 2. + * See http://gpl.openslx.org/ + * + * If you have any feedback please consult http://feedback.openslx.org/ and + * send your suggestions, praise, or complaints to feedback@openslx.org + * + * General information about OpenSLX can be found at http://openslx.org/ + */ + +class Ipxe_IndexController extends Zend_Controller_Action +{ + protected $membership; + + public function init() + { + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + /* Initialize action controller here */ + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + + $membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); + } + + public function errorAction() + { + $result = $this->_request->getParam('serialresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('serial',$result); + } + } + + public function indexAction() + { + $mySession = new Zend_Session_Namespace('pbs'); + + if(count($mySession->postdata)<=0){ + $mySession->postdata = $_POST; + } + + $result = $this->_request->getParam('notify'); + if($result == 'nomember'){ + //fehler + } + + $d = new Pbs_Debug(); + $d->debug(array('IpxeIndexController',$_SERVER['REMOTE_ADDR'],implode("\t",$mySession->postdata))); + + if(isset($mySession->postdata['serialnumber'])){ + // Create a session + $n = new Pbs_Session(); + + $bootisomapper = new Application_Model_BootIsoMapper(); + $bootiso = new Application_Model_BootIso(); + + $results = $bootisomapper->findBy(array('serialnumber' => $mySession->postdata['serialnumber']),true); + if(count($results) == 0){ + $this->_redirect('/fbgui/index/error/serialresult/noserial2'); + } + $bootiso->setOptions($results[0]); + $bootiso->setID($results[0]['bootisoID']); + $groupID = $bootiso->getGroupID(); + + + + $client = new Application_Model_Client(); + $client->setMacadress($mySession->postdata['mac']); + $client->setHardwarehash($mySession->postdata['hardwarehash']); + $client->setGroupID($groupID); + $client->setCreated(time()); + $client = $n->createClient($client); + $clientID = $client->getID(); + + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + + if(!isset($_SESSION['alphasessionID'])){ + $session = new Application_Model_Session(); + $session->setBootisoID($bootiso->getID()); + $session->setClientID($clientID); + $session->setTime(time()); + if($this->membership->getID() != ''){ + $session->setMembershipID($this->membership->getID()); + } + $session->setIp($_SERVER['REMOTE_ADDR']); + $session = $n->createSession($session); + $_SESSION['alphasessionID'] = $session->getAlphasessionID(); + } + else{ + $session = new Application_Model_Session(); + $sessionMapper = new Application_Model_SessionMapper(); + $sessions = $sessionMapper->findBy(array('alphasessionID'=>$_SESSION['alphasessionID'])); + $session = $sessions[0]; + if($this->membership->getID() != '' && $session->getMembershipID() == ''){ + $session->setMembershipID($this->membership->getID()); + $sessionMapper->save($session); + } + } + // Request Bootmenu + $pbsFilter = new Pbs_Filter(); + $bootmenuID = $pbsFilter->evaluate(); + if($bootmenuID != null){ + $this->view->alphasessionID = $_SESSION['alphasessionID']; + // print_a('Debug Output', + // 'Session is now set', + // 'Your sessionID is '.$session->getID(), + // 'Your alphasessionID is '.$session->getAlphasessionID(), + // 'Your client is '.$session->getClientID(), + // 'goto bootmenu '.$bootmenuID); + + $bootmenuMapper = new Application_Model_BootMenuMapper(); + $bm = $bootmenuMapper->find($bootmenuID); + $this->view->title = $bm->getTitle(); + $this->view->startcounter = $bm->getStartcounter(); + + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID),false); + $this->view->entries = $res; + + if (!Zend_Auth::getInstance()->hasIdentity()) { + $this->view->loginmenu = true; + } + + if(Zend_Auth::getInstance()->hasIdentity()){ + if($bm->MembershipID != '' && $bm->MembershipID == $this->membership->getID()){} + else{ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify("This is not your Bootmenu. There is currently a BootMenu with a higher priority active.",'info'); + } + } + } + else{ + // print_a('Debug Output', + // 'Session is now set', + // 'Your sessionID is '.$session->getID(), + // 'Your alphasessionID is '.$session->getAlphasessionID(), + // 'Your client is '.$session->getClientID(), + // 'there is no bootmenu for you'); + if (!Zend_Auth::getInstance()->hasIdentity()) { + $this->view->loginmenu = true; + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify("There is no default BootMenu, please Login to get your BootMenu.",'info'); + } + else{ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify("You have no BootMenu.",'info'); + } + $this->view->nobootmenu = true; + } + } + else{ + #$this->_redirect('/fbgui/index/error/serialresult/noserial'); + } + + } + public function startAction(){ + $bootmenuntryID = $this->_request->getParam('bme'); + $a = $_SESSION['alphasessionID']; + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenuentriesMapper->find($bootmenuntryID,$bootmenuentry); + + $sessionMapper = new Application_Model_SessionMapper(); + $session_k = $sessionMapper->findBy(array('alphasessionID' => $a),true); + + $session = new Application_Model_Session(); + $session->setOptions($session_k[0]); + $session->setID($session_k[0]['sessionID']); + + $session->setBootmenuentryID($bootmenuntryID); + $session->setBootosID($bootmenuentry->getBootosID()); + $sessionMapper->save($session); + + + $this->view->host = 'pbs2.mp.openslx.org'; + $this->view->alphasessionID = $a; + } + +} diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php index 9bc6a69..f7fad49 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -85,13 +85,17 @@ class user_BootosController extends Zend_Controller_Action } $this->view->bootoslist = array_reverse($this->view->bootoslist); - + $this->view->resources = array(); + $groupMapper = new Application_Model_GroupMapper(); if(count($this->view->bootoslist)>0){ foreach ($this->view->bootoslist as $bootos){ if($bootos->getDefaultkcl() == null) $bootos->setDefaultkcl("none (edit Bootos to set KCL)"); + $this->view->resources[$bootos->getID()]['kernel'] = is_file("../resources/bootos/".$bootos->getID()."/kernel/kernel"); + $this->view->resources[$bootos->getID()]['initramfs'] = is_file("../resources/bootos/".$bootos->getID()."/initramfs/initramfs"); + $this->view->resources[$bootos->getID()]['config'] = is_file("../resources/bootos/".$bootos->getID()."/config/default.tgz"); $bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupMapper->find($bootos->getGroupID())->getTitle()); $bootos->setCreated(date(Zend_Registry::get('dateformat'),$bootos->getCreated())); $bootos->setExpires(date(Zend_Registry::get('dateformat'),$bootos->getExpires())); diff --git a/application/modules/user/views/scripts/bootos/index.phtml b/application/modules/user/views/scripts/bootos/index.phtml index f01cccd..109084f 100644 --- a/application/modules/user/views/scripts/bootos/index.phtml +++ b/application/modules/user/views/scripts/bootos/index.phtml @@ -86,6 +86,12 @@ <div class='item'><?php echo $this->escape($bootos->getShortname()); ?> </div> <label>Share</label> <div class='item'><?php echo $this->escape($bootos->getShare()); ?> </div> + <label>Kernel</label> + <div class='item'><?php echo $this->escape($this->resources[$bootos->getID()]['kernel']?"vorhanden":"nicht vorhanden"); ?> </div> + <label>Initramfs</label> + <div class='item'><?php echo $this->escape($this->resources[$bootos->getID()]['initramfs']?"vorhanden":"nicht vorhanden"); ?> </div> + <label>Config</label> + <div class='item'><?php echo $this->escape($this->resources[$bootos->getID()]['config']?"vorhanden":"nicht vorhanden"); ?> </div> <?php endif; ?> <label>Changed</label> <div class='item'><?php echo $this->escape($bootos->getCreated()); ?> </div> diff --git a/application/views/scripts/resource/getvesamenu.phtml b/application/views/scripts/resource/getvesamenu.phtml new file mode 100644 index 0000000..7751f20 --- /dev/null +++ b/application/views/scripts/resource/getvesamenu.phtml @@ -0,0 +1,142 @@ +<?php + +// $username = $_SERVER["PHP_AUTH_USER"]; +// $password = $_SERVER["PHP_AUTH_PW"]; + + $index = 0; + + function title ( $title ) { + global $username; + echo "menu title ".$title; + echo ( $username ? " for ".$username : "" )."\n"; + } + + function label ( $label ) { + global $index; + $index++; + echo "label item".$index."\n"; + echo " menu label "; + echo "^".( ( $index < 10 ) ? $index : + sprintf ( "%c", $index + ord ( 'A' ) - 10 ) )." "; + echo $label."\n"; + } + + function uriboot ( $label, $uri, $args ) { + label ( $label ); + echo " kernel ".$uri."\n"; + if ( $args ) + echo " append ".$args."\n"; + } + + function localboot () { + label ( "LOCALBOOT"); + echo "LOCALBOOT -1\n"; + texthelp("Gets you out of here by booting from next device in BIOS boot + order."); + } + + function texthelp ( $texthelp ){ + echo "TEXT HELP\n"; + echo $texthelp."\n"; + echo "ENDTEXT\n"; + } + + function retry () { + echo "label failed\n"; + echo " menu label Authentication Failed\n"; + echo " menu disable\n"; + uriboot ( "Try again", "ipxe.php", "" ); + } + + function authenticated () { + global $username; + global $password; + + switch ( "$username:$password" ) { + case "test:test": + case "guest:guest": + return 1; + default: + return 0; + } + } + + ?> + +TIMEOUT 100 +PROMPT 0 +DEFAULT vesamenu.c32 + +MENU BACKGROUND pbs2.png +MENU WIDTH 78 +MENU MARGIN 9 +MENU PASSWORDMARGIN 9 +MENU ROWS 10 +MENU TABMSGROW 16 +MENU CMDLINEROW 16 +MENU ENDROW -1 +MENU PASSWORDROW 16 +MENU TIMEOUTROW 20 +MENU HELPMSGROW 16 +MENU HELPMSGENDROW -1 +MENU HSHIFT 0 +MENU VSHIFT 7 + +#menu color screen 37;40 #80ffffff #00000000 std +menu color border 37;40 #00000000 #00000000 std +menu color title 1 #ee004a99 #00000000 all +menu color unsel 37;40 #ff4f75aa #00000000 all +menu color hotkey 1;37;40 #ffff8b00 #ff8093a1 std +menu color sel 7;37;40 #ff1c2a33 #667799bb all +#menu color hotsel 1;7;37;40 #ffff8b00 #667799bb all +#menu color disabled 1;37;40 #ffff8b00 #ff8093a1 std +#menu color scrollbar 37;40 #40000000 #ee000000 std +#menu color tabmsg 37;40 #ffff8b00 #ff8093a1 std +#menu color cmdmark 1;37;40 #ffff8b00 #ff8093a1 std +#menu color cmdline 37;40 #fff0f0f0 #ff8093a1 std +#menu color pwdborder 37;40 #40000000 #ff8093a1 std +#menu color pwdheader 37;40 #ffff8b00 #ff8093a1 std +#menu color pwdentry 37;40 #ffff8b00 #ff8093a1 std +#menu color timeout_msg 37;40 #fff0f0f0 #ff8093a1 std +#menu color timeout 1;37;40 #ffff8b00 #ff8093a1 std +#menu color help 37;40 #ff1c2a33 #00000000 none +MENU MSGCOLOR #ff1c2a33 #00000000 none + +<? + +// title ( "Welcome to OpenSLX PreBoot USB Ext2/3 (Mini Linux/Kexec)" ); +// +// if ( ! authenticated() ) { +// retry(); +// } else { +// +// if ( $username == "test" ) { +// +// localboot(); +// } + +uriboot ( "Ubuntu 10.04", + "http://$this->host/resource/getkernel/", "initrd=init vga=0x317" ); + +localboot(); +// } + +// LABEL SLXSTDBOOT +// MENU LABEL +// KERNEL kernel +// APPEND initrd=init vga=0x317 +// TEXT HELP +// Use this (default) entry if you have configured your client. +// You have chance to edit the kernel commandline by hitting the +// TAB key (e.g. for adding debug=3 to it for bug hunting) ... +// ENDTEXT +//LABEL DEBUGBOOT +// MENU LABEL OpenSLX PreBoot - Debug Mode +// KERNEL kernel +// APPEND initrd=init vga=0x317 debug=3 +// TEXT HELP +// Use this to start the preboot environment with debug shells. +// ENDTEXT + + + ?>
\ No newline at end of file |