diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 9357685bd0a2bebc64d6597a9d6b2894d8bc0a82..a3fd41505f83ce0b2fa6eb197ce7ae6eb01e73de 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
# REVISION: ---
#===============================================================================
# REVISION: ---
#===============================================================================
-# TODO es gibt eine globale funktion get_ldap_handle
-# - ist in einer session dieses ldap handle schon vorhanden, wird es zurückgegeben
-# - ist es nicht vorhanden, wird es erzeugt, im heap für spätere ldap anfragen gespeichert und zurückgegeben
-# - sessions die kein ldap handle brauchen, sollen auch keins haben
-# - wird eine session geschlossen, muss das ldap verbindung vorher beendet werden
-
use strict;
use warnings;
use strict;
use warnings;
my $modules_path = "/usr/lib/gosa-si/modules";
use lib "/usr/lib/gosa-si/modules";
my $modules_path = "/usr/lib/gosa-si/modules";
use lib "/usr/lib/gosa-si/modules";
+# TODO es gibt eine globale funktion get_ldap_handle
+# - ist in einer session dieses ldap handle schon vorhanden, wird es zurückgegeben
+# - ist es nicht vorhanden, wird es erzeugt, im heap für spätere ldap anfragen gespeichert und zurückgegeben
+# - sessions die kein ldap handle brauchen, sollen auch keins haben
+# - wird eine session geschlossen, muss das ldap verbindung vorher beendet werden
+our $global_kernel;
+
my (%cfg_defaults, $foreground, $verbose, $ping_timeout);
my ($bus_activ, $bus, $msg_to_bus, $bus_cipher);
my ($server);
my ($gosa_server, $job_queue_timeout, $job_queue_loop_delay);
my (%cfg_defaults, $foreground, $verbose, $ping_timeout);
my ($bus_activ, $bus, $msg_to_bus, $bus_cipher);
my ($server);
my ($gosa_server, $job_queue_timeout, $job_queue_loop_delay);
+my ($messaging_db_loop_delay);
my ($known_modules);
my ($pid_file, $procid, $pid, $log_file);
my ($arp_activ, $arp_fifo);
my ($known_modules);
my ($pid_file, $procid, $pid, $log_file);
my ($arp_activ, $arp_fifo);
our $verbose;
our $forground;
our $cfg_file;
our $verbose;
our $forground;
our $cfg_file;
-our ($ldap_handle, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
+#our ($ldap_handle, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
+our ($ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
# specifies the verbosity of the daemon_log
# specifies the verbosity of the daemon_log
$no_bus = 0;
$bus_activ = "true";
$no_bus = 0;
$bus_activ = "true";
-
$no_arp = 0;
$no_arp = 0;
+my $packages_list_under_construction = 0;
our $prg= basename($0);
our $prg= basename($0);
our $job_db;
our $job_queue_tn = 'jobs';
my $job_queue_file_name;
our $job_db;
our $job_queue_tn = 'jobs';
my $job_queue_file_name;
-my @job_queue_col_names = ("id INTEGER",
- "timestamp",
+my @job_queue_col_names = ("id INTEGER PRIMARY KEY",
+ "timestamp DEFAULT 'none'",
"status DEFAULT 'none'",
"result DEFAULT 'none'",
"progress DEFAULT 'none'",
"status DEFAULT 'none'",
"result DEFAULT 'none'",
"progress DEFAULT 'none'",
- "headertag DEFAULT 'none'",
+ "headertag DEFAULT 'none'",
"targettag DEFAULT 'none'",
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
"targettag DEFAULT 'none'",
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
+ "plainname DEFAULT 'none'",
);
# holds all other gosa-sd as well as the gosa-sd-bus
our $known_server_db;
our $known_server_tn = "known_server";
my $known_server_file_name;
);
# holds all other gosa-sd as well as the gosa-sd-bus
our $known_server_db;
our $known_server_tn = "known_server";
my $known_server_file_name;
-my @known_server_col_names = ('hostname', 'status', 'hostkey', 'timestamp');
+my @known_server_col_names = ("hostname", "status", "hostkey", "timestamp");
# holds all registrated clients
our $known_clients_db;
our $known_clients_tn = "known_clients";
my $known_clients_file_name;
# holds all registrated clients
our $known_clients_db;
our $known_clients_tn = "known_clients";
my $known_clients_file_name;
-my @known_clients_col_names = ('hostname', 'status', 'hostkey', 'timestamp', 'macaddress', 'events');
+my @known_clients_col_names = ("hostname", "status", "hostkey", "timestamp", "macaddress", "events");
# holds all logged in user at each client
our $login_users_db;
our $login_users_tn = "login_users";
my $login_users_file_name;
# holds all logged in user at each client
our $login_users_db;
our $login_users_tn = "login_users";
my $login_users_file_name;
-my @login_users_col_names = ('client', 'user', 'timestamp');
+my @login_users_col_names = ("client", "user", "timestamp");
# holds all fai server, the debian release and tag
our $fai_server_db;
our $fai_server_tn = "fai_server";
my $fai_server_file_name;
# holds all fai server, the debian release and tag
our $fai_server_db;
our $fai_server_tn = "fai_server";
my $fai_server_file_name;
-our @fai_server_col_names = ('timestamp', 'server', 'release', 'sections', 'tag');
+our @fai_server_col_names = ("timestamp", "server", "release", "sections", "tag");
+
+our $fai_release_db;
our $fai_release_tn = "fai_release";
our $fai_release_tn = "fai_release";
-our @fai_release_col_names = ('timestamp', 'release', 'class', 'type', 'state');
+my $fai_release_file_name;
+our @fai_release_col_names = ("timestamp", "release", "class", "type", "state");
# holds all packages available from different repositories
our $packages_list_db;
our $packages_list_tn = "packages_list";
my $packages_list_file_name;
# holds all packages available from different repositories
our $packages_list_db;
our $packages_list_tn = "packages_list";
my $packages_list_file_name;
-our @packages_list_col_names = ('distribution', 'package', 'version', 'section', 'description', 'template', 'timestamp');
+our @packages_list_col_names = ("distribution", "package", "version", "section", "description", "template", "timestamp");
my $outdir = "/tmp/packages_list_db";
my $arch = "i386";
# holds all messages which should be delivered to a user
our $messaging_db;
our $messaging_tn = "messaging";
my $outdir = "/tmp/packages_list_db";
my $arch = "i386";
# holds all messages which should be delivered to a user
our $messaging_db;
our $messaging_tn = "messaging";
-our @messaging_col_names = ('subject', 'from', 'to', 'flag', 'direction', 'delivery_time', 'message', 'timestamp', 'id INTEGER', );
+our @messaging_col_names = ("id INTEGER", "subject", "message_from", "message_to",
+ "flag", "direction", "delivery_time", "message", "timestamp" );
my $messaging_file_name;
# path to directory to store client install log files
my $messaging_file_name;
# path to directory to store client install log files
"known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ],
"known-servers" => [\$known_server_file_name, '/var/lib/gosa-si/servers.db'],
"login-users" => [\$login_users_file_name, '/var/lib/gosa-si/users.db'],
"known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ],
"known-servers" => [\$known_server_file_name, '/var/lib/gosa-si/servers.db'],
"login-users" => [\$login_users_file_name, '/var/lib/gosa-si/users.db'],
- "fai-server" => [\$fai_server_file_name, '/var/lib/gosa-si/fai.db'],
+ "fai-server" => [\$fai_server_file_name, '/var/lib/gosa-si/fai_server.db'],
+ "fai-release" => [\$fai_release_file_name, '/var/lib/gosa-si/fai_release.db'],
"packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'],
"messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
"source-list" => [\$sources_list, '/etc/apt/sources.list'],
"packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'],
"messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
"source-list" => [\$sources_list, '/etc/apt/sources.list'],
"port" => [\$gosa_port, "20082"],
"job-queue" => [\$job_queue_file_name, '/var/lib/gosa-si/jobs.db'],
"job-queue-loop-delay" => [\$job_queue_loop_delay, 3],
"port" => [\$gosa_port, "20082"],
"job-queue" => [\$job_queue_file_name, '/var/lib/gosa-si/jobs.db'],
"job-queue-loop-delay" => [\$job_queue_loop_delay, 3],
+ "messaging-db-loop-delay" => [\$messaging_db_loop_delay, 3],
"key" => [\$GosaPackages_key, "none"],
},
"SIPackages" => {
"key" => [\$GosaPackages_key, "none"],
},
"SIPackages" => {
#===============================================================================
sub read_configfile {
my $cfg;
#===============================================================================
sub read_configfile {
my $cfg;
- if( defined( $cfg_file) && ( length($cfg_file) > 0 )) {
+ if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) {
if( -r $cfg_file ) {
$cfg = Config::IniFiles->new( -file => $cfg_file );
} else {
if( -r $cfg_file ) {
$cfg = Config::IniFiles->new( -file => $cfg_file );
} else {
print STDERR "cannot open $log_file: $!";
return }
chomp($msg);
print STDERR "cannot open $log_file: $!";
return }
chomp($msg);
+ $msg =~s/\n//g; # no newlines are allowed in log messages, this is important for later log parsing
if($level <= $verbose){
my ($seconds, $minutes, $hours, $monthday, $month,
$year, $weekday, $yearday, $sommertime) = localtime(time);
if($level <= $verbose){
my ($seconds, $minutes, $hours, $monthday, $month,
$year, $weekday, $yearday, $sommertime) = localtime(time);
sub sig_int_handler {
my ($signal) = @_;
sub sig_int_handler {
my ($signal) = @_;
- if(defined($ldap_handle)) {
- $ldap_handle->disconnect;
- }
+# if (defined($ldap_handle)) {
+# $ldap_handle->disconnect;
+# }
+ # TODO alle verbliebenden ldap verbindungen aus allen heaps beenden
+
daemon_log("shutting down gosa-si-server", 1);
daemon_log("shutting down gosa-si-server", 1);
- system("killall gosa-si-server");
+ system("kill `ps -C gosa-si-server -o pid=`");
}
$SIG{INT} = \&sig_int_handler;
}
$SIG{INT} = \&sig_int_handler;
sub _start {
my ($kernel) = $_[KERNEL];
&trigger_db_loop($kernel);
sub _start {
my ($kernel) = $_[KERNEL];
&trigger_db_loop($kernel);
+ $global_kernel = $kernel;
$kernel->yield('create_fai_server_db', $fai_server_tn );
$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->sig(USR1 => "sig_handler");
$kernel->yield('create_fai_server_db', $fai_server_tn );
$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->sig(USR1 => "sig_handler");
+ $kernel->sig(USR2 => "create_packages_list_db");
}
sub sig_handler {
}
sub sig_handler {
daemon_log("", 5);
daemon_log("$session_id INFO: Incoming msg with session ID $session_id from '".$heap->{'remote_ip'}."'", 5);
daemon_log("", 5);
daemon_log("$session_id INFO: Incoming msg with session ID $session_id from '".$heap->{'remote_ip'}."'", 5);
- daemon_log("$session_id DEBUG: Incoming msg:\n$input", 9);
+ #daemon_log("$session_id DEBUG: Incoming msg:\n$input", 9);
####################
# check incoming msg
####################
# check incoming msg
if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
# if an incoming msg could not be decrypted (maybe a wrong key), send client a ping. If the client
# could not understand a msg from its server the client cause a re-registering process
if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
# if an incoming msg could not be decrypted (maybe a wrong key), send client a ping. If the client
# could not understand a msg from its server the client cause a re-registering process
+ daemon_log("$session_id INFO cannot understand incoming msg, send 'ping'-msg to all host with ip '".$heap->{remote_ip}."' to cause a re-registering of the client if necessary", 5);
my $sql_statement = "SELECT * FROM $main::known_clients_tn WHERE (hostname LIKE '".$heap->{'remote_ip'}."%')";
my $query_res = $known_clients_db->select_dbentry( $sql_statement );
while( my ($hit_num, $hit) = each %{ $query_res } ) {
my $sql_statement = "SELECT * FROM $main::known_clients_tn WHERE (hostname LIKE '".$heap->{'remote_ip'}."%')";
my $query_res = $known_clients_db->select_dbentry( $sql_statement );
while( my ($hit_num, $hit) = each %{ $query_res } ) {
if ( 0 < @{$answer_l} ) {
my $answer_str = join("\n", @{$answer_l});
daemon_log("$session_id DEBUG: $module: Got answer from module: \n".$answer_str,8);
if ( 0 < @{$answer_l} ) {
my $answer_str = join("\n", @{$answer_l});
daemon_log("$session_id DEBUG: $module: Got answer from module: \n".$answer_str,8);
+ } else {
+ daemon_log("$session_id DEBUG: $module: Got no answer from module!" ,8);
}
}
+
}
if( !$answer_l ) { $error++ };
}
if( !$answer_l ) { $error++ };
sub trigger_db_loop {
my ($kernel) = @_ ;
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
sub trigger_db_loop {
my ($kernel) = @_ ;
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
- $kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay);
+ $kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay);
+ $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
+ $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
}
sub watch_for_done_jobs {
}
sub watch_for_done_jobs {
my ($kernel,$heap) = @_[KERNEL, HEAP];
# check gosa job queue for jobs with executable timestamp
my ($kernel,$heap) = @_[KERNEL, HEAP];
# check gosa job queue for jobs with executable timestamp
- my $timestamp = &get_time();
- my $sql_statement = "SELECT * FROM ".$job_queue_tn.
- " WHERE status='waiting' AND timestamp<'$timestamp'";
- my $res = $job_db->select_dbentry( $sql_statement );
+ my $timestamp = &get_time();
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE status='waiting' AND (CAST (timestamp AS INTEGER)) < $timestamp ORDER BY timestamp";
+ my $res = $job_db->exec_statement( $sql_statement );
+
+ # Merge all new jobs that would do the same actions
+ my @drops;
+ my $hits;
+ foreach my $hit (reverse @{$res} ) {
+ my $macaddress= lc @{$hit}[8];
+ my $headertag= @{$hit}[5];
+ if(defined($hits->{$macaddress}->{$headertag})) {
+ push @drops, "DELETE FROM $job_queue_tn WHERE id = '$hits->{$macaddress}->{$headertag}[0]'";
+ }
+ $hits->{$macaddress}->{$headertag}= $hit;
+ }
- while( my ($id, $hit) = each %{$res} ) {
- my $jobdb_id = $hit->{id};
- my $macaddress = $hit->{'macaddress'};
- my $job_msg = $hit->{'xmlmessage'};
- daemon_log("J DEBUG: its time to execute $job_msg", 7);
- my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$macaddress'";
- my $res_hash = $known_clients_db->select_dbentry( $sql_statement );
- # expect macaddress is unique!!!!!!
- my $target = $res_hash->{1}->{hostname};
-
- # change header
- $job_msg =~ s/<header>job_/<header>gosa_/;
-
- # add sqlite_id
- $job_msg =~ s/<\/xml>$/<jobdb_id>$jobdb_id<\/jobdb_id><\/xml>/;
-
- $job_msg =~ /<header>(\S+)<\/header>/;
- my $header = $1 ;
- my $func_error = &send_msg_to_target($job_msg, $server_address, $GosaPackages_key, $header, "J");
-
- # update status in job queue to 'processing'
- $sql_statement = "UPDATE $job_queue_tn SET status='processing' WHERE id='$jobdb_id'";
- my $res = $job_db->update_dbentry($sql_statement);
- }
+ # Delete new jobs with a matching job in state 'processing'
+ foreach my $macaddress (keys %{$hits}) {
+ foreach my $jobdb_headertag (keys %{$hits->{$macaddress}}) {
+ my $jobdb_id = @{$hits->{$macaddress}->{$jobdb_headertag}}[0];
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND headertag='$jobdb_headertag' AND status='processing'";
+ my $res = $job_db->exec_statement( $sql_statement );
+ foreach my $hit (@{$res}) {
+ push @drops, "DELETE FROM $job_queue_tn WHERE id = '$jobdb_id'";
+ }
+ }
+ }
+
+ # Commit deletion
+ $job_db->exec_statementlist(\@drops);
+
+ # Look for new jobs that could be executed
+ foreach my $macaddress (keys %{$hits}) {
+
+ # Look if there is an executing job
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND status='processing'";
+ my $res = $job_db->exec_statement( $sql_statement );
+
+ # Skip new jobs for host if there is a processing job
+ if(defined($res) and defined @{$res}[0]) {
+ next;
+ }
+
+ foreach my $jobdb_headertag (keys %{$hits->{$macaddress}}) {
+ my $jobdb_id = @{$hits->{$macaddress}->{$jobdb_headertag}}[0];
+ my $job_msg = @{$hits->{$macaddress}->{$jobdb_headertag}}[7];
+
+ daemon_log("J DEBUG: its time to execute $job_msg", 7);
+ my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$macaddress'";
+ my $res_hash = $known_clients_db->select_dbentry( $sql_statement );
+
+ # expect macaddress is unique!!!!!!
+ my $target = $res_hash->{1}->{hostname};
+
+ # change header
+ $job_msg =~ s/<header>job_/<header>gosa_/;
+
+ # add sqlite_id
+ $job_msg =~ s/<\/xml>$/<jobdb_id>$jobdb_id<\/jobdb_id><\/xml>/;
+
+ $job_msg =~ /<header>(\S+)<\/header>/;
+ my $header = $1 ;
+ my $func_error = &send_msg_to_target($job_msg, $server_address, $GosaPackages_key, $header, "J");
+
+ # update status in job queue to 'processing'
+ $sql_statement = "UPDATE $job_queue_tn SET status='processing' WHERE id='$jobdb_id'";
+ my $res = $job_db->update_dbentry($sql_statement);
+
+ # We don't want parallel processing
+ last;
+ }
+ }
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
}
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
}
-sub get_ldap_handle {
- my ($session_id) = @_;
- my $heap;
- my $ldap_handle;
-
- if (not defined $session_id) {
- return $ldap_handle;
- }
+sub watch_for_new_messages {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+ my @coll_user_msg; # collection list of outgoing messages
+
+ # check messaging_db for new incoming messages with executable timestamp
+ my $timestamp = &get_time();
+ my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( (CAST(timestamp AS INTEGER))<$timestamp AND flag='n' AND direction='in' )";
+ my $res = $messaging_db->exec_statement( $sql_statement );
+ foreach my $hit (@{$res}) {
+
+ # create outgoing messages
+ my $message_to = @{$hit}[3];
+
+ # translate message_to to plain login name
+# TODO implement reciever translation
+ my @reciever_l = ($message_to);
+ my $message_id = @{$hit}[0];
+
+ #add each outgoing msg to messaging_db
+ my $reciever;
+ foreach $reciever (@reciever_l) {
+ my $sql_statement = "INSERT INTO $messaging_tn (id, subject, message_from, message_to, flag, direction, delivery_time, message, timestamp) ".
+ "VALUES ('".
+ $message_id."', '". # id
+ @{$hit}[1]."', '". # subject
+ @{$hit}[2]."', '". # message_from
+ $reciever."', '". # message_to
+ "none"."', '". # flag
+ "out"."', '". # direction
+ @{$hit}[6]."', '". # delivery_time
+ @{$hit}[7]."', '". # message
+ $timestamp."'". # timestamp
+ ")";
+ &daemon_log("M DEBUG: $sql_statement", 1);
+ my $res = $messaging_db->exec_statement($sql_statement);
+ &daemon_log("M INFO: message '".@{$hit}[0]."' is prepared for delivery to reciever '$reciever'", 5);
+ }
- my $session_reference = $kernel->ID_id_to_session($session_id);
- if( defined $session_reference ) {
- $heap = $session_reference->get_heap();
- }
+ # send outgoing messages
+ my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( flag='p' AND direction='out' )";
+ my $res = $messaging_db->exec_statement( $sql_statement );
+ foreach my $hit (@{$res}) {
+ # add subject, from, to and message to list coll_user_msg
+ my @user_msg = [@{$hit}[1], @{$hit}[2], $reciever, @{$hit}[7]];
+ push( @coll_user_msg, \@user_msg);
+ }
- if (not exists $heap->{ldap_handle}) {
- # create new ldap handle
- # add ldap handle to heap
- }
+ # send outgoing list to myself (gosa-si-server) to deliver each message to user
+ # reason for this workaround: if to much messages have to be delivered, it can come to
+ # denial of service problems of the server. so, the incoming message list can be processed
+ # by a forked child and gosa-si-server is always ready to work.
+ my $collection_out_msg = &create_xml_hash("collection_user_messages", $server_address, $server_address);
+ # add to hash 'msg1' => [subject, from, to, message]
+ # hash to string
+ # send msg to myself
+# TODO
+
+ # set incoming message to flag d=deliverd
+ $sql_statement = "UPDATE $messaging_tn SET flag='p' WHERE id='$message_id'";
+ &daemon_log("M DEBUG: $sql_statement", 7);
+ $res = $messaging_db->update_dbentry($sql_statement);
+ &daemon_log("M INFO: message '$message_id' is set to flag 'p' (processed)", 5);
- $ldap_handle = $heap->{ldap_handle};
+ }
+
+ $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
- return \$ldap_handle;
+
+ return;
}
}
-sub refresh_ldap_handle {
- my ($session_id) = @_ ;
- if (not defined $session_id) { $session_id = 0; }
-
- my $mesg;
+sub watch_for_done_messages {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
- daemon_log("$session_id DEBUG: Trying to create a connection to URI '$ldap_uri'", 7);
- # Get an ldap handle, if we don't have one
- if( ! defined $ldap_handle ){
- $ldap_handle = Net::LDAP->new( $ldap_uri );
- }
- # Still not defined?
- if( ! defined $ldap_handle ) {
- daemon_log( "$session_id ERROR: ch $$: Net::LDAP constructor failed: $!\n" );
- return 0;
- }
+ $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
+ return;
+}
- # Bind to ldap server - eventually authenticate
- if( defined $ldap_admin_dn ) {
- if( defined $ldap_admin_password ) {
- $mesg = $ldap_handle->bind( $ldap_admin_dn, password => $ldap_admin_password );
- } else {
- $mesg = $ldap_handle->bind( $ldap_admin_dn );
- }
- } else {
- $mesg = $ldap_handle->bind();
- }
- if( 0 != $mesg->code ) {
- undef( $ldap_handle ) if( 81 == $mesg->code );
- daemon_log( "$session_id ERROR: ch $$: LDAP bind: error (". $mesg->code . ') - ' . $mesg->error . "\n", 1);
- return 0;
- }
- daemon_log("$session_id DEBUG: create a new connection to URI '$ldap_uri'", 7);
- return 1;
+sub get_ldap_handle {
+ my ($session_id) = @_;
+ my $heap;
+ my $ldap_handle;
+
+ if (not defined $session_id ) { $session_id = 0 };
+ if ($session_id =~ /[^0-9]*/) { $session_id = 0 };
+
+ if ($session_id == 0) {
+ daemon_log("$session_id DEBUG: get_ldap_handle invoked without a session_id, create a new ldap_handle", 7);
+ $ldap_handle = Net::LDAP->new( $ldap_uri );
+ $ldap_handle->bind($ldap_admin_dn, password => $ldap_admin_password);
+
+ } else {
+ my $session_reference = $global_kernel->ID_id_to_session($session_id);
+ if( defined $session_reference ) {
+ $heap = $session_reference->get_heap();
+ }
+
+ if (not defined $heap) {
+ daemon_log("$session_id DEBUG: cannot get heap for session_id '$session_id'", 7);
+ return;
+ }
+
+ # TODO: This "if" is nonsense, because it doesn't prove that the
+ # used handle is still valid - or if we've to reconnect...
+ #if (not exists $heap->{ldap_handle}) {
+ $ldap_handle = Net::LDAP->new( $ldap_uri );
+ $ldap_handle->bind($ldap_admin_dn, password => $ldap_admin_password);
+ $heap->{ldap_handle} = $ldap_handle;
+ #}
+ }
+ return $ldap_handle;
}
}
wake => '',
memcheck => 'memcheck',
sysinfo => 'sysinfo',
wake => '',
memcheck => 'memcheck',
sysinfo => 'sysinfo',
- install => 'install',
+ install => 'install',
);
# Return if this is unknown
);
# Return if this is unknown
my $state= $mapActions{ $st };
my $state= $mapActions{ $st };
- &refresh_ldap_handle();
+ my $ldap_handle = &get_ldap_handle($session_id);
if( defined($ldap_handle) ) {
# Build search filter for hosts
if( defined($ldap_handle) ) {
# Build search filter for hosts
filter => "$search"
);
filter => "$search"
);
- if ($mesg->count) {
- my @entries = $mesg->entries;
- foreach my $entry (@entries) {
- # Only modify entry if it is not set to '$state'
- if ($entry->get_value("FAIstate") ne "$state"){
- daemon_log("$session_id INFO: Setting FAIstate to '$state' for ".$entry->dn, 5);
- my $result;
- my %tmp = map { $_ => 1 } $entry->get_value("objectClass");
- if (exists $tmp{'FAIobject'}){
- if ($state eq ''){
- $result= $ldap_handle->modify($entry->dn, changes => [
- delete => [ FAIstate => [] ] ]);
- } else {
- $result= $ldap_handle->modify($entry->dn, changes => [
- replace => [ FAIstate => $state ] ]);
- }
- } elsif ($state ne ''){
- $result= $ldap_handle->modify($entry->dn, changes => [
- add => [ objectClass => 'FAIobject' ],
- add => [ FAIstate => $state ] ]);
- }
-
- # Errors?
- if ($result->code){
- daemon_log("$session_id Error: Setting FAIstate to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
- }
-
- } else {
- daemon_log("$session_id DEBUG FAIstate at host '$_' already at state '$st'", 7);
- }
- }
- }
+ if ($mesg->count) {
+ my @entries = $mesg->entries;
+ foreach my $entry (@entries) {
+ # Only modify entry if it is not set to '$state'
+ if ($entry->get_value("FAIstate") ne "$state"){
+ daemon_log("$session_id INFO: Setting FAIstate to '$state' for ".$entry->dn, 5);
+ my $result;
+ my %tmp = map { $_ => 1 } $entry->get_value("objectClass");
+ if (exists $tmp{'FAIobject'}){
+ if ($state eq ''){
+ $result= $ldap_handle->modify($entry->dn, changes => [
+ delete => [ FAIstate => [] ] ]);
+ } else {
+ $result= $ldap_handle->modify($entry->dn, changes => [
+ replace => [ FAIstate => $state ] ]);
+ }
+ } elsif ($state ne ''){
+ $result= $ldap_handle->modify($entry->dn, changes => [
+ add => [ objectClass => 'FAIobject' ],
+ add => [ FAIstate => $state ] ]);
+ }
+
+ # Errors?
+ if ($result->code){
+ daemon_log("$session_id Error: Setting FAIstate to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
+ }
+ } else {
+ daemon_log("$session_id DEBUG FAIstate at host '".$entry->dn."' already at state '$st'", 7);
+ }
+ }
+ }
# if no ldap handle defined
} else {
daemon_log("$session_id ERROR: no LDAP handle defined for update FAIstate", 1);
}
# if no ldap handle defined
} else {
daemon_log("$session_id ERROR: no LDAP handle defined for update FAIstate", 1);
}
+
}
}
# Switch on or off?
my $state= $st eq 'active' ? 'active': 'locked';
# Switch on or off?
my $state= $st eq 'active' ? 'active': 'locked';
- &refresh_ldap_handle();
+ my $ldap_handle = &get_ldap_handle($session_id);
if( defined($ldap_handle) ) {
# Build search filter for hosts
if( defined($ldap_handle) ) {
# Build search filter for hosts
}
}
+sub run_create_fai_server_db {
+ my ($kernel, $session, $heap, $table_name) = @_[KERNEL, SESSION, HEAP, ARG0];
+ my $session_id = $session->ID;
+ my $task = POE::Wheel::Run->new(
+ Program => sub { &create_fai_server_db($table_name,$kernel, undef, $session_id) },
+ StdoutEvent => "session_run_result",
+ StderrEvent => "session_run_debug",
+ CloseEvent => "session_run_done",
+ );
+
+ $heap->{task}->{ $task->ID } = $task;
+ return;
+}
+
+
sub create_fai_server_db {
sub create_fai_server_db {
- my ($table_name, $kernel) = @_;
+ my ($table_name, $kernel, $dont_create_packages_list, $session_id) = @_;
my $result;
my $result;
+ if (not defined $session_id) { $session_id = 0; }
+ my $ldap_handle = &get_ldap_handle();
if(defined($ldap_handle)) {
if(defined($ldap_handle)) {
- daemon_log("INFO: create_fai_server_db: start", 5);
+ daemon_log("$session_id INFO: create_fai_server_db: start", 5);
my $mesg= $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
my $mesg= $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
}
}
}
}
}
}
- daemon_log("INFO: create_fai_server_db: finished", 5);
+ daemon_log("$session_id INFO: create_fai_server_db: finished", 5);
# TODO: Find a way to post the 'create_packages_list_db' event
# TODO: Find a way to post the 'create_packages_list_db' event
- &create_packages_list_db();
+ if(not defined($dont_create_packages_list)) {
+ &create_packages_list_db(undef, undef, $session_id);
+ }
}
}
-
+
+ $ldap_handle->disconnect;
return $result;
}
return $result;
}
-sub run_create_fai_server_db {
- my ($kernel, $session, $heap, $table_name) = @_[KERNEL, SESSION, HEAP, ARG0];
+
+sub run_create_fai_release_db {
+ my ($session, $heap, $table_name) = @_[SESSION, HEAP, ARG0];
+ my $session_id = $session->ID;
my $task = POE::Wheel::Run->new(
my $task = POE::Wheel::Run->new(
- Program => sub { &create_fai_server_db($table_name,$kernel) },
+ Program => sub { &create_fai_release_db($table_name, $session_id) },
StdoutEvent => "session_run_result",
StderrEvent => "session_run_debug",
CloseEvent => "session_run_done",
StdoutEvent => "session_run_result",
StderrEvent => "session_run_debug",
CloseEvent => "session_run_done",
sub create_fai_release_db {
sub create_fai_release_db {
- my ($table_name) = @_;
+ my ($table_name, $session_id) = @_;
my $result;
my $result;
+ # used for logging
+ if (not defined $session_id) { $session_id = 0; }
+
+ my $ldap_handle = &get_ldap_handle();
if(defined($ldap_handle)) {
if(defined($ldap_handle)) {
- daemon_log("INFO: create_fai_release_db: start",5);
+ daemon_log("$session_id INFO: create_fai_release_db: start",5);
my $mesg= $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
my $mesg= $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
my @sql_list;
my $timestamp= &get_time();
foreach my $ou (@{$mesg->{entries}}) {
my @sql_list;
my $timestamp= &get_time();
foreach my $ou (@{$mesg->{entries}}) {
- my $tmp_classes= resolve_fai_classes($ou->dn);
+ my $tmp_classes= resolve_fai_classes($ou->dn, $ldap_handle, $session_id);
if(defined($tmp_classes) && ref($tmp_classes) eq 'HASH') {
my @tmp_array=get_fai_release_entries($tmp_classes);
if(@tmp_array) {
if(defined($tmp_classes) && ref($tmp_classes) eq 'HASH') {
my @tmp_array=get_fai_release_entries($tmp_classes);
if(@tmp_array) {
}
}
}
}
}
}
- daemon_log("DEBUG: Inserting ".scalar @sql_list." entries to DB",6);
+
+ daemon_log("$session_id DEBUG: Inserting ".scalar @sql_list." entries to DB",8);
if(@sql_list) {
if(@sql_list) {
- unshift @sql_list, "DELETE FROM $table_name";
- $fai_server_db->exec_statementlist(\@sql_list);
+ unshift @sql_list, "DELETE FROM $table_name"; # at first, clear db
+ $fai_release_db->exec_statementlist(\@sql_list);
}
}
- daemon_log("DEBUG: Done with inserting",6);
+ daemon_log("$session_id DEBUG: Done with inserting",7);
}
}
- daemon_log("INFO: create_fai_release_db: finished",5);
+ daemon_log("$session_id INFO: create_fai_release_db: finished",5);
}
}
-
+ $ldap_handle->disconnect;
return $result;
}
return $result;
}
-sub run_create_fai_release_db {
- my ($session, $heap, $table_name) = @_[SESSION, HEAP, ARG0];
- my $task = POE::Wheel::Run->new(
- Program => sub { &create_fai_release_db($table_name) },
- StdoutEvent => "session_run_result",
- StderrEvent => "session_run_debug",
- CloseEvent => "session_run_done",
- );
-
- $heap->{task}->{ $task->ID } = $task;
- return;
-}
sub get_fai_types {
my $tmp_classes = shift || return undef;
sub get_fai_types {
my $tmp_classes = shift || return undef;
}
sub resolve_fai_classes {
}
sub resolve_fai_classes {
+ my ($fai_base, $ldap_handle, $session_id) = @_;
+ if (not defined $session_id) { $session_id = 0; }
my $result;
my $result;
- my $fai_base= shift;
my @possible_fai_classes= ("FAIscript", "FAIhook", "FAIpartitionTable", "FAItemplate", "FAIvariable", "FAIprofile", "FAIpackageList");
my $fai_filter= "(|(&(objectClass=FAIclass)(|(objectClass=".join(")(objectClass=", @possible_fai_classes).")))(objectClass=FAIbranch))";
my $fai_classes;
my @possible_fai_classes= ("FAIscript", "FAIhook", "FAIpartitionTable", "FAItemplate", "FAIvariable", "FAIprofile", "FAIpackageList");
my $fai_filter= "(|(&(objectClass=FAIclass)(|(objectClass=".join(")(objectClass=", @possible_fai_classes).")))(objectClass=FAIbranch))";
my $fai_classes;
- daemon_log("DEBUG: Searching for FAI entries in base $fai_base",6);
+ daemon_log("$session_id DEBUG: Searching for FAI entries in base $fai_base",7);
my $mesg= $ldap_handle->search(
base => $fai_base,
scope => 'sub',
attrs => ['cn','objectClass','FAIstate'],
filter => $fai_filter,
);
my $mesg= $ldap_handle->search(
base => $fai_base,
scope => 'sub',
attrs => ['cn','objectClass','FAIstate'],
filter => $fai_filter,
);
- daemon_log("DEBUG: Found ".$mesg->count()." FAI entries",6);
+ daemon_log("$session_id DEBUG: Found ".$mesg->count()." FAI entries",7);
if($mesg->{'resultCode'} == 0 &&
$mesg->count != 0) {
if($mesg->{'resultCode'} == 0 &&
$mesg->count != 0) {
}
sub create_sources_list {
}
sub create_sources_list {
+ my ($session_id) = @_;
+ my $ldap_handle = &get_ldap_handle;
my $result="/tmp/gosa_si_tmp_sources_list";
# Remove old file
if(stat($result)) {
unlink($result);
my $result="/tmp/gosa_si_tmp_sources_list";
# Remove old file
if(stat($result)) {
unlink($result);
+ &main::daemon_log("$session_id DEBUG: remove an old version of '$result'", 7);
}
my $fh;
}
my $fh;
- open($fh, ">$result") or return undef;
+ open($fh, ">$result");
+ if (not defined $fh) {
+ &main::daemon_log("$session_id DEBUG: cannot open '$result' for writing", 7);
+ return undef;
+ }
if(defined($ldap_server_dn) and length($ldap_server_dn) > 0) {
my $mesg=$ldap_handle->search(
base => $ldap_server_dn,
if(defined($ldap_server_dn) and length($ldap_server_dn) > 0) {
my $mesg=$ldap_handle->search(
base => $ldap_server_dn,
);
if($mesg->count) {
foreach my $entry(@{$mesg->{'entries'}}) {
);
if($mesg->count) {
foreach my $entry(@{$mesg->{'entries'}}) {
- my ($server, $tag, $release, $sections)= split /\|/, $entry->get_value('FAIrepository');
- my $line = "deb $server $release";
- $sections =~ s/,/ /g;
- $line.= " $sections";
- print $fh $line."\n";
+ foreach my $value(@{$entry->get_value('FAIrepository', asref => 1)}) {
+ my ($server, $tag, $release, $sections)= split /\|/, $value;
+ my $line = "deb $server $release";
+ $sections =~ s/,/ /g;
+ $line.= " $sections";
+ print $fh $line."\n";
+ }
}
}
}
}
- }
+ } else {
+ &main::daemon_log("$session_id ERROR: something wrong with ldap_server_dn '$ldap_server_dn', abort create_soureces_list", 1);
+ }
close($fh);
return $result;
}
close($fh);
return $result;
}
+
+sub run_create_packages_list_db {
+ my ($session, $heap) = @_[SESSION, HEAP];
+ my $session_id = $session->ID;
+
+ my $task = POE::Wheel::Run->new(
+ Program => sub {&create_packages_list_db(undef, undef, $session_id)},
+ StdoutEvent => "session_run_result",
+ StderrEvent => "session_run_debug",
+ CloseEvent => "session_run_done",
+ );
+ $heap->{task}->{ $task->ID } = $task;
+}
+
+
sub create_packages_list_db {
sub create_packages_list_db {
- my ($sources_file) = @_ || &create_sources_list;
- my $line;
- daemon_log("INFO: create_packages_list_db: start", 5);
+ my ($ldap_handle, $sources_file, $session_id) = @_;
+
+ if (not defined $session_id) { $session_id = 0; }
+ if (not defined $ldap_handle) {
+ $ldap_handle= &get_ldap_handle();
+
+ if (not defined $ldap_handle) {
+ daemon_log("$session_id ERROR: no ldap_handle available to create_packages_list_db", 1);
+ return;
+ }
+ }
+ if (not defined $sources_file) {
+ &main::daemon_log("$session_id INFO: no sources_file given for creating packages list so trigger creation of it", 5);
+ $sources_file = &create_sources_list($session_id);
+ }
+
+ if (not defined $sources_file) {
+ &main::daemon_log("$session_id ERROR: no sources_file given under '$sources_file', skip create_packages_list_db", 1);
+
+ }
+
+ # it should not be possible to trigger a recreation of packages_list_db
+ # while packages_list_db is under construction, so set flag packages_list_under_construction
+ # which is tested befor recreation can be started
+ if ($packages_list_under_construction) {
+ daemon_log("$session_id WARNING: packages_list_db is right now under construction, please wait untill this process is finished", 3);
+ return;
+ } else {
+ daemon_log("$session_id INFO: create_packages_list_db: start", 5);
+ # set packages_list_under_construction to true
+ $packages_list_under_construction = 1;
+ }
+ my $line;
open(CONFIG, "<$sources_file") or do {
open(CONFIG, "<$sources_file") or do {
- daemon_log( "ERROR: create_packages_list_db: Failed to open '$sources_file'", 1);
+ daemon_log( "$session_id ERROR: create_packages_list_db: Failed to open '$sources_file'", 1);
return;
};
return;
};
my( $baseurl, $dist, $sections ) = ($line =~ /^deb\s([^\s]+)\s+([^\s]+)\s+(.*)$/);
my $section;
foreach $section (split(' ', $sections)){
my( $baseurl, $dist, $sections ) = ($line =~ /^deb\s([^\s]+)\s+([^\s]+)\s+(.*)$/);
my $section;
foreach $section (split(' ', $sections)){
- &parse_package_info( $baseurl, $dist, $section );
+ &parse_package_info( $baseurl, $dist, $section, $session_id );
}
}
}
close (CONFIG);
}
}
}
close (CONFIG);
- daemon_log("INFO: create_packages_list_db: finished", 5);
+ daemon_log("$session_id INFO: create_packages_list_db: finished", 5);
+ # set packages_list_under_construction to false
+ $packages_list_under_construction = 0;
+
return;
}
return;
}
-sub run_create_packages_list_db {
- my ($session, $heap) = @_[SESSION, HEAP];
- my $task = POE::Wheel::Run->new(
- Program => sub {&create_packages_list_db},
- StdoutEvent => "session_run_result",
- StderrEvent => "session_run_debug",
- CloseEvent => "session_run_done",
- );
- $heap->{task}->{ $task->ID } = $task;
-}
sub parse_package_info {
sub parse_package_info {
- my ($baseurl, $dist, $section)= @_;
+ my ($baseurl, $dist, $section, $session_id)= @_;
my ($package);
my ($package);
-
+ if (not defined $session_id) { $session_id = 0; }
my ($path) = ($baseurl =~ m%://[^/]*(.*)$%);
$repo_dirs{ "${repo_path}/pool" } = 1;
foreach $package ("Packages.gz"){
my ($path) = ($baseurl =~ m%://[^/]*(.*)$%);
$repo_dirs{ "${repo_path}/pool" } = 1;
foreach $package ("Packages.gz"){
- daemon_log("DEBUG: create_packages_list: fetch $baseurl, $dist, $section", 7);
- get_package( "$baseurl/dists/$dist/$section/binary-$arch/$package", "$outdir/$dist/$section" );
- parse_package( "$outdir/$dist/$section", $dist, $path );
+ daemon_log("$session_id DEBUG: create_packages_list: fetch $baseurl, $dist, $section", 7);
+ get_package( "$baseurl/dists/$dist/$section/binary-$arch/$package", "$outdir/$dist/$section", $session_id );
+ parse_package( "$outdir/$dist/$section", $dist, $path, $session_id );
}
}
- find(\&cleanup_and_extract, keys( %repo_dirs ) );
+ find(\&cleanup_and_extract($session_id), keys( %repo_dirs ));
}
}
+
sub get_package {
sub get_package {
- my ($url, $dest)= @_;
+ my ($url, $dest, $session_id)= @_;
+ if (not defined $session_id) { $session_id = 0; }
my $tpath = dirname($dest);
-d "$tpath" || mkpath "$tpath";
my $tpath = dirname($dest);
-d "$tpath" || mkpath "$tpath";
# This is ugly, but I've no time to take a look at "how it works in perl"
if(0 == system("wget '$url' -O '$dest' 2>/dev/null") ) {
system("gunzip -cd '$dest' > '$dest.in'");
# This is ugly, but I've no time to take a look at "how it works in perl"
if(0 == system("wget '$url' -O '$dest' 2>/dev/null") ) {
system("gunzip -cd '$dest' > '$dest.in'");
+ daemon_log("$session_id DEBUG: run command: gunzip -cd '$dest' > '$dest.in'", 5);
unlink($dest);
unlink($dest);
+ daemon_log("$session_id DEBUG: delete file '$dest'", 5);
} else {
} else {
- daemon_log("ERROR: create_packages_list_db: get_packages: fetching '$url' failed!", 1);
+ daemon_log("$session_id ERROR: create_packages_list_db: get_packages: fetching '$url' failed!", 1);
}
return 0;
}
sub parse_package {
}
return 0;
}
sub parse_package {
- my ($path, $dist, $srv_path)= @_;
+ my ($path, $dist, $srv_path, $session_id)= @_;
+ if (not defined $session_id) { $session_id = 0;}
my ($package, $version, $section, $description);
my @sql_list;
my $PACKAGES;
if(not stat("$path.in")) {
my ($package, $version, $section, $description);
my @sql_list;
my $PACKAGES;
if(not stat("$path.in")) {
- daemon_log("ERROR: create_packages_list: parse_package: file '$path.in' is not readable",1);
+ daemon_log("$session_id ERROR: create_packages_list: parse_package: file '$path.in' is not readable",1);
return;
}
open($PACKAGES, "<$path.in");
if(not defined($PACKAGES)) {
return;
}
open($PACKAGES, "<$path.in");
if(not defined($PACKAGES)) {
- daemon_log("ERROR: create_packages_list_db: parse_package: can not open '$path.in'",1);
+ daemon_log("$session_id ERROR: create_packages_list_db: parse_package: cannot open '$path.in'",1);
return;
}
return;
}
}
close( $PACKAGES );
}
close( $PACKAGES );
- unlink( "$path.in" );
-
+# unlink( "$path.in" );
+ &main::daemon_log("$session_id DEBUG: unlink '$path.in'", 1);
+ my $len_sql_list = @sql_list;
+ &main::daemon_log("$session_id DEBUG: add $len_sql_list insert-statements to packages_list_db", 5);
$packages_list_db->exec_statementlist(\@sql_list);
}
$packages_list_db->exec_statementlist(\@sql_list);
}
}
sub cleanup_and_extract {
}
sub cleanup_and_extract {
- my $fileinfo = $repo_files{ $File::Find::name };
+ my ($session_id) = @_;
+ if (not defined $session_id) { $session_id = 0; }
+ my $fileinfo = $repo_files{ $File::Find::name };
- if( defined $fileinfo ) {
+ if( defined $fileinfo ) {
- my $dir = "$outdir/$fileinfo->{ 'dist' }/debconf.d";
- my $sql;
- my $package = $fileinfo->{ 'package' };
- my $newver = $fileinfo->{ 'version' };
+ my $dir = "$outdir/$fileinfo->{ 'dist' }/debconf.d";
+ my $sql;
+ my $package = $fileinfo->{ 'package' };
+ my $newver = $fileinfo->{ 'version' };
- mkpath($dir);
- system( "dpkg -e '$File::Find::name' '$dir/DEBIAN'" );
+ mkpath($dir);
+ system( "dpkg -e '$File::Find::name' '$dir/DEBIAN'" );
- if( -f "$dir/DEBIAN/templates" ) {
+ if( -f "$dir/DEBIAN/templates" ) {
- daemon_log("DEBUG: Found debconf templates in '$package' - $newver", 5);
+ daemon_log("$session_id DEBUG: Found debconf templates in '$package' - $newver", 5);
- my $tmpl= "";
- {
- local $/=undef;
- open FILE, "$dir/DEBIAN/templates";
- $tmpl = &encode_base64(<FILE>);
- close FILE;
- }
- rmtree("$dir/DEBIAN/templates");
+ my $tmpl= "";
+ {
+ local $/=undef;
+ open FILE, "$dir/DEBIAN/templates";
+ $tmpl = &encode_base64(<FILE>);
+ close FILE;
+ }
+ rmtree("$dir/DEBIAN/templates");
- $sql= "update $main::packages_list_tn set template = '$tmpl' where package = '$package' and version = '$newver';";
+ $sql= "update $main::packages_list_tn set template = '$tmpl' where package = '$package' and version = '$newver';";
- } else {
- $sql= "update $main::packages_list_tn set template = '' where package = '$package' and version = '$newver';";
- }
+ } else {
+ $sql= "update $main::packages_list_tn set template = '' where package = '$package' and version = '$newver';";
+ }
- my $res= $main::packages_list_db->update_dbentry($sql);
- }
+ my $res= $main::packages_list_db->update_dbentry($sql);
+ }
}
}
$bus_activ = "false"
}
$bus_activ = "false"
}
-
-
-# delete old DBsqlite lock files
-#unlink('/tmp/gosa_si_lock*');
-
# connect to gosa-si job queue
$job_db = GOSA::DBsqlite->new($job_queue_file_name);
$job_db->create_table($job_queue_tn, \@job_queue_col_names);
# connect to gosa-si job queue
$job_db = GOSA::DBsqlite->new($job_queue_file_name);
$job_db->create_table($job_queue_tn, \@job_queue_col_names);
$login_users_db->create_table($login_users_tn, \@login_users_col_names);
# connect to fai_server_db and fai_release_db
$login_users_db->create_table($login_users_tn, \@login_users_col_names);
# connect to fai_server_db and fai_release_db
+unlink($fai_server_file_name);
$fai_server_db = GOSA::DBsqlite->new($fai_server_file_name);
$fai_server_db->create_table($fai_server_tn, \@fai_server_col_names);
$fai_server_db = GOSA::DBsqlite->new($fai_server_file_name);
$fai_server_db->create_table($fai_server_tn, \@fai_server_col_names);
-$fai_server_db->create_table($fai_release_tn, \@fai_release_col_names);
+
+unlink($fai_release_file_name);
+$fai_release_db = GOSA::DBsqlite->new($fai_release_file_name);
+$fai_release_db->create_table($fai_release_tn, \@fai_release_col_names);
# connect to packages_list_db
unlink($packages_list_file_name);
# connect to packages_list_db
unlink($packages_list_file_name);
inline_states => {
_start => \&_start,
sig_handler => \&sig_handler,
inline_states => {
_start => \&_start,
sig_handler => \&sig_handler,
+ watch_for_new_messages => \&watch_for_new_messages,
+ watch_for_done_messages => \&watch_for_done_messages,
watch_for_new_jobs => \&watch_for_new_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
create_packages_list_db => \&run_create_packages_list_db,
watch_for_new_jobs => \&watch_for_new_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
create_packages_list_db => \&run_create_packages_list_db,