Исправлено отключение ntp

pull/46/head
Igor Belitskiy 3 years ago
parent e68202ce39
commit 3f04ea1279

@ -269,7 +269,7 @@ void MainWindow::event(){
btnMessClose->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_mess_close));
btnMessCloseSudo->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::gui_exit));
//cldrDate->signal_day_selected().connect(sigc::mem_fun(*this, &MainWindow::get_calendar));
btnUpdateDateTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::wrapper_update_time_date));
btnUpdateDateTime->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::update_time_date));
btnChooseDate->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::calendar_show));
cbDhcp->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::event_entry_cbDhcp));
cbRegion->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::append_zone));
@ -287,7 +287,6 @@ void MainWindow::wind_close_ntp(){
}
void MainWindow::stop_ntp(){
windowsNnpClose->hide();
string cmd = "SEL_SERVICE=\"systemd-timesyncd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service; ";
system(cmd.c_str());
cmd ="SEL_SERVICE=\"ntpd\"; systemctl --quiet is-active ${SEL_SERVICE}.service &>/dev/null && systemctl stop ${SEL_SERVICE}.service || pkill -9 ${SEL_SERVICE}; ";
@ -302,8 +301,6 @@ void MainWindow::stop_ntp(){
system(cmd.c_str());
cmd ="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();
}
@ -355,6 +352,7 @@ void MainWindow::event_entry_cbDhcp(){
int activ_index = cbDhcp->get_active_row_number();
if (str_dhcp.length()!=0){
if (activ_index==0){
btnUpdateDateTime->set_sensitive(false);
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=default";
system(cmd.c_str());
txtNtpServer->set_sensitive(false);
@ -364,6 +362,7 @@ void MainWindow::event_entry_cbDhcp(){
txtNtpServer->set_text(response);
}
else if (activ_index==1){
btnUpdateDateTime->set_sensitive(false);
string cmd = "/usr/bin/ubconfig set network NTPSERVERS=dhcp";
system(cmd.c_str());
txtNtpServer->set_sensitive(false);
@ -371,6 +370,7 @@ void MainWindow::event_entry_cbDhcp(){
txtNtpServer->set_text("");
}
else if (activ_index==2){
btnUpdateDateTime->set_sensitive(false);
txtNtpServer->set_sensitive(true);
if (txtNtpServer->get_text().find("default")!=std::string::npos){
txtNtpServer->set_text("");
@ -390,6 +390,8 @@ void MainWindow::event_entry_cbDhcp(){
system(cmd.c_str());
txtNtpServer->set_text("");
txtNtpServer->set_sensitive(false);
btnUpdateDateTime->set_sensitive(true);
this->stop_ntp();
}
}
@ -451,19 +453,23 @@ void MainWindow::calendar_show(){
void MainWindow::enry_dhcp_mess(){
string str_dhcp = this->call("/usr/bin/ubconfig get network NTPSERVERS");
if (str_dhcp.find("(null)")==std::string::npos){
btnUpdateDateTime->set_sensitive(false);
str_dhcp = str_dhcp.substr(str_dhcp.find("=")+1,str_dhcp.length());
str_dhcp = str_dhcp.substr(0,str_dhcp.find("\n"));
if (str_dhcp=="dhcp"){
cbDhcp->set_active(1);
txtNtpServer->set_text("");
txtNtpServer->set_sensitive(false);
}
else if (str_dhcp=="default"){
btnUpdateDateTime->set_sensitive(false);
cbDhcp->set_active(0);
txtNtpServer->set_text("");
txtNtpServer->set_sensitive(false);
}
else{
btnUpdateDateTime->set_sensitive(false);
if (str_dhcp==""){
lblMessage->set_text(_("Enter DHCP!"));
mess_dchp->show();
@ -483,6 +489,7 @@ void MainWindow::enry_dhcp_mess(){
cbDhcp->set_active(3);
txtNtpServer->set_text("");
txtNtpServer->set_sensitive(false);
btnUpdateDateTime->set_sensitive(true);
}
}
@ -676,17 +683,6 @@ void MainWindow::append_zone_glob(){
}
cbZoneGlob->set_active(0);
}
void MainWindow::wrapper_update_time_date(){
string cmd = "pidof systemd-timesyncd ntpd chronyd ntpdate openntpd ptp4l phc2sys";
string response = this->call(cmd);
if (response.length()==0){
this->update_time_date();
}
else{
windowsNnpClose->show();
}
}
void MainWindow::update_time_date(){
//this->enter_zone();

Loading…
Cancel
Save