summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael pereira2011-03-18 19:24:47 +0100
committermichael pereira2011-03-18 19:24:47 +0100
commitfd0e66bf49af0bc56e68830b4c59294f0ec8c101 (patch)
treea5bd9e4e255c9a841b35931fa8f5d9c8d1ece5a2
parentDatenbank update, PoolController (diff)
downloadpbs2-fd0e66bf49af0bc56e68830b4c59294f0ec8c101.tar.gz
pbs2-fd0e66bf49af0bc56e68830b4c59294f0ec8c101.tar.xz
pbs2-fd0e66bf49af0bc56e68830b4c59294f0ec8c101.zip
BootOs Update implementiert, BootISO anlegen und some fixes
-rw-r--r--application/models/BootIso.php10
-rw-r--r--application/models/BootIsoMapper.php6
-rw-r--r--application/modules/dev/controllers/BootisoController.php15
-rw-r--r--application/modules/dev/controllers/BootosController.php74
-rw-r--r--application/modules/dev/controllers/ResourceController.php16
-rw-r--r--application/modules/dev/forms/BootisoCreate.php4
-rw-r--r--application/modules/dev/views/scripts/bootiso/index.phtml4
-rw-r--r--application/modules/dev/views/scripts/bootos/index.phtml18
-rw-r--r--pbs-newdata.sql4
-rw-r--r--pbs.sql2
-rw-r--r--public/media/img/update.pngbin0 -> 338 bytes
-rw-r--r--public/media/img/update_grey.pngbin0 -> 2794 bytes
12 files changed, 123 insertions, 30 deletions
diff --git a/application/models/BootIso.php b/application/models/BootIso.php
index f5e2c15..6354d7c 100644
--- a/application/models/BootIso.php
+++ b/application/models/BootIso.php
@@ -4,7 +4,7 @@ class Application_Model_BootIso
{
protected $_bootisoID;
protected $_title;
- protected $_path;
+ protected $_path_fbgui;
protected $_membershipID;
protected $_groupID;
protected $_serialnumber;
@@ -89,13 +89,13 @@ class Application_Model_BootIso
$this->_title = $_title;
return $this;
}
- public function getPath()
+ public function getPath_fbgui()
{
- return $this->_path;
+ return $this->_path_fbgui;
}
- public function setPath($_path)
+ public function setPath_fbgui($_path_fbgui)
{
- $this->_path = $_path;
+ $this->_path_fbgui = $_path_fbgui;
return $this;
}
public function getSerialnumber()
diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php
index 11af0d7..bccc851 100644
--- a/application/models/BootIsoMapper.php
+++ b/application/models/BootIsoMapper.php
@@ -47,7 +47,7 @@ class Application_Model_BootIsoMapper
public function save(Application_Model_BootIso $botiso)
{
- $data = array('bootisoID'=> $botiso->getID() ,'membershipID'=> $botiso->getMembershipID() ,'title'=> $botiso->getTitle(),'path'=> $botiso->getPath() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() );
+ $data = array('bootisoID'=> $botiso->getID() ,'membershipID'=> $botiso->getMembershipID() ,'title'=> $botiso->getTitle(),'path_fbgui'=> $botiso->getPath_fbgui() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() );
if (null === ($id = $botiso->getID()) ) {
unset($data['bootisoID']);
@@ -75,7 +75,7 @@ class Application_Model_BootIsoMapper
$row = $result->current();
- $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath($row->path)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public);
+ $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_fbgui($row->path_fbgui)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public);
}
public function fetchAll()
@@ -85,7 +85,7 @@ class Application_Model_BootIsoMapper
foreach ($resultSet as $row) {
$entry = new Application_Model_BootIso();
- $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath($row->path)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public);
+ $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_fbgui($row->path_fbgui)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public);
$entries[] = $entry;
}
diff --git a/application/modules/dev/controllers/BootisoController.php b/application/modules/dev/controllers/BootisoController.php
index 2b0e624..86454cd 100644
--- a/application/modules/dev/controllers/BootisoController.php
+++ b/application/modules/dev/controllers/BootisoController.php
@@ -42,7 +42,22 @@ class dev_BootisoController extends Zend_Controller_Action
$bootiso->setCreated(time());
try {
+
+ exec("wget --spider ".$bootiso->getPath_fbgui()." 2>&1 | grep 'Remote file exists.'", $exists_fbgui);
+
+ if(!array_pop($exists_fbgui)){
+ $this->view->createbootisoForm = $createbootisoForm;
+ return;
+ }
+
$bootisomapper->save($bootiso);
+
+ $path_fbgui = "../resources/bootmedium/fbgui/";
+
+ exec("wget -P ".$path_fbgui." -N ".$bootiso->getPath_fbgui());
+
+
+
}catch(Zend_Exception $e)
{
echo "Caught exception: " . get_class($e) . "<br/>";
diff --git a/application/modules/dev/controllers/BootosController.php b/application/modules/dev/controllers/BootosController.php
index 36c1cf5..5f8aaf0 100644
--- a/application/modules/dev/controllers/BootosController.php
+++ b/application/modules/dev/controllers/BootosController.php
@@ -19,8 +19,11 @@ class dev_BootosController extends Zend_Controller_Action
$configmapper = new Application_Model_ConfigMapper();
$this->view->bootoslist = $bootosmapper->fetchAll();
+ $this->view->update = array();
+
if(count($this->view->bootoslist)>0){
foreach ($this->view->bootoslist as $bootos){
+ $this->view->update[$bootos->getID()] = $this->checkupdateAction($bootos);
$bootos->setGroupID("[".$bootos->getGroupID()."] ".$groupmapper->find($bootos->getGroupID())->getTitle());
$bootos->setMembershipID("[".$bootos->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootos->getMembershipID())->getPersonID())->getFirstname());
$bootos->setConfigID("[".$bootos->getConfigID()."] ".$configmapper->find($bootos->getConfigID())->getTitle());
@@ -36,12 +39,12 @@ class dev_BootosController extends Zend_Controller_Action
$configmapper = new Application_Model_ConfigMapper();
if (!isset($_POST["createbootos"])){
- try{
+ try{
$createbootosForm = new dev_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()));
- }catch(Zend_Exception $e){
- print_a($e);
- }
- } else {
+ }catch(Zend_Exception $e){
+ print_a($e);
+ }
+ } else {
$createbootosForm = new dev_Form_BootosCreate(array('grouplist' => $groupmapper->fetchAll() ,'configlist'=>$configmapper->fetchAll()),$_POST);
@@ -55,13 +58,23 @@ class dev_BootosController extends Zend_Controller_Action
$bootos->setCreated(time());
try {
+ exec("wget --spider ".$bootos->getPath_kernel()." 2>&1 | grep 'Remote file exists.'", $exists_kernel);
+ exec("wget --spider ".$bootos->getPath_init()." 2>&1 | grep 'Remote file exists.'" , $exists_init);
+
+ if(!array_pop($exists_init) || !array_pop($exists_kernel)){
+ $this->view->createbootosForm = $createbootosForm;
+ return;
+ }
+
$bootosID = $bootosmapper->save($bootos);
$initpath = "../resources/bootos/".$bootosID."/initramfs/";
$kernelpath = "../resources/bootos/".$bootosID."/kernel/";
-
+
exec("wget -P ".$kernelpath." ".$bootos->getPath_kernel());
- exec("wget -P ".$initpath." ".$bootos->getPath_init());
+ exec("wget -P ".$initpath." ".$bootos->getPath_init());
+
+
}catch(Zend_Exception $e)
{
@@ -76,6 +89,52 @@ class dev_BootosController extends Zend_Controller_Action
$this->view->createbootosForm = $createbootosForm;
}
+
+ public function checkupdateAction($bootos)
+ {
+ exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_kernel())."' 2>&1 | grep 'Last-Modified:'", $kerneldate);
+ exec("wget --server-response --spider '".escapeshellcmd($bootos->getPath_init())."' 2>&1 | grep 'Last-Modified:'", $initdate);
+
+ $kerneldate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($kerneldate))));
+ $kernelname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/kernel/"));
+
+ if($kernelname != "." && $kernelname != "..")
+ $kernelolddate = filemtime("../resources/bootos/".$bootos->getID()."/kernel/".$kernelname);
+ else
+ $kernelolddate = false;
+
+ $initdate = strtotime(trim(str_replace('Last-Modified:', '', array_pop($initdate))));
+ $initname = array_pop(scandir("../resources/bootos/".$bootos->getID()."/initramfs/"));
+
+ if($initname != "." && $initname != "..")
+ $initolddate = filemtime("../resources/bootos/".$bootos->getID()."/initramfs/".$initname);
+ else
+ $initolddate = false;
+
+ //print_a($kernelname,$kerneldate,$kernelolddate,$initname,$initdate,$initolddate);
+
+
+ if($kerneldate > $kernelolddate || $initdate > $initolddate)
+ return true;
+ else
+ return false;
+
+ }
+
+ public function updatebootosAction()
+ {
+ $bootosID = $this->_request->getParam('bootosID');
+ $bootosmapper = new Application_Model_BootOsMapper();
+ $bootos = $bootosmapper->find($bootosID);
+
+ $initpath = "../resources/bootos/".$bootosID."/initramfs/";
+ $kernelpath = "../resources/bootos/".$bootosID."/kernel/";
+
+ exec("wget -P ".$kernelpath." -N ".$bootos->getPath_kernel());
+ exec("wget -P ".$initpath." -N ".$bootos->getPath_init());
+
+ $this->_redirect('/dev/bootos');
+ }
public function editbootosAction()
{
@@ -100,6 +159,7 @@ class dev_BootosController extends Zend_Controller_Action
if ($editbootosForm->isValid($_POST)) {
+ //TODO: Check for new URL and download new files.
$bootos = new Application_Model_BootOs($_POST);
$bootos->setMembershipID('1');
if($bootos->getConfigID() == '')
diff --git a/application/modules/dev/controllers/ResourceController.php b/application/modules/dev/controllers/ResourceController.php
index 653b70d..cbca8d0 100644
--- a/application/modules/dev/controllers/ResourceController.php
+++ b/application/modules/dev/controllers/ResourceController.php
@@ -33,14 +33,16 @@ class dev_ResourceController extends Zend_Controller_Action
if(is_dir("../resources/bootos/$bootosID/initramfs/") && is_numeric($bootosID)){
header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
header('Content-Disposition: ' . $content_disp . '; filename="initramfs"');
header('Pragma: no-cache');
header('Expires: 0');
// create file.
chdir("../resources/bootos/$bootosID/initramfs/");
- passthru( "cat initramfs");
+ $initname = array_pop(scandir("./"));
+
+ passthru( "cat ".$initname);
}
}
@@ -58,7 +60,7 @@ class dev_ResourceController extends Zend_Controller_Action
if(is_dir("../resources/config/$configID/config/") && is_numeric($configID)){
header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
header('Content-Disposition: ' . $content_disp . '; filename="config.tar.gz"');
header('Pragma: no-cache');
header('Expires: 0');
@@ -76,14 +78,16 @@ class dev_ResourceController extends Zend_Controller_Action
if(is_dir("../resources/bootos/$bootosID/kernel/") && is_numeric($bootosID)){
header('Content-Type: application/x-gzip');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
header('Content-Disposition: ' . $content_disp . '; filename="kernel"');
header('Pragma: no-cache');
header('Expires: 0');
// create the gzipped tarfile.
chdir("../resources/bootos/$bootosID/kernel/");
- passthru( "cat kernel");
+ $kernelname = array_pop(scandir("./"));
+
+ passthru( "cat ". $kernelname);
}
}
@@ -98,7 +102,7 @@ class dev_ResourceController extends Zend_Controller_Action
$bmemapper->find($bmeID,$bme);
header('Content-Type: text/html');
- $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
+ $content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
header('Content-Disposition: ' . $content_disp . '; filename="kcl.txt"');
header('Pragma: no-cache');
header('Expires: 0');
diff --git a/application/modules/dev/forms/BootisoCreate.php b/application/modules/dev/forms/BootisoCreate.php
index 1615f6e..2ecc2d2 100644
--- a/application/modules/dev/forms/BootisoCreate.php
+++ b/application/modules/dev/forms/BootisoCreate.php
@@ -35,14 +35,14 @@ class dev_Form_BootisoCreate extends Zend_Form
$groupfield->setRegisterInArrayValidator(false);
$this->addElement($groupfield);
- $this->addElement('text', 'path', array(
+ $this->addElement('text', 'path_fbgui', array(
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 50)),
),
'required' => true,
'size' => 50,
- 'label' => 'Path:',
+ 'label' => 'Path to FbGui:',
));
$this->addElement('text', 'serialnumber', array(
diff --git a/application/modules/dev/views/scripts/bootiso/index.phtml b/application/modules/dev/views/scripts/bootiso/index.phtml
index b119aff..453f316 100644
--- a/application/modules/dev/views/scripts/bootiso/index.phtml
+++ b/application/modules/dev/views/scripts/bootiso/index.phtml
@@ -8,7 +8,7 @@
<th>Title</th>
<th>GroupID</th>
<th>MembershipID</th>
- <th>Path</th>
+ <th>FbGui Path</th>
<th>Serialnumber</th>
<th>Created</th>
<th>Expires</th>
@@ -23,7 +23,7 @@
<td><?php echo $this->escape($bootiso->getTitle()); ?></td>
<td><?php echo $this->escape($bootiso->getGroupID()); ?></td>
<td><?php echo $this->escape($bootiso->getMembershipID()); ?></td>
- <td><?php echo $this->escape($bootiso->getPath()); ?></td>
+ <td><?php echo $this->escape($bootiso->getPath_fbgui()); ?></td>
<td><?php echo $this->escape($bootiso->getSerialnumber()); ?></td>
<td><?php echo $this->escape(date('Y-m-d H:i:s', $bootiso->getCreated())); ?></td>
<td><?php echo $this->escape($bootiso->getExpires()); ?></td>
diff --git a/application/modules/dev/views/scripts/bootos/index.phtml b/application/modules/dev/views/scripts/bootos/index.phtml
index c5970b6..f76938d 100644
--- a/application/modules/dev/views/scripts/bootos/index.phtml
+++ b/application/modules/dev/views/scripts/bootos/index.phtml
@@ -17,7 +17,7 @@
<th>Changed</th>
<th>Expires</th>
<th>Public</th>
- <th colspan=2>Actions</th>
+ <th colspan=3>Actions</th>
</tr>
<?php if(count($this->bootoslist)==0)
echo "</table> There are no BootOs's to display." ?>
@@ -35,6 +35,20 @@
<td><?php echo $this->escape(date('Y-m-d H:i:s', $bootos->getCreated())); ?></td>
<td><?php echo $this->escape($bootos->getExpires()); ?></td>
<td><?php echo $this->escape($bootos->getPublic()); ?></td>
+ <?php if($this->update[$bootos->getID()]==true): ?>
+ <td class='action'><a
+ href="<?php echo $this->url(
+ array(
+ 'module' => 'dev',
+ 'controller' => 'bootos',
+ 'action' => 'updatebootos',
+ 'bootosID' => $bootos->getID()
+ ),
+ 'default',
+ true, false) ?>"><img src='/media/img/update.png' alt='Updates available' /></a></td>
+ <?php else: ?>
+ <td class='action'><img src='/media/img/update_grey.png' alt='No updates available' /></td>
+ <?php endif; ?>
<td class='action'><a
href="<?php echo $this->url(
array(
@@ -54,7 +68,7 @@
'bootosID' => $bootos->getID()
),
'default',
- true) ?>"><img src='/media/img/delete.png' alt='Delete BootOS' /></a></td>
+ true) ?>"><img src='/media/img/delete.png' alt='Delete BootOS' /></a></td>
</tr>
<?php endforeach; ?>
</table>
diff --git a/pbs-newdata.sql b/pbs-newdata.sql
index a412195..9dd4624 100644
--- a/pbs-newdata.sql
+++ b/pbs-newdata.sql
@@ -54,7 +54,7 @@ INSERT INTO `pbs_bootos` (`bootosID`, `configID`, `groupID`, `membershipID`, `ti
(10, 1, 1, 1, 'BootOs 10', 'Description 10', 'initpath 10', 'kernelpath 10', 'default kcl 10', '1299693782', '2012-03-09', 0);
-- Adding bootiso
-INSERT INTO `pbs_bootiso` (`bootisoID`, `title`, `membershipID`, `groupID`, `path`, `serialnumber`, `created`, `expires`, `public`) VALUES
+INSERT INTO `pbs_bootiso` (`bootisoID`, `title`, `membershipID`, `groupID`, `path_fbgui`, `serialnumber`, `created`, `expires`, `public`) VALUES
(1, 'BootIso 1', 1, 1, 'Path 1', 123456789, '1299693879', '2012-03-09', 0),
(2, 'BootIso 2', 1, 1, 'Path 2', 2147483647, '1299693899', '2012-03-09', 0),
(3, 'BootIso 3', 1, 1, 'Path 3', 2147483647, '1299693899', '2012-03-09', 0);
@@ -63,7 +63,7 @@ INSERT INTO `pbs_bootiso` (`bootisoID`, `title`, `membershipID`, `groupID`, `pat
INSERT INTO `pbs_pool` (`poolID`, `groupID`, `title`, `description`, `location`) VALUES
(1, 1, 'Pool 1', 'Description 1', 'Keller'),
(2, 1, 'Pool 2', 'Description 2', 'EG'),
-(3, 1, 'Pool 3', 'Description 3', '1 OG');
+(3, 1, 'Pool 3', 'Description 3', '1 OG'),
(4, 1, 'Pool 4', 'Description 4', '2 OG');
-- Adding Bootmenus
diff --git a/pbs.sql b/pbs.sql
index 58c21b2..9b44b51 100644
--- a/pbs.sql
+++ b/pbs.sql
@@ -188,7 +188,7 @@ CREATE TABLE IF NOT EXISTS `pbs_bootiso` (
`title` varchar(30) NOT NULL,
`membershipID` int(11),
`groupID` int(11) NOT NULL,
- `path` varchar(30) NOT NULL,
+ `path_fbgui` varchar(30) NOT NULL,
`serialnumber` int(11) NOT NULL,
`created` VARCHAR(14) NOT NULL,
`expires` VARCHAR(14),
diff --git a/public/media/img/update.png b/public/media/img/update.png
new file mode 100644
index 0000000..1717611
--- /dev/null
+++ b/public/media/img/update.png
Binary files differ
diff --git a/public/media/img/update_grey.png b/public/media/img/update_grey.png
new file mode 100644
index 0000000..815c7ba
--- /dev/null
+++ b/public/media/img/update_grey.png
Binary files differ