From f54579433454284e83ec4569732e0898c5f43668 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Thu, 9 Feb 2023 17:18:30 +0600 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3=20=D1=81=20=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=BE=D0=B9=20ntp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index 459a472..f4eecf6 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -290,19 +290,14 @@ void MainWindow::wind_close_ntp(){ void MainWindow::stop_ntp(){ windowsNnpClose->hide(); - string cmd = ""; - string response = ""; - string array_servis[8] = {"systemd-timesyncd", "chronyd.service", "ntp.service", "ntpdate.service", - "ntpd.service", "ptp4l.service", "openntpd.service", "phc2sys.service"}; - for (string &name_serive: array_servis){ - cmd = "systemctl status " + name_serive + " | grep \"Active: active\""; - response = this->call(cmd.c_str()); - if (response.length()!=0){ - cmd = "systemctl --quiet is-active " + name_serive + " &>/dev/null && systemctl stop " + name_serive; - this->call(cmd.c_str()); - } - } - + string cmd = "SEL_SERVICE=\"systemd-timesyncd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service; " + "SEL_SERVICE=\"ntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; " + "SEL_SERVICE=\"ntpdate\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; " + "SEL_SERVICE=\"chronyd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; " + "SEL_SERVICE=\"openntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ntpd; " + "SEL_SERVICE=\"ptp4l\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; " + "SEL_SERVICE=\"phc2sys\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE} "; + system(cmd.c_str()); this->update_time_date();