19 Tails dev team <tails@boum.org>
20 See https://tails.boum.org/.
28 use English
'-no_match_vars';
33 setlocale
(LC_MESSAGES
, "");
35 my $htp_done_file = '/var/run/htpdate/done';
36 my $htp_success_file = '/var/run/htpdate/success';
37 my $htp_log_file = '/var/log/htpdate.log';
42 sub debug
{ say STDERR
$_[0] if $debug; }
46 exit 0 if -e
$htp_success_file;
48 my $notify = Desktop
::Notify
->new()
49 or die "Failed creating Desktop::Notify object.";
50 debug
('$notify:' . "\n" . Dumper
($notify));
52 my $summary = gettext
("Synchronizing the system's clock");
53 my $body = gettext
("Tor needs an accurate clock to work properly, especially for Hidden Services. Please wait...");
55 my $notification = $notify->create(summary
=> $summary,
58 or die "Failed to create notification object";
59 debug
('$notification:' . "\n" . Dumper
($notification));
61 # Wait until notifications can be shown
62 until (system("pidof", "nm-applet") == 0) {
66 $notification->show() or warn "Failed showing notification.";
68 # Wait until htpdate is done
69 until ( -e
$htp_done_file ) {
73 $notification->close();
75 # in case htpdate failed, notify the user with the corresponding logs
76 unless (-e
$htp_success_file) {
77 open(my $htp_log, '<', $htp_log_file)
78 or die "Can not open file '$htp_log_file': $OS_ERROR";
81 if ($_ =~ /^Running htpdate\./) {
87 my $failure_summary = gettext
("Failed to synchronize the clock!");
88 my $failure_body = $last_log;
89 my $failure_notification = $notify->create(summary
=> $failure_summary,
90 body
=> $failure_body,
92 $failure_notification->show();