0.10.0: guided setup (prereqs, default datastore via config.xml + vm init, first switch) and dashboard hint
This commit is contained in:
1 parent
0bea2dce52
commit
fd2f0192c3
6 files changed
+327
-2
No files matched your search
@@ -101,6 +101,52 @@ if (!function_exists('vmm_register_boot')) {
|
||||
return $added;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a plain rc.conf variable through config.xml (survives reboots) and
|
||||
* apply it to the running system via sysrc.
|
||||
*/
|
||||
function vmm_set_rc_param(string $name, string $value): bool
|
||||
{
|
||||
global $config;
|
||||
if (!isset($config['rc']['param']) || !is_array($config['rc']['param'])) {
|
||||
$config['rc'] = $config['rc'] ?? [];
|
||||
$config['rc']['param'] = [];
|
||||
}
|
||||
$found = false;
|
||||
foreach ($config['rc']['param'] as $i => $p) {
|
||||
if ((string)($p['name'] ?? '') === $name) {
|
||||
$config['rc']['param'][$i]['value'] = $value;
|
||||
$config['rc']['param'][$i]['enable'] = true;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$config['rc']['param'][] = [
|
||||
'uuid' => uuid(),
|
||||
'enable' => true,
|
||||
'name' => $name,
|
||||
'value' => $value,
|
||||
'comment' => '',
|
||||
];
|
||||
}
|
||||
write_config();
|
||||
// apply now, the file is only regenerated at boot
|
||||
@exec('/usr/sbin/sysrc ' . escapeshellarg($name . '=' . $value) . ' >/dev/null 2>&1');
|
||||
return true;
|
||||
}
|
||||
|
||||
function vmm_rc_param(string $name): string
|
||||
{
|
||||
global $config;
|
||||
foreach (($config['rc']['param'] ?? []) as $p) {
|
||||
if ((string)($p['name'] ?? '') === $name) {
|
||||
return (string)($p['value'] ?? '');
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function vmm_boot_state(): array
|
||||
{
|
||||
global $config;
|
||||
|
||||
Reference in new issue
Block a user