Skip to content

Commit 129f62b

Browse files
authored
Merge pull request #256 from lbr38/devel
4.20.0
2 parents 891a249 + 587036f commit 129f62b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+835
-397
lines changed

docker/init

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ if [ -z "$FQDN" ];then
1515
exit 1
1616
fi
1717

18+
echo "Starting up"
19+
1820
# Set FQDN
1921
# Postfix/mail configuration
2022
postconf -e "myhostname = $FQDN"

www/controllers/App/Config/Settings.php

+16
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ public static function get()
130130
}
131131
}
132132

133+
if (!defined('TASK_CLEAN_OLDER_THAN')) {
134+
if (!empty($settings['TASK_CLEAN_OLDER_THAN'])) {
135+
define('TASK_CLEAN_OLDER_THAN', $settings['TASK_CLEAN_OLDER_THAN']);
136+
} else {
137+
define('TASK_CLEAN_OLDER_THAN', 730);
138+
}
139+
}
140+
133141
if (!defined('WWW_REPOS_DIR_URL')) {
134142
define('WWW_REPOS_DIR_URL', __SERVER_PROTOCOL__ . '://' . WWW_HOSTNAME . '/repo');
135143
}
@@ -257,6 +265,14 @@ public static function get()
257265
}
258266
}
259267

268+
if (!defined('DEB_ALLOW_EMPTY_REPO')) {
269+
if (!empty($settings['DEB_ALLOW_EMPTY_REPO'])) {
270+
define('DEB_ALLOW_EMPTY_REPO', $settings['DEB_ALLOW_EMPTY_REPO']);
271+
} else {
272+
define('DEB_ALLOW_EMPTY_REPO', 'false');
273+
}
274+
}
275+
260276
if (!defined('DEB_INVALID_SIGNATURE')) {
261277
if (!empty($settings['DEB_INVALID_SIGNATURE'])) {
262278
define('DEB_INVALID_SIGNATURE', $settings['DEB_INVALID_SIGNATURE']);

www/controllers/Browse.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public static function printFile($file, $path)
7777
* Etc ...
7878
*/
7979
$extension = pathinfo($file, PATHINFO_EXTENSION);
80-
if ($extension == 'deb' || $extension == 'rpm') {
80+
81+
if (in_array($extension, ['deb', 'rpm', 'xz', 'gz', 'dsc'])) {
8182
$title = 'Package file';
8283
$icon = 'package';
8384
$checkbox = true;

www/controllers/Filesystem/File.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static function recursiveChown(string $path, string $owner, string $group
123123
/**
124124
* Return an array with the list of founded files in specified directory path
125125
*/
126-
public static function findRecursive(string $path, string $fileExtension = null, bool $absolute = true)
126+
public static function findRecursive(string $path, array $fileExtension = [], bool $absolute = true)
127127
{
128128
$foundedFiles = array();
129129

@@ -146,13 +146,11 @@ public static function findRecursive(string $path, string $fileExtension = null,
146146
}
147147

148148
/**
149-
* If an extension has been specified, then check that the file has correct extension
149+
* If one or more extension(s) have been specified, then check that the file has correct extension
150+
* Otherwise, ignore it
150151
*/
151152
if (!empty($fileExtension)) {
152-
/**
153-
* If extension is incorrect, then ignore the current file and process the next one
154-
*/
155-
if ($file->getExtension() != $fileExtension) {
153+
if (!in_array($file->getExtension(), $fileExtension)) {
156154
continue;
157155
}
158156
}

www/controllers/Host.php

-7
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,6 @@ public function closeHostDb()
761761
*/
762762
public function register()
763763
{
764-
/**
765-
* Lorsque appelé par l'api, HOSTS_DIR n'est pas setté, donc on le fait
766-
*/
767-
// if (!defined('HOSTS_DIR')) {
768-
// define('HOSTS_DIR', DATA_DIR . '/hosts');
769-
// }
770-
771764
/**
772765
* Si on n'a pas renseigné l'IP ou le hostname alors on quitte
773766
*/

www/controllers/Layout/Container/vars/browse/actions.vars.inc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
try {
5454
$myrepoPackage->upload($_POST['snapId'], \Controllers\Browse::reArrayFiles($_FILES['packages']));
55-
$uploadSuccessMessage = '<br>Packages uploaded successfully';
55+
$uploadSuccessMessage = 'Packages uploaded successfully';
5656
} catch (\Exception $e) {
5757
$uploadErrorMessage = $e->getMessage();
5858
}

www/controllers/Layout/Container/vars/browse/list.vars.inc.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
*/
4040
if ($myrepo->getPackageType() == 'rpm') {
4141
$repoSize = \Controllers\Filesystem\Directory::getSize(REPOS_DIR . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getName());
42-
$packagesCount = count(\Controllers\Filesystem\File::findRecursive(REPOS_DIR . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getName(), 'rpm'));
42+
$packagesCount = count(\Controllers\Filesystem\File::findRecursive(REPOS_DIR . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getName(), ['rpm']));
4343
}
4444
if ($myrepo->getPackageType() == 'deb') {
4545
$repoSize = \Controllers\Filesystem\Directory::getSize(REPOS_DIR . '/' . $myrepo->getName() . '/' . $myrepo->getDist() . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getSection());
46-
$packagesCount = count(\Controllers\Filesystem\File::findRecursive(REPOS_DIR . '/' . $myrepo->getName() . '/' . $myrepo->getDist() . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getSection(), 'deb'));
46+
$packagesCount = count(\Controllers\Filesystem\File::findRecursive(REPOS_DIR . '/' . $myrepo->getName() . '/' . $myrepo->getDist() . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getSection(), ['deb']));
4747
}
4848

4949
/**

www/controllers/Layout/Container/vars/stats/list.vars.inc.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
*/
6565
if ($myrepo->getPackageType() == 'rpm') {
6666
$repoSize = \Controllers\Filesystem\Directory::getSize(REPOS_DIR . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getName());
67-
$packagesCount = count(\Controllers\Filesystem\File::findRecursive(REPOS_DIR . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getName(), 'rpm'));
67+
$packagesCount = count(\Controllers\Filesystem\File::findRecursive(REPOS_DIR . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getName(), ['rpm']));
6868
}
6969
if ($myrepo->getPackageType() == 'deb') {
7070
$repoSize = \Controllers\Filesystem\Directory::getSize(REPOS_DIR . '/' . $myrepo->getName() . '/' . $myrepo->getDist() . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getSection());
71-
$packagesCount = count(\Controllers\Filesystem\File::findRecursive(REPOS_DIR . '/' . $myrepo->getName() . '/' . $myrepo->getDist() . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getSection(), 'deb'));
71+
$packagesCount = count(\Controllers\Filesystem\File::findRecursive(REPOS_DIR . '/' . $myrepo->getName() . '/' . $myrepo->getDist() . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getSection(), ['deb']));
7272
}
7373

7474
/**

www/controllers/Layout/Container/vars/tasks/log.vars.inc.php

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
throw new Exception('No task found.');
2525
}
2626

27+
// Check if task exists
28+
if (!$taskController->exists($taskId)) {
29+
throw new Exception('Task #' . $taskId . ' not found.');
30+
}
31+
2732
// Get task info
2833
$taskInfo = $taskController->getById($taskId);
2934

www/controllers/Log/Log.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,16 @@ public function log(string $type, string $component, string $message, string $de
5555
/**
5656
* If the log could not be saved in database, log the error in error_log
5757
*/
58-
} catch (\Exception $e) {
58+
} catch (Exception $e) {
5959
error_log('Here is a database error while trying to save log: ' . $e . PHP_EOL);
6060

61-
6261
/**
6362
* If the log cannot be saved then log directly in error_log
6463
*/
6564
if (!empty($details)) {
66-
error_log('Here is a the original error that could not be saved in database: ' . $message . ': ' . $details . PHP_EOL);
65+
error_log('Here is the original error that could not be saved in database: ' . $message . ': ' . $details . PHP_EOL);
6766
} else {
68-
error_log('Here is a the original error that could not be saved in database: ' . $message . PHP_EOL);
67+
error_log('Here is the original error that could not be saved in database: ' . $message . PHP_EOL);
6968
}
7069
}
7170
}

www/controllers/Profile.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public function getProfilePackagesConfiguration(string $profile)
115115
*/
116116
$configuration['Package_exclude'] = $fullConfiguration['Package_exclude'];
117117
$configuration['Package_exclude_major'] = $fullConfiguration['Package_exclude_major'];
118+
$configuration['Service_reload'] = $fullConfiguration['Service_reload'];
118119
$configuration['Service_restart'] = $fullConfiguration['Service_restart'];
119120

120121
return $configuration;
@@ -295,7 +296,7 @@ public function duplicate(string $id)
295296
/**
296297
* Copy source profile configuration to new profile
297298
*/
298-
$this->model->configure($newProfileId, $newName, $profileConf['Package_exclude'], $profileConf['Package_exclude_major'], $profileConf['Service_restart'], $profileConf['Notes']);
299+
$this->model->configure($newProfileId, $newName, $profileConf['Package_exclude'], $profileConf['Package_exclude_major'], $profileConf['Service_reload'], $profileConf['Service_restart'], $profileConf['Notes']);
299300

300301
/**
301302
* Retrieve source profile repos members
@@ -346,7 +347,7 @@ public function delete(int $id)
346347
/**
347348
* Configure profile
348349
*/
349-
public function configure(int $id, string $name, array $reposIds = null, array $packagesExcluded = null, array $packagesMajorExcluded = null, array $serviceNeedRestart = null, string $notes)
350+
public function configure(int $id, string $name, array $reposIds, array $packagesExcluded, array $packagesMajorExcluded, array $serviceNeedReload, array $serviceNeedRestart, string $notes)
350351
{
351352
if (!IS_ADMIN) {
352353
throw new Exception('You are not allowed to perform this action');
@@ -356,7 +357,6 @@ public function configure(int $id, string $name, array $reposIds = null, array $
356357
$myHost = new \Controllers\Host();
357358
$myHostRequest = new \Controllers\Host\Request();
358359
$error = 0;
359-
360360
$name = \Controllers\Common::validateData($name);
361361

362362
/**
@@ -498,6 +498,7 @@ public function configure(int $id, string $name, array $reposIds = null, array $
498498
*/
499499
$packagesExcludedExploded = implode(',', $packagesExcluded);
500500
$packagesMajorExcludedExploded = implode(',', $packagesMajorExcluded);
501+
$serviceNeedReloadExploded = implode(',', $serviceNeedReload);
501502
$serviceNeedRestartExploded = implode(',', $serviceNeedRestart);
502503

503504
/**
@@ -510,7 +511,7 @@ public function configure(int $id, string $name, array $reposIds = null, array $
510511
/**
511512
* Insert new configuration into database
512513
*/
513-
$this->model->configure($id, $name, $packagesExcludedExploded, $packagesMajorExcludedExploded, $serviceNeedRestartExploded, $notes);
514+
$this->model->configure($id, $name, $packagesExcludedExploded, $packagesMajorExcludedExploded, $serviceNeedReloadExploded, $serviceNeedRestartExploded, $notes);
514515

515516
/**
516517
* Get all hosts using this profile

0 commit comments

Comments
 (0)