From 81fa07d9aae85d7e6ce71126938b372c373bbd0d Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 18 Dec 2017 11:32:21 +0100 Subject: [PATCH] PMG/Fetchmail.pm - autostart fetchmail service --- PMG/Fetchmail.pm | 2 ++ PMG/Utils.pm | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/PMG/Fetchmail.pm b/PMG/Fetchmail.pm index 5e44aa0..7e16c79 100644 --- a/PMG/Fetchmail.pm +++ b/PMG/Fetchmail.pm @@ -7,6 +7,7 @@ use Data::Dumper; use PVE::Tools; use PVE::INotify; +use PMG::Utils; use PMG::Config; use PMG::ClusterConfig; @@ -239,6 +240,7 @@ sub update_fetchmail_default { if (($role eq '-') || ($role eq 'master')) { if (!!$enable != !!$is_enabled) { PVE::INotify::write_file('fetchmail_default', $enable); + PMG::Utils::service_cmd('fetchmail', 'restart'); } if (! -e $config_link_filename) { symlink ($config_filename, $config_link_filename); diff --git a/PMG/Utils.pm b/PMG/Utils.pm index 563d800..aa0da54 100644 --- a/PMG/Utils.pm +++ b/PMG/Utils.pm @@ -574,6 +574,10 @@ sub service_cmd { if ($service eq 'pmgdaemon' || $service eq 'pmgproxy') { die "invalid service cmd '$service $cmd': ERROR" if $cmd eq 'stop'; + } elsif ($service eq 'fetchmail') { + # use restart instead of start - else it does not start 'exited' unit + # after setting START_DAEMON=yes in /etc/default/fetchmail + $cmd = 'restart' if $cmd eq 'start'; } $service = $service_aliases->{$service} // $service; -- 2.39.2