In the past Google Calendar exports were done by first removing all events of a day and then create new ones. This takes a lot of time for export and runs into Google Calendar usage limits after some time. By now content will be compared before removing/creating a single event one. To be able to do so, all other sync sources and targets have been removed, so its only possible to export from database to Google Calendar by this change. To trigger an export you need to create a trigger file. run_jobs.pl runs periodically e.g. started by cron and checks if a trigger file exists and start sync_cms.pl to export the selected events to the Google Calendar. Trigger files and jobs are configured at jobs.config. Each job has a source and target file containing the access data for calcms and the calendar. Configuration files have been cleaned up. Old Accounts and passwords have been removed. They hopefully should have been not active for a long time ;-)
76 lines
1.5 KiB
Perl
76 lines
1.5 KiB
Perl
package Common;
|
|
use warnings;
|
|
use strict;
|
|
|
|
use Fcntl ':flock';
|
|
|
|
use base 'Exporter';
|
|
our @EXPORT_OK = ( 'info', 'error' );
|
|
|
|
sub checkSingleInstance() {
|
|
open my $self, '<', $0 or die "Couldn't open self: $!";
|
|
flock $self, LOCK_EX | LOCK_NB or die "This script $0 is already running";
|
|
}
|
|
|
|
sub loadFile($) {
|
|
my $filename = shift;
|
|
|
|
my $content = '';
|
|
open my $file, '<', $filename || die("cannot load $filename");
|
|
while (<$file>) {
|
|
$content .= $_;
|
|
}
|
|
close $file;
|
|
return $content;
|
|
}
|
|
|
|
sub saveFile($$) {
|
|
my $filename = shift;
|
|
my $content = shift;
|
|
open my $file, ">:utf8", $filename || die("cannot write $filename");
|
|
print $file $content;
|
|
close $file;
|
|
|
|
}
|
|
|
|
sub getModifiedAt {
|
|
my $file = shift;
|
|
my @stats = stat $file;
|
|
return 0 if scalar @stats == 0;
|
|
my $modifiedAt = $stats[9];
|
|
return $modifiedAt;
|
|
}
|
|
|
|
sub execute($) {
|
|
my $command = shift;
|
|
print "EXEC:\t$command\n";
|
|
my $result = `$command`;
|
|
my $exitCode = ( $? >> 8 );
|
|
print "ERROR! exitCode=$?\n" if $exitCode > 0;
|
|
return ( $exitCode, $result );
|
|
}
|
|
|
|
my $debug = 0;
|
|
|
|
sub debug($$) {
|
|
my $level = shift;
|
|
my $message = shift;
|
|
print $message. "\n" if $debug > $level;
|
|
}
|
|
|
|
sub error ($) {
|
|
print "\nERROR: $_[0]\nsee $0 --help for help";
|
|
exit 1;
|
|
}
|
|
|
|
sub info ($) {
|
|
my $message = shift;
|
|
if ( $message =~ /^\n/ ) {
|
|
$message =~ s/^\n//g;
|
|
print "\n";
|
|
}
|
|
print "INFO:\t$message\n";
|
|
}
|
|
|
|
return 1;
|