Allow the OEM config to be provided as JSON files
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Родитель
f7768f0075
Коммит
df1d5e5cb4
|
@ -0,0 +1 @@
|
|||
config/*.json
|
30
README.md
30
README.md
|
@ -1,3 +1,31 @@
|
|||
# Nextcloud Client Updater Server
|
||||
|
||||
This is the Nextcloud client update server.
|
||||
This is the Nextcloud client update server.
|
||||
|
||||
## Ship config of other OEMs
|
||||
|
||||
Just create a json file in `config/` with the name of the OEM that contains the same entries as the `config.php`.
|
||||
|
||||
If the default `config.php` doesn't hold update information for this OEM, the config is read from the JSON file.
|
||||
|
||||
```json
|
||||
{
|
||||
"linux": {
|
||||
"version": "2.3.2",
|
||||
"versionstring": "Nextcloud Client 2.3.2",
|
||||
"web": "https://nextcloud.com/install/?pk_campaign=clientupdate#install-clients"
|
||||
},
|
||||
"win32": {
|
||||
"version": "2.3.2.1",
|
||||
"versionstring": "Nextcloud Client 2.3.2 (build 1)",
|
||||
"downloadUrl": "https://download.nextcloud.com/desktop/releases/Windows/Nextcloud-2.3.2.1-setup.exe",
|
||||
"web": "https://nextcloud.com/install/?pk_campaign=clientupdate#install-clients"
|
||||
},
|
||||
"macos": {
|
||||
"version": "2.2.4.1",
|
||||
"versionstring": "Nextcloud Client 2.2.4 (build 1)",
|
||||
"downloadUrl": "https://download.nextcloud.com/desktop/releases/Mac/Updates/Nextcloud-2.2.4.1.pkg.tbz",
|
||||
"signature": "MCwCFGC3X/fejC/y/3T2X+c8ldDk7pJGAhQoR8v6vtvvV57nIcMNePA+jNRYcw=="
|
||||
}
|
||||
}
|
||||
```
|
|
@ -60,7 +60,25 @@ class Response {
|
|||
*/
|
||||
private function getUpdateVersion() : array {
|
||||
if(!isset($this->config[$this->oem])) {
|
||||
return [];
|
||||
if (preg_match('/^[a-zA-Z0-9-_.]+$/', $this->oem) !== 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!file_exists(__DIR__ . '/../config/' . $this->oem . '.json')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$content = file_get_contents(__DIR__ . '/../config/' . $this->oem . '.json');
|
||||
if ($content === false) {
|
||||
return [];
|
||||
}
|
||||
$data = json_decode($content, true);
|
||||
|
||||
if (!is_array($data)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$this->config[$this->oem] = $data;
|
||||
}
|
||||
|
||||
if(!isset($this->config[$this->oem][$this->platform])) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче