mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-08-06 18:24:46 +00:00
checktime: output expected and wrong times for better UX
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
e74223a729
commit
d0817324af
12
checktime
12
checktime
@ -1,20 +1,24 @@
|
|||||||
#!/usr/bin/perl -w
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
use File::stat;
|
use File::stat;
|
||||||
|
use POSIX qw(strftime);
|
||||||
|
|
||||||
sub testtime {
|
sub testtime {
|
||||||
|
my $st = stat("/usr/bin/checktime") || stat("./checktime");
|
||||||
my $st = stat ("/usr/bin/checktime") || stat ("./checktime");
|
|
||||||
|
|
||||||
my $ctime = time();
|
my $ctime = time();
|
||||||
|
|
||||||
if ($ctime < $st->atime) {
|
if ($ctime < $st->atime) {
|
||||||
warn "detected wrong system time\n";
|
my $system_time_str = strftime "%F %T", localtime $ctime;
|
||||||
|
my $pkg_time_str = strftime "%F %T", localtime $st->atime;
|
||||||
|
warn "detected wrong system time $system_time_str, older than installer ($pkg_time_str)\n";
|
||||||
my $tstr = localtime $st->atime;
|
my $tstr = localtime $st->atime;
|
||||||
# correct system time to avoid errors, i.e gpg fails
|
# correct system time to avoid errors, i.e gpg fails
|
||||||
system ("date -s '$tstr'");
|
system ("date -s '$tstr'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testtime();
|
testtime();
|
||||||
|
Loading…
Reference in New Issue
Block a user