From ff65712fd9e5565691b2f4657b051badb8d0ff40 Mon Sep 17 00:00:00 2001 From: Digimer Date: Mon, 24 May 2021 15:27:10 -0400 Subject: [PATCH] * Created the function check_daemons() in anvil-daemon to check that needed daemons are running when it starts. This was specifically added to address a periodic issue with machines booting without NetworkManager running. Signed-off-by: Digimer --- share/words.xml | 2 ++ tools/anvil-daemon | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/share/words.xml b/share/words.xml index bf5365a3..3673aa94 100644 --- a/share/words.xml +++ b/share/words.xml @@ -2120,6 +2120,8 @@ Are you sure that you want to delete the server: [#!variable!server_name!#]? [Ty Purging the Anvil!: [#!variable!anvil_name!#] (UUID: [#!variable!anvil_uuid!#]: '. Available servers on this Anvil! system;]]> Created the journald directory: [#!variable!directory!#]. + Checking that the daemon: [#!variable!daemon!#] is running. + The daemon: [#!variable!daemon!#] was not running, starting it now. Saved the mail server information successfully! diff --git a/tools/anvil-daemon b/tools/anvil-daemon index 17168b09..16d2b488 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -579,9 +579,12 @@ sub run_once # Check to see if we need to do boot-time tasks. We only run these if we've just booted boot_time_tasks($anvil); + # Check that the daemons we need are running. + check_daemons($anvil); + # Check the ssh stuff. # NOTE: This actually runs again in the minutes tasks, but needs to run on boot as well. - $anvil->System->check_ssh_keys({debug => 3}); + $anvil->System->check_ssh_keys(); # Check setuid wrappers check_setuid_wrappers($anvil); @@ -597,6 +600,28 @@ sub run_once return(0); } +sub check_daemons +{ + my ($anvil) = @_; + + foreach my $daemon ("NetworkManager") + { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "message_0249", variables => { daemon => $daemon }}); + + my $running = $anvil->System->check_daemon({daemon => $daemon}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { running => $running }}); + + if (not $running) + { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "message_0250", variables => { daemon => $daemon }}); + my $return_code = $anvil->System->start_daemon({daemon => $daemon}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { return_code => $return_code }}); + } + } + + return(0); +} + sub check_journald { my ($anvil) = @_;