From 0e0d7b8adf4015724c52b60d546e446f1f45266a Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Tue, 25 Feb 2025 15:10:13 -0500 Subject: [PATCH 1/3] Fix: Last container wouldn't autostart --- emhttp/plugins/dynamix.docker.manager/scripts/docker_init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix.docker.manager/scripts/docker_init b/emhttp/plugins/dynamix.docker.manager/scripts/docker_init index 99f3fd76d..e7168d885 100755 --- a/emhttp/plugins/dynamix.docker.manager/scripts/docker_init +++ b/emhttp/plugins/dynamix.docker.manager/scripts/docker_init @@ -29,5 +29,5 @@ foreach ($autostart as $container) { } $newAuto[] = $container; } -file_put_contents("/var/lib/docker/unraid-autostart",implode("\n",$newAuto)); +file_put_contents("/var/lib/docker/unraid-autostart",implode("\n",$newAuto)."\n"); ?> From f9e20d10b4e57b1533ff084e984aa2d0d43a559c Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Tue, 25 Feb 2025 15:24:03 -0500 Subject: [PATCH 2/3] Prevent extraneous writes --- emhttp/plugins/dynamix.docker.manager/scripts/docker_init | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix.docker.manager/scripts/docker_init b/emhttp/plugins/dynamix.docker.manager/scripts/docker_init index e7168d885..bc010031d 100755 --- a/emhttp/plugins/dynamix.docker.manager/scripts/docker_init +++ b/emhttp/plugins/dynamix.docker.manager/scripts/docker_init @@ -4,6 +4,7 @@ $autostart = @file("/var/lib/docker/unraid-autostart",FILE_IGNORE_NEW_LINES); if ( ! $autostart ) exit(); +$flag = false; $newAuto = []; foreach ($autostart as $container) { if (! trim($container) ) continue; @@ -15,7 +16,7 @@ foreach ($autostart as $container) { } $doc = new DOMDocument(); - if (!$doc->load("/boot/config/plugins/dockerMan/templates-user/my-{$cont[0]}.xml")) { + if (!$doc->load("/boot/config/plugins/dockerMan/templates-user/my-{$cont[0]}.xml")) { $newAuto[] = $container; continue; } @@ -24,10 +25,12 @@ foreach ($autostart as $container) { exec("logger ".escapeshellarg("Autostart disabled on {$cont[0]} due to tailscale integration with host network.")); exec("logger ".escapeshellarg("This is a security risk due to the possibility of unauthenticated access to your server's GUI and resources")); exec("/usr/local/emhttp/plugins/dynamix/scripts/notify -e 'Autostart Disabled' -s 'Autostart Disabled' -d ".escapeshellarg("Autostart disabled automatically on {$cont[0]}")." -m ".escapeshellarg("Autostart has been automatically disabled on {$cont[0]} due to a security issue with container on network type host and tailscale integration enabled. You should either switch the network type or disabled tailscale integration on this container")." -i 'alert' -l '/Docker'"); + $flag = true; continue; } } $newAuto[] = $container; } -file_put_contents("/var/lib/docker/unraid-autostart",implode("\n",$newAuto)."\n"); +if ( $flag ) + file_put_contents("/var/lib/docker/unraid-autostart",implode("\n",$newAuto."\n"); ?> From a6aeb86c6946a1a2642b12729af5450e15aacc6e Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Tue, 25 Feb 2025 15:30:58 -0500 Subject: [PATCH 3/3] Update docker_init --- emhttp/plugins/dynamix.docker.manager/scripts/docker_init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix.docker.manager/scripts/docker_init b/emhttp/plugins/dynamix.docker.manager/scripts/docker_init index bc010031d..8431d2a25 100755 --- a/emhttp/plugins/dynamix.docker.manager/scripts/docker_init +++ b/emhttp/plugins/dynamix.docker.manager/scripts/docker_init @@ -32,5 +32,5 @@ foreach ($autostart as $container) { $newAuto[] = $container; } if ( $flag ) - file_put_contents("/var/lib/docker/unraid-autostart",implode("\n",$newAuto."\n"); + file_put_contents("/var/lib/docker/unraid-autostart",implode("\n",$newAuto)."\n"); ?>