mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user