vendor/sunnyvalley: simplify previous, make sure to rewrite

We do want to rewrite the plain file even if the binary is not
found.  Same behaviour as with the other repo scripts.
This commit is contained in:
Franco Fichtner
2024-01-12 15:31:09 +01:00
parent d4b94cfdb5
commit 993a69436a
@@ -30,13 +30,18 @@
require_once 'util.inc';
$conf = '/usr/local/etc/pkg/repos/SunnyValley.conf';
$uuidPattern = '/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/';
if (file_exists($conf . '.shadow') && file_exists('/usr/local/zenarmor/bin/eastpect')) {
$node_uuid = shell_safe('/usr/local/zenarmor/bin/eastpect -s');
if ($node_uuid != '') {
$fileContents = file_get_contents($conf . '.shadow');
$fileContents = str_replace('/latest"', '/' . $node_uuid . '"', $fileContents);
file_put_contents($conf, $fileContents);
if (!file_exists($conf . '.shadow')) {
exit(0);
}
$fileContents = file_get_contents($conf . '.shadow');
if (file_exists('/usr/local/zenarmor/bin/eastpect')) {
$uuid = shell_safe('/usr/local/zenarmor/bin/eastpect -s');
if ($uuid != '') {
$fileContents = str_replace('/latest"', '/' . $uuid . '"', $fileContents);
}
}
file_put_contents($conf, $fileContents);