Mageia Bugzilla – Attachment 4106 Details for
Bug 6056
drakclock has a confusing message asking about hardware clock in GMT
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
patch to change GTM/UTC string, and better default for NTP severs
drakclock-utc-and-better-ntp-server-default.patch (text/plain), 5.09 KB, created by
Pablo Saratxaga
on 2013-06-06 11:20:15 CEST
(
hide
)
Description:
patch to change GTM/UTC string, and better default for NTP severs
Filename:
MIME Type:
Creator:
Pablo Saratxaga
Created:
2013-06-06 11:20:15 CEST
Size:
5.09 KB
patch
obsolete
>--- /usr/sbin/drakclock_bak 2013-06-05 22:18:11.377154883 +0200 >+++ /usr/sbin/drakclock 2013-06-06 10:53:37.158317831 +0200 >@@ -11,6 +11,7 @@ > use interactive; > use standalone; > use timezone; >+use lang; # to get the user country > > my $in = interactive->vnew('su'); > my $pixmap; >@@ -26,6 +27,7 @@ > my $ntpfile = '/etc/ntp.conf'; > my $ntpdlock = '/var/lock/subsys/ntpd'; > my $ntpdsystemdlock = '/sys/fs/cgroup/systemd/system/ntpd.service'; >+my $ntpdsystemdunit = '/usr/lib/systemd/system/ntpd.service'; > > my $my_win = ugtk2->new(N("Date, Clock & Time Zone Settings")); > >@@ -44,7 +46,7 @@ > $button_time->signal_connect(clicked => sub { > local $::isEmbedded = 0; # to prevent sub window embedding > if ($timezone->{timezone} = $in->ask_from_treelist(N("Timezone - DrakClock"), N("Which is your timezone?"), '/', \@timezones, $timezone->{timezone})) { >- $timezone->{UTC} = $in->ask_yesorno(N("GMT - DrakClock"), N("Is your hardware clock set to GMT?"), $timezone->{UTC}); >+ $timezone->{UTC} = $in->ask_yesorno(N("UTC - DrakClock"), N("Is your hardware clock set to UTC (universal time)?"), $timezone->{UTC}); > timezone::write($timezone); > } > $label_timezone->set_text($timezone->{timezone}); >@@ -116,15 +118,24 @@ > return; > } > timezone::set_ntp_server($choosed_serv); >- system(qw(/sbin/chkconfig --level 35 ntpd on)); > # FIXME: Change to use systemctl when will not support old iniscript anymore >+ if (-e $ntpdsystemdunit) { >+ system(qw(systemctl stop ntpd.service)); >+ system(qw(systemctl enable ntpd.service)); >+ } else { > system(qw(service ntpd stop)); >+ system(qw(/sbin/chkconfig --level 35 ntpd on)); >+ } > #verify that we have a valid hostname (thx sam) > $choosed_serv =~ s/[^-a-zA-Z0-9.]//g; > if (!system("/usr/sbin/ntpdate", $choosed_serv)) { > update_time(); #- get the new time before updating the hwclock > # FIXME: Change to use systemctl when will not support old iniscript anymore >+ if (-e $ntpdsystemdunit) { >+ system(qw(systemctl start ntpd.service)); >+ } else { > system(qw(service ntpd start)); >+ } > $need_date = 0; > } else { > $in->ask_from_no_check({ >@@ -135,14 +146,14 @@ > }, []) or return; > } > } else { >- if (-e $ntpdlock) { >- system(qw(service ntpd stop)); >- system(qw(/sbin/chkconfig --level 35 ntpd off)); >- } >- elsif (-e $ntpdsystemdlock) { >+ if (-e $ntpdsystemdlock) { > system(qw(systemctl stop ntpd.service)); > system(qw(systemctl disable ntpd.service)); > } >+ elsif (-e $ntpdlock) { >+ system(qw(service ntpd stop)); >+ system(qw(/sbin/chkconfig --level 35 ntpd off)); >+ } > } > if ($need_date) { > my ($year, $month, $day) = $calendar->get_date; >@@ -175,6 +186,7 @@ > my $servers = get_server(); > $combo_ntpserver->set_popdown_strings(@$servers); > if (-e $ntpfile && (-e $ntpdsystemdlock || -e $ntpdlock)) { >+ # if NTP is already configured, preset the NTP server value > $ntp = timezone::ntp_server(); > $ntp and ntp_widget_state(1); > my $fullntp = $ntp; >@@ -185,7 +197,22 @@ > /^[^:]+: \Q$short_ntp\E$/ and $fullntp = $_, last; > } > $combo_ntpserver->entry->set_text($fullntp); >-} else { ntp_widget_state(0) } >+} else { >+ # if NTP is not configured, preset the NTP server to match user country if possible >+ # if not, to match the continent from the timezone >+ ntp_widget_state(0); >+ my $country = lang::read()->{country}; >+ my $continent = $timezone->{timezone}; >+ $continent =~ s/^(.*)\/.*/$1/ ; >+ # "|" must be escaped as the sring will be used in a regexp match >+ my $continent_all_servers = N($continent) . "\\|" . N("All servers"); >+ my $fullntp; >+ foreach (@$servers) { >+ /^[^:]+: $country\.pool.ntp.org\E$/i and $fullntp = $_, last; >+ /^$continent_all_servers: [0-9a-z\._-]+$/ and $fullntp = $_; >+ } >+ $fullntp and $combo_ntpserver->entry->set_text($fullntp); >+} > > my $pressed; > $drawing_area->set_events([ 'button_press_mask', 'button_release_mask', "pointer_motion_mask" ]);
--- /usr/sbin/drakclock_bak 2013-06-05 22:18:11.377154883 +0200 +++ /usr/sbin/drakclock 2013-06-06 10:53:37.158317831 +0200 @@ -11,6 +11,7 @@ use interactive; use standalone; use timezone; +use lang; # to get the user country my $in = interactive->vnew('su'); my $pixmap; @@ -26,6 +27,7 @@ my $ntpfile = '/etc/ntp.conf'; my $ntpdlock = '/var/lock/subsys/ntpd'; my $ntpdsystemdlock = '/sys/fs/cgroup/systemd/system/ntpd.service'; +my $ntpdsystemdunit = '/usr/lib/systemd/system/ntpd.service'; my $my_win = ugtk2->new(N("Date, Clock & Time Zone Settings")); @@ -44,7 +46,7 @@ $button_time->signal_connect(clicked => sub { local $::isEmbedded = 0; # to prevent sub window embedding if ($timezone->{timezone} = $in->ask_from_treelist(N("Timezone - DrakClock"), N("Which is your timezone?"), '/', \@timezones, $timezone->{timezone})) { - $timezone->{UTC} = $in->ask_yesorno(N("GMT - DrakClock"), N("Is your hardware clock set to GMT?"), $timezone->{UTC}); + $timezone->{UTC} = $in->ask_yesorno(N("UTC - DrakClock"), N("Is your hardware clock set to UTC (universal time)?"), $timezone->{UTC}); timezone::write($timezone); } $label_timezone->set_text($timezone->{timezone}); @@ -116,15 +118,24 @@ return; } timezone::set_ntp_server($choosed_serv); - system(qw(/sbin/chkconfig --level 35 ntpd on)); # FIXME: Change to use systemctl when will not support old iniscript anymore + if (-e $ntpdsystemdunit) { + system(qw(systemctl stop ntpd.service)); + system(qw(systemctl enable ntpd.service)); + } else { system(qw(service ntpd stop)); + system(qw(/sbin/chkconfig --level 35 ntpd on)); + } #verify that we have a valid hostname (thx sam) $choosed_serv =~ s/[^-a-zA-Z0-9.]//g; if (!system("/usr/sbin/ntpdate", $choosed_serv)) { update_time(); #- get the new time before updating the hwclock # FIXME: Change to use systemctl when will not support old iniscript anymore + if (-e $ntpdsystemdunit) { + system(qw(systemctl start ntpd.service)); + } else { system(qw(service ntpd start)); + } $need_date = 0; } else { $in->ask_from_no_check({ @@ -135,14 +146,14 @@ }, []) or return; } } else { - if (-e $ntpdlock) { - system(qw(service ntpd stop)); - system(qw(/sbin/chkconfig --level 35 ntpd off)); - } - elsif (-e $ntpdsystemdlock) { + if (-e $ntpdsystemdlock) { system(qw(systemctl stop ntpd.service)); system(qw(systemctl disable ntpd.service)); } + elsif (-e $ntpdlock) { + system(qw(service ntpd stop)); + system(qw(/sbin/chkconfig --level 35 ntpd off)); + } } if ($need_date) { my ($year, $month, $day) = $calendar->get_date; @@ -175,6 +186,7 @@ my $servers = get_server(); $combo_ntpserver->set_popdown_strings(@$servers); if (-e $ntpfile && (-e $ntpdsystemdlock || -e $ntpdlock)) { + # if NTP is already configured, preset the NTP server value $ntp = timezone::ntp_server(); $ntp and ntp_widget_state(1); my $fullntp = $ntp; @@ -185,7 +197,22 @@ /^[^:]+: \Q$short_ntp\E$/ and $fullntp = $_, last; } $combo_ntpserver->entry->set_text($fullntp); -} else { ntp_widget_state(0) } +} else { + # if NTP is not configured, preset the NTP server to match user country if possible + # if not, to match the continent from the timezone + ntp_widget_state(0); + my $country = lang::read()->{country}; + my $continent = $timezone->{timezone}; + $continent =~ s/^(.*)\/.*/$1/ ; + # "|" must be escaped as the sring will be used in a regexp match + my $continent_all_servers = N($continent) . "\\|" . N("All servers"); + my $fullntp; + foreach (@$servers) { + /^[^:]+: $country\.pool.ntp.org\E$/i and $fullntp = $_, last; + /^$continent_all_servers: [0-9a-z\._-]+$/ and $fullntp = $_; + } + $fullntp and $combo_ntpserver->entry->set_text($fullntp); +} my $pressed; $drawing_area->set_events([ 'button_press_mask', 'button_release_mask', "pointer_motion_mask" ]);
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 6056
:
4106
|
4107