From 78afc9913ee9b1841ab1a23078c86d69987d82d3 Mon Sep 17 00:00:00 2001 From: cajus Date: Tue, 12 Feb 2008 15:50:07 +0000 Subject: [PATCH] Replaced $0 by $prg git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8876 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-bus | 12 ++++++------ gosa-si/gosa-si-client | 18 +++++++++--------- gosa-si/gosa-si-server | 15 ++++++++------- gosa-si/modules/DBsqlite.pm | 2 +- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/gosa-si/gosa-si-bus b/gosa-si/gosa-si-bus index 7d436d306..a9ae07261 100755 --- a/gosa-si/gosa-si-bus +++ b/gosa-si/gosa-si-bus @@ -34,6 +34,7 @@ use IO::Socket::INET; use NetAddr::IP; use XML::Simple; use MIME::Base64; +use File::Basename; use Digest::MD5 qw(md5 md5_hex md5_base64); @@ -41,12 +42,13 @@ my ($cfg_file, $default_cfg_file, %cfg_defaults, $foreground, $verbose, $pid_fil my ($bus_address, $bus_key, $bus_ip, $bus_port, $bus_mac_address); my ($bus_known_server_db, $bus_known_server_file_name, $bus_known_clients_db, $bus_known_clients_file_name); my $xml; +our $prg= basename($0); $foreground = 0 ; %cfg_defaults = ( "general" => { - "log_file" => [\$log_file, "/var/run/".$0.".log"], - "pid_file" => [\$pid_file, "/var/run/".$0.".pid"], + "log_file" => [\$log_file, "/var/run/".$prg.".log"], + "pid_file" => [\$pid_file, "/var/run/".$prg.".pid"], }, "bus" => { "key" => [\$bus_key, "secret-bus-password"], @@ -173,7 +175,7 @@ sub check_pid { #=============================================================================== sub usage { print STDERR << "EOF" ; -usage: $0 [-hvf] [-c config] +usage: $prg [-hvf] [-c config] -h : this (help) message -c : config file @@ -213,10 +215,8 @@ sub daemon_log { $month = $monthnames[$month]; $monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday; $year+=1900; - my $name = $0; - $name =~ s/\.\///; - my $log_msg = "$month $monthday $hours:$minutes:$seconds $name $msg\n"; + my $log_msg = "$month $monthday $hours:$minutes:$seconds $prg $msg\n"; print LOG_HANDLE $log_msg; if( $foreground ) { print STDERR $log_msg; diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 454b1b765..f36c77f77 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -35,6 +35,7 @@ use Digest::MD5 qw(md5_hex md5 md5_base64); use MIME::Base64; use XML::Simple; use Net::DNS; +use File::Basename; my $event_dir = "/usr/lib/gosa-si/client/events"; use lib "/usr/lib/gosa-si/client/events"; @@ -61,12 +62,13 @@ our $REGISTERED = 0; # in function register_at_gosa_si_server, after which period of seconds a new registration should be tried if a registration was # not successful until now my $delay_set_time = 5; +our $prg= basename($0); %cfg_defaults = ( "general" => - {"log-file" => [\$log_file, "/var/run/".$0.".log"], - "pid-file" => [\$pid_file, "/var/run/".$0.".pid"], - "opts-file" => [\$opts_file, "/var/run/".$0.".opts"], + {"log-file" => [\$log_file, "/var/run/".$prg.".log"], + "pid-file" => [\$pid_file, "/var/run/".$prg.".pid"], + "opts-file" => [\$opts_file, "/var/run/".$prg.".opts"], }, "client" => {"port" => [\$client_port, "20083"], @@ -222,10 +224,8 @@ sub daemon_log { $month = $monthnames[$month]; $monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday; $year+=1900; - my $name = $0; - $name =~ s/\.\///; - my $log_msg = "$month $monthday $hours:$minutes:$seconds $name $msg\n"; + my $log_msg = "$month $monthday $hours:$minutes:$seconds $prg $msg\n"; print LOG_HANDLE $log_msg; if( $foreground ) { print STDERR $log_msg; @@ -809,11 +809,11 @@ sub write_to_file { my $error = 0; if( not defined $file || not -f $file ) { - &main::daemon_log("ERROR: $0: check '-f file' failed: $file", 1); + &main::daemon_log("ERROR: $prg: check '-f file' failed: $file", 1); $error++; } if( not defined $string || 0 == length($string)) { - &main::daemon_log("ERROR: $0: empty string to write to file '$file'", 1); + &main::daemon_log("ERROR: $prg: empty string to write to file '$file'", 1); $error++; } @@ -1138,7 +1138,7 @@ if( 0 != $pid ) { } daemon_log(" ", 1); -daemon_log("$0 started!", 1); +daemon_log("$prg started!", 1); # delete old DBsqlite lock files system('rm -f /tmp/gosa_si_lock*gosa-si-client*'); diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 04063e6f3..127d8b65e 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -39,6 +39,7 @@ use Data::Dumper; use Sys::Syslog qw( :DEFAULT setlogsock); use Cwd; use File::Spec; +use File::Basename; use GOSA::DBsqlite; use POE qw(Component::Server::TCP); @@ -94,11 +95,12 @@ our $known_server_db; # holds all registrated clients our $known_clients_db; +our $prg= basename($0); %cfg_defaults = ( "general" => { - "log-file" => [\$log_file, "/var/run/".$0.".log"], - "pid-file" => [\$pid_file, "/var/run/".$0.".pid"], + "log-file" => [\$log_file, "/var/run/".$prg.".log"], + "pid-file" => [\$pid_file, "/var/run/".$prg.".pid"], }, "bus" => { "activ" => [\$bus_activ, "true"], @@ -130,14 +132,14 @@ our $known_clients_db; #=============================================================================== sub usage { print STDERR << "EOF" ; -usage: $0 [-hvf] [-c config] +usage: $prg [-hvf] [-c config] -h : this (help) message -c : config file -f : foreground, process will not be forked to background -v : be verbose (multiple to increase verbosity) - -no-bus : starts $0 without connection to bus - -no-arp : starts $0 without connection to arp module + -no-bus : starts $prg without connection to bus + -no-arp : starts $prg without connection to arp module EOF print "\n" ; @@ -199,8 +201,7 @@ sub daemon_log { $month = $monthnames[$month]; $monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday; $year+=1900; - my $name = $0; - $name =~ s/\.\///; + my $name = $prg; my $log_msg = "$month $monthday $hours:$minutes:$seconds $name $msg\n"; print LOG_HANDLE $log_msg; diff --git a/gosa-si/modules/DBsqlite.pm b/gosa-si/modules/DBsqlite.pm index 206620c7c..95ac1b68b 100644 --- a/gosa-si/modules/DBsqlite.pm +++ b/gosa-si/modules/DBsqlite.pm @@ -17,7 +17,7 @@ sub new { my $class = shift; my $db_name = shift; - my $lock = $db_name.".gosa_lock"; + my $lock = $db_name.".lock"; # delete existing lock - instance should be running only once if(stat($lock)) { unlink($lock); -- 2.30.2