]> wagnertech.de Git - mfinanz.git/blobdiff - scripts/task_server.pl
Task-Server und -Control-Modul auf neue Konfigurationsdateinamen angepasst
[mfinanz.git] / scripts / task_server.pl
index c2061b76d3703177a73e09c0d23ae5005ddcc152..d84e8115ba927ed16ea4bbf1f016869e138fb4bb 100755 (executable)
@@ -21,32 +21,31 @@ use Daemon::Generic;
 use Data::Dumper;
 use DateTime;
 use English qw(-no_match_vars);
 use Data::Dumper;
 use DateTime;
 use English qw(-no_match_vars);
+use List::Util qw(first);
 use POSIX qw(setuid setgid);
 use SL::Auth;
 use SL::DB::BackgroundJob;
 use SL::BackgroundJob::ALL;
 use SL::Form;
 use SL::Helper::DateTime;
 use POSIX qw(setuid setgid);
 use SL::Auth;
 use SL::DB::BackgroundJob;
 use SL::BackgroundJob::ALL;
 use SL::Form;
 use SL::Helper::DateTime;
+use SL::InstanceConfiguration;
 use SL::LXDebug;
 use SL::LxOfficeConf;
 use SL::Locale;
 
 our %lx_office_conf;
 
 use SL::LXDebug;
 use SL::LxOfficeConf;
 use SL::Locale;
 
 our %lx_office_conf;
 
-# this is a cleaned up version of am.pl
-# it lacks redirection, some html setup and most of the authentication process.
-# it is assumed that anyone with physical access and execution rights on this script
-# won't be hindered by authentication anyway.
 sub lxinit {
   my $login = $lx_office_conf{task_server}->{login};
 
   package main;
 
 sub lxinit {
   my $login = $lx_office_conf{task_server}->{login};
 
   package main;
 
-  $::lxdebug = LXDebug->new;
-  $::locale  = Locale->new($::lx_office_conf{system}->{language});
-  $::cgi     = CGI->new qw();
-  $::form    = Form->new;
-  $::auth    = SL::Auth->new;
+  $::lxdebug       = LXDebug->new;
+  $::locale        = Locale->new($::lx_office_conf{system}->{language});
+  $::form          = Form->new;
+  $::auth          = SL::Auth->new;
+  $::instance_conf = SL::InstanceConfiguration->new;
+  $::request       = { cgi => CGI->new({}) };
 
   die 'cannot reach auth db'               unless $::auth->session_tables_present;
 
 
   die 'cannot reach auth db'               unless $::auth->session_tables_present;
 
@@ -54,7 +53,7 @@ sub lxinit {
 
   require "bin/mozilla/common.pl";
 
 
   require "bin/mozilla/common.pl";
 
-  die "cannot find user $login"            unless %::myconfig = $::auth->read_user($login);
+  die "cannot find user $login"            unless %::myconfig = $::auth->read_user(login => $login);
   die "cannot find locale for user $login" unless $::locale   = Locale->new('de');
 }
 
   die "cannot find locale for user $login" unless $::locale   = Locale->new('de');
 }
 
@@ -89,7 +88,7 @@ sub drop_privileges {
 sub gd_preconfig {
   my $self = shift;
 
 sub gd_preconfig {
   my $self = shift;
 
-  SL::LxOfficeConf->read;
+  SL::LxOfficeConf->read($self->{configfile});
 
   die "Missing section [task_server] in config file"                unless $lx_office_conf{task_server};
   die "Missing key 'login' in section [task_server] in config file" unless $lx_office_conf{task_server}->{login};
 
   die "Missing section [task_server] in config file"                unless $lx_office_conf{task_server};
   die "Missing key 'login' in section [task_server] in config file" unless $lx_office_conf{task_server}->{login};
@@ -127,7 +126,16 @@ sub gd_run {
     }
 
     my $seconds = 60 - (localtime)[0];
     }
 
     my $seconds = 60 - (localtime)[0];
-    sleep($seconds < 30 ? $seconds + 60 : $seconds);
+    if (!eval {
+      local $SIG{'ALRM'} = sub {
+        $::lxdebug->message(0, "Got woken up by SIGALRM") if $lx_office_conf{task_server}->{debug};
+        die "Alarm!\n"
+      };
+      sleep($seconds < 30 ? $seconds + 60 : $seconds);
+      1;
+    }) {
+      die $@ unless $@ eq "Alarm!\n";
+    }
   }
 }
 
   }
 }
 
@@ -136,9 +144,9 @@ my $pidbase = "${cwd}/users/pid";
 
 mkdir($pidbase) if !-d $pidbase;
 
 
 mkdir($pidbase) if !-d $pidbase;
 
-my $file = -f "${cwd}/config/lx_office.conf" ? "${cwd}/config/lx_office.conf" : "${cwd}/config/lx_office.conf.default";
+my $file = first { -f } ("${cwd}/config/kivitendo.conf", "${cwd}/config/lx_office.conf", "${cwd}/config/kivitendo.conf.default");
 newdaemon(configfile => $file,
 newdaemon(configfile => $file,
-          progname   => 'lx-office-task-server',
+          progname   => 'kivitendo-task-server',
           pidbase    => "${pidbase}/",
           );
 
           pidbase    => "${pidbase}/",
           );