summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d844170)
raw | patch | inline | side by side (parent: d844170)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 14 Jan 2008 13:49:48 +0000 (13:49 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 14 Jan 2008 13:49:48 +0000 (13:49 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8325 594d385d-05f5-0310-b6e9-bd551577e9d8
index 26fb1cbcfa458fc60ef233fee6647412ab89a96f..18e68aefcfa4280e6f61dfcba1456a82d92ff4f5 100755 (executable)
start_bus() {
- start-stop-daemon --start --quiet --pidfile /var/run/gosa-si-bus.pid --name gosa-si-bus --startas /usr/sbin/gosa-si-bus
+ start-stop-daemon --start --quiet --pidfile /var/run/gosa-si-bus.pid --name gosa-si-bus --startas /usr/sbin/gosa-si-bus --
}
start_server() {
- start-stop-daemon --start --quiet --pidfile /var/run/gosa-si-server.pid --name gosa-si-server --startas /usr/sbin/gosa-si-server -- $1
+ start-stop-daemon --start --quiet --pidfile /var/run/gosa-si-server.pid --name gosa-si-server --startas /usr/sbin/gosa-si-server -- -vvvvv $1
}
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index e0143000cabc41431649b033550b4430a4dc8e14..2ee9b4d0d87eb3fd83f3c992ac571238feae9a6e 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
my ($rout, $wout, $reg_server);
foreach my $server (@servers) {
+
+# TODO : server abhängige macadress und ipadresse eintragen
+
# create msg hash
my $register_hash = &create_xml_hash("here_i_am", $client_address, $server);
&add_content2xml_hash($register_hash, "new_passwd", $new_server_passwd);
&read_configfile;
&check_pid;
+
+open STDIN, ‘/dev/null’ or die “Can’t read /dev/null: $!”;
+open STDOUT, ‘>>/dev/null’ or die “Can’t write to /dev/null: $!”;
+open STDERR, ‘>>/dev/null’ or die “Can’t write to /dev/null: $!”;
+
+
# restart daemon log file
if(-e $log_file ) { unlink $log_file }
daemon_log(" ", 1);
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index dfec2b882ef7a11752e3aeef476375b2d6858cac..b9a1cc6d662507f53cb537a5ec6ca165f66403f6 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
return }
chomp($msg);
if($level <= $verbose){
- print LOG_HANDLE "$level $msg\n";
+ my ($seconds, $minutes, $hours, $monthday, $month,
+ $year, $weekday, $yearday, $sommertime) = localtime(time);
+ $hours = $hours < 10 ? $hours = "0".$hours : $hours;
+ $minutes = $minutes < 10 ? $minutes = "0".$minutes : $minutes;
+ $seconds = $seconds < 10 ? $seconds = "0".$seconds : $seconds;
+ my @monthnames = ("Jan", "Feb", "Mar", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
+ $month = $monthnames[$month];
+ $monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday;
+ $year+=1900;
+ my $name = $0;
+ $name =~ s/\.\///;
+
+ print LOG_HANDLE "$month $monthday $hours:$minutes:$seconds $name $msg\n";
if($foreground) { print $msg."\n" }
}
}
}
eval { require $file; };
if ($@) {
- daemon_log("ERROR: gosa-sd could not load module $file", 1);
+ daemon_log("ERROR: gosa-si-server could not load module $file", 1);
daemon_log("$@", 5);
- next;
- }
- my $mod_name = $1;
- #my $module_tag_hash = eval( $mod_name.'::get_module_tags()' );
-
- my $info = eval($mod_name.'::get_module_info()');
- my ($input_address, $input_key, $input, $input_active, $input_type) = @{$info};
- $known_modules->{$mod_name} = $info;
+ } else {
+ my $mod_name = $1;
+ my $info = eval($mod_name.'::get_module_info()');
+ my ($input_address, $input_key, $input, $input_active, $input_type) = @{$info};
+ $known_modules->{$mod_name} = $info;
- daemon_log("module $mod_name loaded", 1);
+ daemon_log("module $mod_name loaded", 1);
+ }
}
# for debugging
#===============================================================================
sub sig_int_handler {
my ($signal) = @_;
- if($server){
- close($server);
- daemon_log("daemon server closed", 1);
- }
- if( -p $arp_fifo_path ) {
- close $arp_fifo ;
- unlink($arp_fifo_path) ;
- daemon_log("ARP_FIFO closed", 1) ;
- }
-
- if($gosa_server){
- close($gosa_server);
- daemon_log("gosa server closed", 1);
- }
- print STDERR "$signal\n";
-
+ daemon_log("shutting down gosa-si-server", 1);
exit(1);
}
$SIG{INT} = \&sig_int_handler;
if (defined $answer) {
print $PARENT_wr $answer."\n";
- daemon_log("with answer: $answer", 5);
- daemon_log(" ", 5);
+ daemon_log("with answer:", 5);
+ daemon_log("$answer", 5);
} else {
print $PARENT_wr "done"."\n";
daemon_log(" ", 5);
$SIG{CHLD} = 'IGNORE';
-# restart daemon log file
-daemon_log(" ", 1);
-daemon_log("$0 started!", 1);
+# forward error messages to logfile
+if( ! $foreground ) {
+ open(STDERR, '>>', $log_file);
+ open(STDOUT, '>>', $log_file);
+}
-# Just fork, if we"re not in foreground mode
+# Just fork, if we are not in foreground mode
if( ! $foreground ) {
chdir '/' or die "Can't chdir to /: $!";
$pid = fork;
};
}
+daemon_log(" ", 1);
+daemon_log("$0 started!", 1);
+
+
# connect to gosa-si job queue
-my @job_col_names = ("timestamp", "status", "result", "headertag", "targettag", "xmlmessage", "macaddress");
+my @job_col_names = ("id", "timestamp", "status", "result", "headertag", "targettag", "xmlmessage", "macaddress");
$job_db = GOSA::DBsqlite->new($job_queue_file_name);
$job_db->create_table('jobs', \@job_col_names);
index 5bee915c414a74b42152acc92d4beaf4bd8dd92b..21d7200711fdf77b3a7046b171f4f59c602c6c92 100644 (file)
}
# specify primary key in table
+ if (not exists $arg->{primkey}) {
+ return 2;
+ }
my $primkey = $arg->{primkey};
+ # if primkey is id, fetch max id from table and give new job id= max(id)+1
+ if ($primkey eq 'id') {
+ my $id;
+ my $sql_statement = "SELECT MAX(id) FROM $table";
+ my $max_id = @{ @{ $obj->{dbh}->selectall_arrayref($sql_statement) }[0] }[0];
+ if( defined $max_id) {
+ $id = $max_id + 1;
+ } else {
+ $id = 1;
+ }
+ $arg->{id} = $id;
+ }
+
# check wether value to primary key is specified
- if ( ( defined $primkey ) && ( not $arg->{ $primkey } ) ) {
- return 2;
+ if ( not exists $arg->{ $primkey } ) {
+ return 3;
}
# if timestamp is not provided, add timestamp
}
# check wether primkey is unique in table, otherwise return errorflag 3
- my $res = @{ $obj->{dbh}->selectall_arrayref( "SELECT * FROM $table WHERE $primkey='$arg->{$primkey}'") };
+ my $sql_statement = "SELECT * FROM $table WHERE $primkey='$arg->{$primkey}'";
+ my $res = @{ $obj->{dbh}->selectall_arrayref($sql_statement) };
if ($res == 0) {
# fetch column names of table
my $col_names = $obj->get_table_columns($table);
sub show_table {
my $obj = shift;
my $table_name = shift;
- my @res = @{$obj->{dbh}->selectall_arrayref( "SELECT ROWID, * FROM $table_name")};
+ my @res = @{$obj->{dbh}->selectall_arrayref( "SELECT * FROM $table_name")};
my @answer;
foreach my $hit (@res) {
push(@answer, "hit: ".join(', ', @{$hit}));
index 70e998bfb4832919825e70317d350f8d592038ed..18423d87b2501b3859a6dae871a09beea3321490 100644 (file)
);
if (not defined $gosa_server) {
&main::daemon_log("cannot start tcp server at $gosa_port for communication to gosa: $@", 1);
+ die;
} else {
&main::daemon_log("start server for communication to gosa: $gosa_address", 1);
my $header = @{$msg_hash->{header}}[0];
- &main::daemon_log("recieve '$header' at GosaPackages from $host", 1);
- &main::daemon_log("$msg", 7);
+ &main::daemon_log("GosaPackages: recieve '$header' from $host", 1);
my $out_msg;
if ($header =~ /^job_/) {
my $header = @{$msg_hash->{header}}[0];
$header =~ s/job_//;
- &main::daemon_log("GosaPackages: got a job msg $header", 5);
+ &main::daemon_log("GosaPackages: got a job msg for queue: $header", 5);
# check wether mac address is already known in known_daemons or known_clients
- my $target = 'not known until now';
+ my $target = 'none';
# add job to job queue
my $func_dic = {table=>$main::job_queue_table_name,
+ primkey=>'id',
timestamp=>@{$msg_hash->{timestamp}}[0],
status=>'waiting',
result=>'none',
index 45d4cac4aa211aac31d1327e0238080a4638ea03..7ef62d41b3b75dddf5f1f46c79350960a96c2b3a 100644 (file)
);
if(not defined $server){
&main::daemon_log("cannot be a tcp server at $server_port : $@");
+ die;
} else {
&main::daemon_log("start server: $server_address", 1);
}
index e825d57c9bb3b98d507b70070c6e075c92835dbe..3ccd88d5f3fbe9d3a25d813cc1b6c85df1fb4e5e 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
require_once("../../gosa-core/include/class_socketClient.inc");
error_reporting(E_ALL);
-$sock = new Socket_Client("10.89.1.155","20082",TRUE,1);
+$sock = new Socket_Client("10.89.1.156","20082",TRUE,1);
#$sock = new Socket_Client("169.254.2.248","9999",TRUE,1);
$sock->setEncryptionKey("secret-gosa-password");