mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Hardware clock detection
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
lease=5
|
||||
hwtime=1
|
||||
hwtime=2
|
||||
seconds=1
|
||||
timeserver_hardware=1
|
||||
zone_style=linux
|
||||
|
||||
@@ -3,7 +3,7 @@ lease=Acceptable number seconds of delay between system time and hardware time,0
|
||||
timeserver=Default time server,3,None
|
||||
ntp_only=Only use NTP for time synchronization?,1,1-Yes,0-No
|
||||
line2=System configuration,11
|
||||
hwtime=System supports hardware time,1,1-Yes,0-No
|
||||
hwtime=System supports hardware time,1,1-Yes,0-No,2-Detect automatically
|
||||
seconds=System time setting format,1,1-MMDDHHMMYYYY.SS,0-MMDDHHMMYY,2-YYYYMMDDHHMM.SS
|
||||
zone_style=Timezone configuration method,4,linux-Linux,freebsd-FreeBSD,solaris-Solaris,-<Not supported on this OS>
|
||||
hwclock_flags=Command-line flags for hwclock,10,-None,sysconfig-From /etc/sysconfig/clock
|
||||
|
||||
@@ -8,7 +8,7 @@ $txt = "";
|
||||
|
||||
&error( $text{ 'acl_error' } ) if( $access{ 'sysdate' } && $access{ 'hwdate' } );
|
||||
|
||||
if (!$access{'sysdate'} && !$access{'hwdate'} && $config{'hwtime'}) {
|
||||
if (!$access{'sysdate'} && !$access{'hwdate'} && &support_hwtime()) {
|
||||
$arr = "0,1";
|
||||
}
|
||||
else {
|
||||
@@ -24,7 +24,7 @@ if (!$access{'sysdate'} && !&has_command("date")) {
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
exit;
|
||||
}
|
||||
if (!$access{'hwdate'} && $config{'hwtime'} && !&has_command("hwclock")) {
|
||||
if (!$access{'hwdate'} && $config{'hwtime'} == 1 && !&has_command("hwclock")) {
|
||||
print &text( 'error_cnf', "<tt>hwclock</tt>"),"<p>\n";
|
||||
&ui_print_footer("/", $text{'index'});
|
||||
exit;
|
||||
@@ -60,7 +60,7 @@ if( !$access{'sysdate'} )
|
||||
print &ui_form_start("apply.cgi");
|
||||
print &tabletime(&hlink($text{'sys_title'}, "system_time"), 0, %system_date);
|
||||
print &ui_submit($text{'action_apply'}, "action");
|
||||
if ($config{'hwtime'}) {
|
||||
if (&support_hwtime()) {
|
||||
print &ui_submit($text{'action_sync'}, "action");
|
||||
}
|
||||
print &ui_form_end();
|
||||
@@ -72,7 +72,7 @@ else
|
||||
}
|
||||
|
||||
# Get the hardware time
|
||||
if ($config{'hwtime'}) {
|
||||
if (&support_hwtime()) {
|
||||
local @tm = &get_hardware_time();
|
||||
@tm || &error($get_hardware_time_error || $text{'index_eformat'});
|
||||
$hw_date{ 'second' } = $tm[0];
|
||||
@@ -93,7 +93,7 @@ if ($config{'hwtime'}) {
|
||||
print &tabletime(&hlink($text{'hw_title'}, "hardware_time"),
|
||||
0, %hw_date);
|
||||
print &ui_submit($text{'action_save'}, "action");
|
||||
if ($config{'hwtime'}) {
|
||||
if (support_hwtime()) {
|
||||
print &ui_submit($text{'action_sync_s'}, "action");
|
||||
}
|
||||
print &ui_form_end();
|
||||
@@ -154,7 +154,7 @@ if ( ( !$access{ 'sysdate' } && &has_command( "date" ) || !$access{ 'hwdate' } &
|
||||
&ui_textbox("timeserver", $config{'timeserver'}, 60));
|
||||
|
||||
# Show hardware time checkbox
|
||||
if ($config{'hwtime'}) {
|
||||
if (&support_hwtime()) {
|
||||
print &ui_table_row(" ",
|
||||
&ui_checkbox("hardware", 1, $text{'index_hardware2'},
|
||||
$config{'timeserver_hardware'}));
|
||||
|
||||
@@ -208,5 +208,21 @@ sub number_to_weekday
|
||||
return ucfirst($weekday_names[$_[0]]);
|
||||
}
|
||||
|
||||
# Returns 1 if this system supports setting the hardware clock.
|
||||
sub support_hwtime
|
||||
{
|
||||
if ($config{'hwtime'} == 1) {
|
||||
return 1;
|
||||
}
|
||||
elsif ($config{'hwtime'} == 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return &has_command("hwclock") &&
|
||||
!&running_in_xen() && !&running_in_vserver() &&
|
||||
!&running_in_zone();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user