index 23b302282c6860687ddd9bc61aa09c0d01ea4dc1..576fca207dfcbbdbc274c9efef6372221451b429 100644 (file)
my ($cfg_file, %cfg_defaults) = @_;
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 {
my $time = &get_time;
$time = substr($time, 0, 8)."_".substr($time, 8, 6);
- $client_fai_log_dir = File::Spec->catfile( $client_fai_log_dir, "install-$time" );
+ $client_fai_log_dir = File::Spec->catfile( $client_fai_log_dir, "install_$time" );
mkdir($client_fai_log_dir, 0755);
my @all_logs = split(/log_file:/, $all_logs);
return;
}
-# TODO umstellen wie bei LOGIN
+
sub LOGOUT {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
my $source = @{$msg_hash->{'source'}}[0];
my $login = @{$msg_hash->{$header}}[0];
-
- my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$source'";
- my $res = $main::known_clients_db->select_dbentry($sql_statement);
- if( 1 != keys(%$res) ) {
- &main::daemon_log("DEBUG: clMessages.pm: LOGOUT: no or more hits found in known_clients_db for host '$source'");
- return;
- }
-
- my $act_login = $res->{'1'}->{'login'};
- $act_login =~ s/$login,?//gi;
-
- if( $act_login eq "" ){ $act_login = "nobody"; }
-
- $sql_statement = "UPDATE known_clients SET login='$act_login' WHERE hostname='$source'";
- $res = $main::known_clients_db->update_dbentry($sql_statement);
+
+ my $sql_statement = "DELETE FROM $main::login_users_tn WHERE (client='$source' AND user='$login')";
+ my $res = $main::login_users_db->del_dbentry($sql_statement);
+ &main::daemon_log("$session_id INFO: delete user '$login' at client '$source' from login_user_db", 5);
return;
}
}
}
- # in case of no and more than one running jobs in queue, add on single job
+ # in case of no and more than one running jobs in queue, add one single job
+
+# TODO
+ # resolve plain name for host $macaddress
&main::daemon_log("$session_id DEBUG: add job to queue for host '$macaddress'", 7);
my $func_dic = {table=>$main::job_queue_tn,
- primkey=>['id'],
+ primkey=>[],
timestamp=>&get_time,
status=>'processing',
result=>"$header $content",
targettag=>$source,
xmlmessage=>'none',
macaddress=>$macaddress,
+ plainname=>'none',
};
my ($err, $error_str) = $main::job_db->add_dbentry($func_dic);
if ($err != 0) {
}
- #my $sql_statement = "UPDATE $main::job_queue_tn ".
- # "SET status='processing', result='$header "."$content' ".
- # "WHERE status='processing' AND macaddress LIKE '$macaddress'";
- #&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
- #my $res = $main::job_db->update_dbentry($sql_statement);
- #&main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
-
-
# -----------------------> Update hier
# <CLMSG_TASKBEGIN>finish</CLMSG_TASKBEGIN>
# <header>CLMSG_TASKBEGIN</header>
# clean up header
$header =~ s/CLMSG_//g;
- my $sql_statement = "UPDATE $main::job_queue_tn ".
- "SET status='processing', result='$header "."$content' ".
- "WHERE status='processing' AND macaddress LIKE '$macaddress'";
- &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
- my $res = $main::job_db->update_dbentry($sql_statement);
- &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
+ if ($content eq "savelog 0") {
+ &main::daemon_log("$session_id DEBUG: got savelog from host '$source' - jub done", 7);
+ my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE status='processing' AND macaddress LIKE '$macaddress'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->del_dbentry($sql_statement);
+
+ } else {
+
+ my $sql_statement = "UPDATE $main::job_queue_tn ".
+ "SET status='processing', result='$header "."$content' ".
+ "WHERE status='processing' AND macaddress LIKE '$macaddress'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->update_dbentry($sql_statement);
+ &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
+ }
# -----------------------> Update hier
# <CLMSG_TASKBEGIN>finish</CLMSG_TASKBEGIN>
# <header>CLMSG_TASKBEGIN</header>