- updated demousage

- updated FroxlorPkgCreator (fix for manual added files)
- first cron version for remote server data deploying
This commit is contained in:
Andreas Burchert (scarya)
2010-10-20 21:33:39 +00:00
parent 7a83a01095
commit 84637d82d4
3 changed files with 47 additions and 10 deletions

View File

@@ -55,7 +55,7 @@ class FroxlorPkgCreator
/**
* Manual added files.
* Uses key as filename!
* Contains an array with an array (name, data);
*
* @var array
*/
@@ -131,7 +131,7 @@ class FroxlorPkgCreator
*/
public function addFile($name, $data)
{
$this->_manualFiles[$name] = $data;
$this->_manualFiles[] = array("name" => $name, "data" => $data;
}
/**
@@ -156,8 +156,8 @@ class FroxlorPkgCreator
}
// add manual files
foreach ($this->_manualFiles as $key=>$var) {
$zip->addFromString($key, $var);
foreach ($this->_manualFiles as $var) {
$zip->addFromString($var['name'], $var['data']);
}
// close it

View File

@@ -85,4 +85,5 @@ FroxlorDeployfileCreator::saveListTo("deploy.txt");
/*
* and create a zip archive
*/
new FroxlorPkgCreator("deploy.txt", "deploy.zip");
$pkg = new FroxlorPkgCreator("deploy.txt", "deploy.zip");
$pkg->pack();

View File

@@ -79,6 +79,31 @@ class client_deployer
/**
* @TODO implement me
*/
$deployList = "/tmp/froxlor_deploy_".time().".txt";
$zipPath = "/tmp/froxlor_deploy_".time().".zip";
$remoteTo = "/var/ww/froxlor/"; // TODO setting variable?!
// TODO get a deploy configuration from database/panel?
// create the deploy list
FroxlorDeployfileCreator::createList(
array(
"/var/www/froxlor/lib/",
"/var/www/froxlor/lng/",
"/var/www/froxlor/scripts/",
"/var/www/froxlor/actions/",
"/var/www/froxlor/templates/"
)
);
FroxlorDeployfileCreator::saveListTo($deployList);
// prepare and pack files
$this->_prepareFiles($deployList, $zipPath);
// transfer the data
$bytes = $this->_transferArchive($ssh, $zipPath, $remoteTo);
// close the session
$ssh->close();
@@ -91,9 +116,13 @@ class client_deployer
*
* @return double amount of bytes transferd
*/
private function _transferArchive()
private function _transferArchive($ssh, $from, $to)
{
$archive = $this->_prepareFiles();
if ($ssh->sendFile($from, $to)) {
return stat($from)['7'];
} else {
return 0.0;
}
}
/**
@@ -102,14 +131,21 @@ class client_deployer
*
* @return string path to the created archive
*/
private function _prepareFiles()
private function _prepareFiles($deployList, $toPath)
{
$pkg = FroxlorPkgCreator($deployList, $toPath);
/**
* create userdata file which
* has to be included to the archive
*/
$userdatafile = $this->_createUserdataFile();
// add userdata.inc.php
$pkg->addFile("lib/userdata.inc.php", $userdatafile);
// pack it
$pkg->pack();
}
/**
@@ -122,6 +158,6 @@ class client_deployer
*/
private function _createUserdataFile()
{
return "Chuck Norris doesn't need a userdata.inc.php to run Froxlor!";
}
}