Merge pull request 'Исправлен баг с остановкой ntp' (#7) from develop into master

Reviewed-on: Igor1/ubl-settings-datetime#7
pull/31/head
Igor Belitskiy 3 years ago
commit 387ebde6a1

@ -290,19 +290,14 @@ void MainWindow::wind_close_ntp(){
void MainWindow::stop_ntp(){ void MainWindow::stop_ntp(){
windowsNnpClose->hide(); windowsNnpClose->hide();
string cmd = ""; string cmd = "SEL_SERVICE=\"systemd-timesyncd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service; "
string response = ""; "SEL_SERVICE=\"ntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "
string array_servis[8] = {"systemd-timesyncd", "chronyd.service", "ntp.service", "ntpdate.service", "SEL_SERVICE=\"ntpdate\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "
"ntpd.service", "ptp4l.service", "openntpd.service", "phc2sys.service"}; "SEL_SERVICE=\"chronyd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "
for (string &name_serive: array_servis){ "SEL_SERVICE=\"openntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ntpd; "
cmd = "systemctl status " + name_serive + " | grep \"Active: active\""; "SEL_SERVICE=\"ptp4l\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; "
response = this->call(cmd.c_str()); "SEL_SERVICE=\"phc2sys\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE} ";
if (response.length()!=0){
cmd = "systemctl --quiet is-active " + name_serive + " &>/dev/null && systemctl stop " + name_serive;
this->call(cmd.c_str());
}
}
system(cmd.c_str()); system(cmd.c_str());
this->update_time_date(); this->update_time_date();

Loading…
Cancel
Save