#!/usr/bin/perl
# ldap_restart.cgi
# LDAP Services Restart 
# STTA Rev. 1.3 Copyright (c) 2001-2002 Jesús Pérez Lorenzo  --- license GNU GPL 

 require './stta-lib.pl';
&foreign_require("proc", "proc-lib.pl");
$config{iferror_services}="warn"; 
&headerstta($text{'index_ldaprestart'}, "", "ldaprestart",undef,1,1,$text{headpage_rigth} );

 print "<hr><p>\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>$text{'titidx_ldaprestart'}</b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";

        $str=$config{'ldap_restart'};
	$exec_str="ldap";
        $cmd_str="restart";
        
        if (&run_cmd($str)) { 
          #  print "<tr><td><center><b>-- oOo --</b></center></td></tr>\n";
        } else {
            print "<tr><td><b>$text{'index_cmderr'}</b></td></tr>\n";
        }
        $str=$config{'ldap_restart'};
        $host=$config{ldap_server};
        $thishost_name=$config{ldap_servertitle};
        $title="$text{srvLDAP} $thishost_name:";
        $srv_status="";
        if ( $host ) {
             $port=$config {ldap_port};
             &chkout_service("status",$title,$sttaparams{'ldap'}{'ldap_status'},\$srv_status);
        } else {
             &chkout_service("status",$title,"unknown",\$srv_status);
        };
        $srv_status =~ s/==/<\/td><td><b>/g;
        $srv_status =~ s/STTA://g;
        print "<tr><td><center><b> $srv_status </b></center></td></tr>\n";
        if ( $config{ldap2_server}.length gt 0 ) {   
            $str=$config{'ldap2_restart'};
            $host=$config{ldap2_server};
            $thishost_name=$config{ldap2_servertitle};
            $title="$text{srvLDAP} $thishost_name:";
            $srv_status="";
            if ( $host ) {
                 $port=$config {ldap2_port};
                 &chkout_service("status",$title,$sttaparams{'ldap'}{'ldap2_status'},\$srv_status);
            } else {
                 &chkout_service("status",$title,"unknown",\$srv_status);
            };
            $srv_status =~ s/==/<\/td><td><b>/g;
            $srv_status =~ s/STTA://g;
            print "<tr><td><center><b> $srv_status </b></center></td></tr>\n";
#            if (&run_cmd($str)) { 
#              #        print "<tr><td><center><b>-- oOo --</b></center></td></tr>\n";
#            } else {
#                      print "<tr><td><b>$text{'index_cmderr'}</b></td></tr>\n";
#            }
        }
        &scanSTTA_services("all");
         
 print "<tr>\n";
 print "<tr>\n";
 print "</table></table><p>\n";
 &footer($text{'back_return'},$text{'index'});
 do "footer.pl";
 exit;



