From 5435b8d135d2003945e2361d1c82f583570dfdde Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 4 Sep 2015 19:03:53 +0200 Subject: Many changes --- inc/configmodule.inc.php | 2 ++ inc/configtgz.inc.php | 5 +++++ inc/download.inc.php | 32 ++++++++++++++++++++++++++++++++ inc/trigger.inc.php | 9 --------- 4 files changed, 39 insertions(+), 9 deletions(-) (limited to 'inc') diff --git a/inc/configmodule.inc.php b/inc/configmodule.inc.php index 4dd7c951..5c613f1b 100644 --- a/inc/configmodule.inc.php +++ b/inc/configmodule.inc.php @@ -184,6 +184,7 @@ abstract class ConfigModule * Module specific version of generate. * * @param string $tgz File name of tgz module to write final output to + * @param string $parent Parent task of this task * @return array|boolean true if generation is completed immediately, * a task struct if some task needs to be run for generation, * false on error @@ -307,6 +308,7 @@ abstract class ConfigModule * Updating the database etc. will happen later through a callback. * * @param boolean $deleteOnError if true, the db entry will be deleted if generation failed + * @param string $parent Parent task of this task * @param int $timeoutMs maximum time in milliseconds we wait for completion * @return string|boolean task id if deferred generation was started, * true if generation succeeded (without using a task or within $timeoutMs) diff --git a/inc/configtgz.inc.php b/inc/configtgz.inc.php index 8ddd4523..b51d2787 100644 --- a/inc/configtgz.inc.php +++ b/inc/configtgz.inc.php @@ -38,6 +38,11 @@ class ConfigTgz return true; } + public function isActive() + { + return readlink(CONFIG_HTTP_DIR . '/default/config.tgz') === $this->file; + } + public function getModuleIds() { $ret = array(); diff --git a/inc/download.inc.php b/inc/download.inc.php index 6485ee24..5347e2ee 100644 --- a/inc/download.inc.php +++ b/inc/download.inc.php @@ -58,6 +58,38 @@ class Download return $data; } + /** + * POST-Download file, obey given timeout in seconds + * Return data on success, false on failure + * @param string $url URL to fetch + * @param array $params POST params to set in body, list of key-value-pairs + * @param int $timeout timeout in seconds + * @param int $code HTTP response code, or 999 on error + */ + public static function asStringPost($url, $params, $timeout, &$code) + { + $string = ''; + foreach ($params as $k => $v) { + if (!empty($string)) { + $string .= '&'; + } + $string .= $k . '=' . urlencode($v); + } + $ch = self::initCurl($url, $timeout, $head); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $string); + $data = curl_exec($ch); + $head = self::getContents($head); + if (preg_match('#^HTTP/\d+\.\d+ (\d+) #', $head, $out)) { + $code = (int) $out[1]; + } else { + $code = 999; + } + curl_close($ch); + return $data; + } + /** * Download a file from a URL to file. * diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index 0b1f00c5..9062cafd 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -160,15 +160,6 @@ class Trigger private static function triggerDaemons($action, $parent, &$taskids) { - $task = Taskmanager::submit('SyncdaemonLauncher', array( - 'operation' => $action, - 'parentTask' => $parent, - 'failOnParentFail' => false - )); - if (isset($task['id'])) { - $taskids['syncid'] = $task['id']; - $parent = $task['id']; - } $task = Taskmanager::submit('DozmodLauncher', array( 'operation' => $action, 'parentTask' => $parent, -- cgit v1.2.3-55-g7522