-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathlibvirtconfig
More file actions
executable file
·41 lines (40 loc) · 1.19 KB
/
libvirtconfig
File metadata and controls
executable file
·41 lines (40 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/php -q
<?PHP
/* Copyright 2015-2023, Lime Technology
* Copyright 2015-2016, Guilherme Jardim, Eric Schultz, Jon Panozzo.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$cfgfile = "/boot/config/domain.cfg";
$cfg_defaults = [
"SERVICE" => "disable",
"IMAGE_FILE" => "/mnt/user/system/libvirt/",
"OLD_IMAGE_FILE" => "/mnt/user/system/libvirt/",
"IMAGE_SIZE" => "1",
"DEBUG" => "no",
"DOMAINDIR" => "/mnt/user/domains/",
"MEDIADIR" => "/mnt/user/isos/",
"VIRTIOISO" => "",
"BRNAME" => "br0",
"VMSTORAGEMODE" => "auto"
];
$cfg_new = $cfg_defaults;
if (file_exists($cfgfile)) {
$cfg_old = parse_ini_file($cfgfile);
if (!empty($cfg_old)) {
$cfg_new = array_merge($cfg_defaults, $cfg_old);
if (empty(array_diff($cfg_new, $cfg_old))) unset($cfg_new);
}
}
if (isset($cfg_new)) {
foreach ($cfg_new as $key => $value) $tmp .= "$key=\"$value\"\n";
file_put_contents($cfgfile, $tmp);
}
?>