From fd3d51f0295de6e073edc8fb30a5b35729d4ce92 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Fri, 3 Feb 2023 17:55:18 +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=D0=B0=20=D0=BE=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20Ntp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/ubl-settings-datetime.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/ubl-settings-datetime.cc b/source/ubl-settings-datetime.cc index f623641..918dc24 100644 --- a/source/ubl-settings-datetime.cc +++ b/source/ubl-settings-datetime.cc @@ -280,12 +280,28 @@ void MainWindow::wind_close_ntp(){ void MainWindow::stop_ntp(){ windowsNnpClose->hide(); + /* // string cmd = "systemd-timesyncd [[ systemctl --quiet is-active systemd-timesyncd &>/dev/null ]] && systemctl stop systemd-timesyncd"; + string cmd = "sudo systemctl stop systemd-timesyncd; " ; cmd += "sudo systemctl stop ntp.service; sudo systemctl stop ntpdate.service; "; cmd += "sudo systemctl stop chronyd; sudo service ntpd stop; sudo systemctl stop ptp4l; "; cmd += "sudo systemctl stop openntpd.service; sudo timedatectl set-ntp false"; cmd += "sudo systemctl stop phc2sys"; + */ + string cmd = ""; + string response = ""; + string array_servis[8] = {"systemd-timesyncd", "chronyd", "ntp.service", "ntpdate.service", + "ntpd", "ptp4l", "openntpd.service", "phc2sys"}; + for (string &name_serive: array_servis){ + cmd = "sudo systemctl status " + name_serive + " | grep \"Active: active\""; + response = this->call(cmd.c_str()); + if (response.length()!=0){ + cmd = "sudo systemctl stop " + name_serive; + this->call(cmd.c_str()); + } + } + system(cmd.c_str()); this->update_time_date();