From 01da64858b8624588d5da7bd44763e55b41eefdf Mon Sep 17 00:00:00 2001 From: michael pereira Date: Tue, 22 Mar 2011 12:29:36 +0100 Subject: Bootos fix --- application/models/BootOsMapper.php | 12 +++++++++--- .../modules/dev/controllers/BootisoController.php | 17 ++++++++++------- .../modules/dev/controllers/PrebootController.php | 2 +- .../modules/fbgui/controllers/IndexController.php | 1 + 4 files changed, 21 insertions(+), 11 deletions(-) (limited to 'application') diff --git a/application/models/BootOsMapper.php b/application/models/BootOsMapper.php index fab73f2..1856384 100644 --- a/application/models/BootOsMapper.php +++ b/application/models/BootOsMapper.php @@ -66,7 +66,7 @@ class Application_Model_BootOsMapper } } - public function find($id) + public function find($id, Application_Model_BootOs $botos = null) { $botos = new Application_Model_BootOs(); $result = $this->getDbTable()->find($id); @@ -76,8 +76,14 @@ class Application_Model_BootOsMapper $row = $result->current(); - $botos->setID($row->bootosID)->setConfigID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_init($row->path_init)->setPath_kernel($row->path_kernel)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public); - return $botos; + if($botos == null){ + $botos = new Application_Model_BootOs(); + $botos->setID($row->bootosID)->setConfigID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_init($row->path_init)->setPath_kernel($row->path_kernel)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public); + return $botos; + }else{ + $botos->setID($row->bootosID)->setConfigID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_init($row->path_init)->setPath_kernel($row->path_kernel)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public); + } + } public function fetchAll() diff --git a/application/modules/dev/controllers/BootisoController.php b/application/modules/dev/controllers/BootisoController.php index 901c901..dc4ec58 100644 --- a/application/modules/dev/controllers/BootisoController.php +++ b/application/modules/dev/controllers/BootisoController.php @@ -40,19 +40,22 @@ class dev_BootisoController extends Zend_Controller_Action header('Content-Type: application/x-gzip'); $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="preboot.zip"'); + header('Content-Disposition: ' . $content_disp . '; filename="preboot.tgz"'); header('Pragma: no-cache'); header('Expires: 0'); - $fp = fopen("bootisoSerial.txt", "w"); - fputs ($fp, $serialnumber); - fclose ($fp); + chdir("../resources/bootmedium/$prebootID/preboot/"); + +// $fp = fopen("bootisoSerial.txt", "w"); +// fputs ($fp, $serialnumber); +// fclose ($fp); // create the gzipped tarfile. - chdir("../resources/bootmedium/$prebootID/preboot/"); - passthru("zip -r - ./"); + + passthru("tar -cz ./"); - } + + } diff --git a/application/modules/dev/controllers/PrebootController.php b/application/modules/dev/controllers/PrebootController.php index cfcbeca..df8daf2 100644 --- a/application/modules/dev/controllers/PrebootController.php +++ b/application/modules/dev/controllers/PrebootController.php @@ -65,7 +65,7 @@ class dev_PrebootController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; } - //$this->_redirect('/dev/preboot'); + $this->_redirect('/dev/preboot'); } } diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index 906de49..53eb6ab 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -10,6 +10,7 @@ class Fbgui_IndexController extends Zend_Controller_Action public function indexAction() { + print_a($_POST); $params = $this->_request->getParam('data'); $keys = $this->_request->getParam('keys'); $post = $this->_request->getParam('post'); -- cgit v1.2.3-55-g7522 From 04475ff1a1df3a0cc523117e6288401808946d43 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Tue, 22 Mar 2011 12:31:56 +0100 Subject: Bootiso & Preboot update --- application/models/BootIsoMapper.php | 12 +++-- .../modules/dev/controllers/BootisoController.php | 58 ++++++++++++++++------ .../modules/dev/controllers/PrebootController.php | 43 ++++++++++++---- .../modules/fbgui/controllers/IndexController.php | 2 +- 4 files changed, 84 insertions(+), 31 deletions(-) (limited to 'application') diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php index 9e5b3db..8d883af 100644 --- a/application/models/BootIsoMapper.php +++ b/application/models/BootIsoMapper.php @@ -51,7 +51,7 @@ class Application_Model_BootIsoMapper if (null === ($id = $botiso->getID()) ) { unset($data['bootisoID']); - $this->getDbTable()->insert($data); + return $this->getDbTable()->insert($data); } else { $this->getDbTable()->update($data, array('bootisoID = ?' => $id)); } @@ -66,7 +66,7 @@ class Application_Model_BootIsoMapper } } - public function find($id, Application_Model_BootIso $botiso) + public function find($id, Application_Model_BootIso $botiso = null) { $result = $this->getDbTable()->find($id); if (0 == count($result)) { @@ -75,7 +75,13 @@ class Application_Model_BootIsoMapper $row = $result->current(); - $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + if($botiso == null){ + $botiso = new Application_Model_BootIso(); + $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + return $botiso; + }else{ + $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPrebootID($row->prebootID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public); + } } public function fetchAll() diff --git a/application/modules/dev/controllers/BootisoController.php b/application/modules/dev/controllers/BootisoController.php index dc4ec58..da3e4c2 100644 --- a/application/modules/dev/controllers/BootisoController.php +++ b/application/modules/dev/controllers/BootisoController.php @@ -31,28 +31,31 @@ class dev_BootisoController extends Zend_Controller_Action public function downloadbootisoAction() { $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); + $this->_helper->viewRenderer->setNoRender(true); $prebootID = $this->_request->getParam('prebootID'); $serialnumber = $this->_request->getParam('serialnumber'); if(is_dir("../resources/bootmedium/$prebootID/") && is_numeric($prebootID)){ - header('Content-Type: application/x-gzip'); - $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; - header('Content-Disposition: ' . $content_disp . '; filename="preboot.tgz"'); - header('Pragma: no-cache'); - header('Expires: 0'); - +// header('Content-Type: application/x-gzip'); +// $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment'; +// header('Content-Disposition: ' . $content_disp . '; filename="preboot.tgz"'); +// header('Pragma: no-cache'); +// header('Expires: 0'); + chdir("../resources/bootmedium/$prebootID/preboot/"); + $prebootname = array_pop(scandir("./")); + print_a($prebootname); -// $fp = fopen("bootisoSerial.txt", "w"); -// fputs ($fp, $serialnumber); -// fclose ($fp); + $fp = fopen($prebootname."/build/rootfs/tmp/proobootisoSerial.txt", "w"); + fputs ($fp, $serialnumber); + fclose ($fp); // create the gzipped tarfile. - - passthru("tar -cz ./"); + + passthru("tar -cvz ./"); + } @@ -80,9 +83,20 @@ class dev_BootisoController extends Zend_Controller_Action $bootisomapper = new Application_Model_BootIsoMapper(); $bootiso->setCreated(time()); + $prebootID = $bootiso->getPrebootID(); + try { - $bootisomapper->save($bootiso); + $bootisoID = $bootisomapper->save($bootiso); + + copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res === true){ + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/tmp/serial", $bootiso->getSerialnumber()); + $zip->close(); + } }catch(Zend_Exception $e) { @@ -99,7 +113,7 @@ class dev_BootisoController extends Zend_Controller_Action public function editbootisoAction() { - $bootisoID = $this->_request->getParam('bootisoID'); + $bootisoID = $this->_request->getParam('bootisoID'); $groupmapper = new Application_Model_GroupMapper(); $prebootmapper = new Application_Model_PreBootMapper(); @@ -126,9 +140,21 @@ class dev_BootisoController extends Zend_Controller_Action $bootisomapper = new Application_Model_BootIsoMapper(); $bootiso->setCreated(time()); $bootiso->setID($bootisoID); - + $prebootID = $bootiso->getPrebootID(); + try { - $bootisomapper->save($bootiso); + + + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res === true){ + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/mnt/serial", $bootiso->getSerialnumber()); + $zip->close(); + } + + $bootisomapper->save($bootiso); + }catch(Zend_Exception $e) { echo "Caught exception: " . get_class($e) . "
"; diff --git a/application/modules/dev/controllers/PrebootController.php b/application/modules/dev/controllers/PrebootController.php index df8daf2..5271450 100644 --- a/application/modules/dev/controllers/PrebootController.php +++ b/application/modules/dev/controllers/PrebootController.php @@ -53,12 +53,11 @@ class dev_PrebootController extends Zend_Controller_Action $prebootID = $prebootmapper->save($preboot); $path_preboot = "../resources/bootmedium/$prebootID/"; - mkdir($path_preboot."preboot/",0777,true); + mkdir($path_preboot ,0777, true); - exec("wget -O '".$path_preboot."preboot.tgz' ".$preboot->getPath_preboot()); - - exec("tar -xvf ".$path_preboot."preboot.tgz "."-C ".$path_preboot."preboot/"); - + exec("wget -O '".$path_preboot."preboot.zip' ".$preboot->getPath_preboot()); + + }catch(Zend_Exception $e) { echo "Caught exception: " . get_class($e) . "
"; @@ -81,8 +80,8 @@ class dev_PrebootController extends Zend_Controller_Action $prebootdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($prebootdate)))); - if(is_file("../resources/bootmedium/$prebootID/preboot.tgz")) - $prebootolddate = filemtime("../resources/bootmedium/".$prebootID."/preboot.tgz"); + if(is_file("../resources/bootmedium/$prebootID/preboot.zip")) + $prebootolddate = filemtime("../resources/bootmedium/".$prebootID."/preboot.zip"); else $prebootolddate = false; @@ -98,6 +97,7 @@ class dev_PrebootController extends Zend_Controller_Action public function updateprebootAction() { + $prebootID = $this->_request->getParam('prebootID'); $prebootmapper = new Application_Model_PreBootMapper(); @@ -106,10 +106,31 @@ class dev_PrebootController extends Zend_Controller_Action $path_preboot = "../resources/bootmedium/$prebootID/"; - exec("rm -r $path_preboot"."preboot/*"); - - exec("wget -O '".$path_preboot."preboot.tgz' ".$preboot->getPath_preboot()); - exec("tar -xvf ".$path_preboot."preboot.tgz "."-C ".$path_preboot."preboot/"); + exec("wget -O '".$path_preboot."preboot.zip' ".$preboot->getPath_preboot()); + + $filelist = array(); + $filelist = scandir($path_preboot); + + $bootisoMapper = new Application_Model_BootIsoMapper(); + + foreach($filelist as $file){ + if($file == "." || $file == ".." || $file == "preboot.zip"){ + //do nothing + } + else{ + $bootisoID = str_replace('.zip', '', $file); + $serialnumber = $bootisoMapper->find($bootisoID)->getSerialnumber(); + + copy("../resources/bootmedium/$prebootID/preboot.zip", "../resources/bootmedium/$prebootID/$bootisoID".".zip"); + $zip = new ZipArchive(); + $res = $zip->open("../resources/bootmedium/$prebootID/$bootisoID".".zip"); + if($res === true){ + $rootdir = $zip->getNameIndex(0); + $zip->addFromString($rootdir."build/rootfs/tmp/serial", $serialnumber); + $zip->close(); + } + } + } $this->_redirect('/dev/preboot'); } diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index 53eb6ab..09332bf 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -10,7 +10,7 @@ class Fbgui_IndexController extends Zend_Controller_Action public function indexAction() { - print_a($_POST); + $params = $this->_request->getParam('data'); $keys = $this->_request->getParam('keys'); $post = $this->_request->getParam('post'); -- cgit v1.2.3-55-g7522