From 993a69436a8f99967ac0f29001eac36c9535366e Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 12 Jan 2024 15:31:09 +0100 Subject: [PATCH] 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. --- .../scripts/firmware/repos/SunnyValley.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/vendor/sunnyvalley/src/opnsense/scripts/firmware/repos/SunnyValley.php b/vendor/sunnyvalley/src/opnsense/scripts/firmware/repos/SunnyValley.php index 9866efbc5..badc4f46b 100755 --- a/vendor/sunnyvalley/src/opnsense/scripts/firmware/repos/SunnyValley.php +++ b/vendor/sunnyvalley/src/opnsense/scripts/firmware/repos/SunnyValley.php @@ -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);