From f778af84a09bb1cb1645126bb863311e220dc4f0 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Mon, 16 Feb 2026 20:15:52 +0200 Subject: [PATCH] Fix `create_launchd_agent` to support optional load parameter https://github.com/webmin/authentic-theme/issues/1729#issuecomment-3899950457 --- init/init-lib.pl | 11 +++++++---- init/updateboot.pl | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/init/init-lib.pl b/init/init-lib.pl index ae3ed90ce..9ffa1b711 100644 --- a/init/init-lib.pl +++ b/init/init-lib.pl @@ -2816,14 +2816,15 @@ foreach my $a (@rv) { return @rv; } -=head2 create_launchd_agent(name, start-script, boot-flag) +=head2 create_launchd_agent(name, start-script, boot-flag, [load-now]) Creates a new my launchd agent =cut sub create_launchd_agent { -my ($name, $start, $boot) = @_; +my ($name, $start, $boot, $load) = @_; +$load = 1 if (!defined($load)); my $file = "/Library/LaunchDaemons/".$name.".plist"; my $plist = "\n". "\n". @@ -2846,8 +2847,10 @@ $plist .= "\n"; &open_lock_tempfile(PLIST, ">$file"); &print_tempfile(PLIST, $plist); &close_tempfile(PLIST); -my $out = &backquote_logged("launchctl load ".quotemeta($file)." 2>&1"); -&error("Failed to load plist : $out") if ($?); +if ($load) { + my $out = &backquote_logged("launchctl load ".quotemeta($file)." 2>&1"); + &error("Failed to load plist : $out") if ($?); + } } =head2 delete_launchd_agent(name) diff --git a/init/updateboot.pl b/init/updateboot.pl index 5d55c5ce5..e3ffebf5c 100755 --- a/init/updateboot.pl +++ b/init/updateboot.pl @@ -69,12 +69,12 @@ if ($product) { &delete_launchd_agent($name); &create_launchd_agent($name, "$config_directory/.start-init --nofork", - $boot); + $boot, 0); } elsif ($want_boot) { &create_launchd_agent($name, "$config_directory/.start-init --nofork", - 1); + 1, 0); } } elsif (-d "/etc/init.d") {