pve-installer/checktime
Thomas Lamprecht d0817324af checktime: output expected and wrong times for better UX
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-19 09:52:31 +02:00

27 lines
586 B
Perl
Executable File

#!/usr/bin/perl -w
use strict;
use warnings;
use File::stat;
use POSIX qw(strftime);
sub testtime {
my $st = stat("/usr/bin/checktime") || stat("./checktime");
my $ctime = time();
if ($ctime < $st->atime) {
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;
# correct system time to avoid errors, i.e gpg fails
system ("date -s '$tstr'");
}
}
testtime();
exit (0);