File classes/Utils.php copied from file footer.php (similarity 51%) (mode: 100644) (index e91aa93..624b77c) |
1 |
1 |
<?php |
<?php |
2 |
|
// Copyright (C) 2015 xaizek <xaizek@posteo.net> |
|
|
2 |
|
// Copyright (C) 2018 xaizek <xaizek@posteo.net> |
3 |
3 |
// |
// |
4 |
4 |
// fragile is free software: you can redistribute it and/or modify it under the |
// fragile is free software: you can redistribute it and/or modify it under the |
5 |
5 |
// terms of the GNU Affero General Public License as published by the Free |
// terms of the GNU Affero General Public License as published by the Free |
|
13 |
13 |
// You should have received a copy of the GNU Affero General Public License |
// You should have received a copy of the GNU Affero General Public License |
14 |
14 |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 |
15 |
|
|
16 |
|
print "<footer><a href='" . CI_URL . "'>fragile v0.5</a></footer>\n" |
|
17 |
|
. "</body></html>"; |
|
|
16 |
|
/** |
|
17 |
|
* @brief Helper functions. |
|
18 |
|
*/ |
|
19 |
|
class Utils |
|
20 |
|
{ |
|
21 |
|
/** |
|
22 |
|
* @brief Removes subtree. |
|
23 |
|
* |
|
24 |
|
* @param dir Directory path to remove. |
|
25 |
|
* |
|
26 |
|
* @returns Result of rmdir(). |
|
27 |
|
*/ |
|
28 |
|
public static function delTree($dir) |
|
29 |
|
{ |
|
30 |
|
$files = array_diff(scandir($dir), ['.', '..']); |
|
31 |
|
foreach ($files as $file) { |
|
32 |
|
if (is_dir("$dir/$file")) { |
|
33 |
|
Utils::delTree("$dir/$file"); |
|
34 |
|
} else { |
|
35 |
|
unlink("$dir/$file"); |
|
36 |
|
} |
|
37 |
|
} |
|
38 |
|
return rmdir($dir); |
|
39 |
|
} |
|
40 |
|
|
|
41 |
|
} |
18 |
42 |
|
|
19 |
43 |
?> |
?> |
File daemon.php changed (mode: 100644) (index 623ace7..27c3306) |
15 |
15 |
|
|
16 |
16 |
require_once __DIR__ . '/classes/Builds.php'; |
require_once __DIR__ . '/classes/Builds.php'; |
17 |
17 |
require_once __DIR__ . '/classes/Buildset.php'; |
require_once __DIR__ . '/classes/Buildset.php'; |
|
18 |
|
require_once __DIR__ . '/classes/Utils.php'; |
18 |
19 |
require_once __DIR__ . '/config.php'; |
require_once __DIR__ . '/config.php'; |
19 |
20 |
|
|
20 |
21 |
// TODO: maybe mark all "running" builds as failed |
// TODO: maybe mark all "running" builds as failed |
|
... |
... |
function prepareRepository() |
39 |
40 |
|
|
40 |
41 |
system(__DIR__ . "/vcs/clone '" . REPO_URL . "'", $retval); |
system(__DIR__ . "/vcs/clone '" . REPO_URL . "'", $retval); |
41 |
42 |
if ($retval != 0) { |
if ($retval != 0) { |
42 |
|
delTree(REPO_PATH); |
|
|
43 |
|
Utils::delTree(REPO_PATH); |
43 |
44 |
die("Failed to clone repository\n"); |
die("Failed to clone repository\n"); |
44 |
45 |
} |
} |
45 |
46 |
} |
} |
46 |
47 |
|
|
47 |
|
/** |
|
48 |
|
* @brief Removes subtree. |
|
49 |
|
* |
|
50 |
|
* @param dir Directory path to remove. |
|
51 |
|
* |
|
52 |
|
* @returns Result of rmdir(). |
|
53 |
|
*/ |
|
54 |
|
function delTree($dir) |
|
55 |
|
{ |
|
56 |
|
$files = array_diff(scandir($dir), ['.', '..']); |
|
57 |
|
foreach ($files as $file) { |
|
58 |
|
(is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); |
|
59 |
|
} |
|
60 |
|
return rmdir($dir); |
|
61 |
|
} |
|
62 |
|
|
|
63 |
48 |
/** |
/** |
64 |
49 |
* @brief Performs infinite loop of running builds. |
* @brief Performs infinite loop of running builds. |
65 |
50 |
*/ |
*/ |