installDse.pl 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # --- BEGIN COPYRIGHT BLOCK ---
  2. # This Program is free software; you can redistribute it and/or modify it under
  3. # the terms of the GNU General Public License as published by the Free Software
  4. # Foundation; version 2 of the License.
  5. #
  6. # This Program is distributed in the hope that it will be useful, but WITHOUT
  7. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. #
  10. # You should have received a copy of the GNU General Public License along with
  11. # this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. # Place, Suite 330, Boston, MA 02111-1307 USA.
  13. #
  14. # In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. # right to link the code of this Program with code not covered under the GNU
  16. # General Public License ("Non-GPL Code") and to distribute linked combinations
  17. # including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. # permitted under this exception must only link to the code of this Program
  19. # through those well defined interfaces identified in the file named EXCEPTION
  20. # found in the source code files (the "Approved Interfaces"). The files of
  21. # Non-GPL Code may instantiate templates or use macros or inline functions from
  22. # the Approved Interfaces without causing the resulting work to be covered by
  23. # the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. # additions to the list of Approved Interfaces. You must obey the GNU General
  25. # Public License in all respects for all of the Program code and other code used
  26. # in conjunction with the Program except the Non-GPL Code covered by this
  27. # exception. If you modify this file, you may extend this exception to your
  28. # version of the file, but you are not obligated to do so. If you do not wish to
  29. # provide this exception without modification, you must delete this exception
  30. # statement from your version and license this file solely under the GPL without
  31. # exception.
  32. #
  33. #
  34. # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. # Copyright (C) 2005 Red Hat, Inc.
  36. # All rights reserved.
  37. # --- END COPYRIGHT BLOCK ---
  38. #
  39. # The script is used to load the config mapping tree node for the null suffix
  40. # and to load the test sample plugin node into the Directory Server used to
  41. # demonstrate the Data Interoperability feature for Verisign.
  42. # The dse.ldif configuration file used as the default configuration by the
  43. # Server gets edited for adding the above mentioned two config nodes and the
  44. # server is restarted to load the plugin.
  45. # The loading of the DataInterop test plugin is only to demostrate the use
  46. # of the test plugin and can be replaced with Verisign's database plugin for use.
  47. # Written by [email protected]
  48. # Edits to be done for use
  49. # $host = Hostname of the Directory Server
  50. # $port = port used by the Server
  51. # $mgrdn = Bind Dn
  52. # $mgrpass = Password
  53. # $installDir = Installation root of the Server <server-root>
  54. ###### Begin Edits ##################################
  55. $host = "trika.nscp.aoltw.net";
  56. $instance = "trika2";
  57. $port = "7775";
  58. $mgrdn = "cn=directory manager";
  59. $mgrpass = "password";
  60. $installDir = "/export/msyBuild/install"; # Installation root of the Server <server-root>
  61. ###### End of Edits ##################################
  62. $dseOrgFile = "$installDir/slapd-$instance/config/dse.ldif"; # default configuration file to be edited
  63. $dseFile = "$installDir/slapd-$instance/config/load_dse.ldif"; # additional configuration file to be added
  64. $pidFile = "$installDir/slapd-$instance/logs/pid"; # pid file for the running server
  65. my $editedNode = 0;
  66. my $editedPlugin = 0;
  67. my $serverStatus = 1;
  68. if(!(-e $pidFile)){
  69. open( START_SERVER, "| $installDir/slapd-$instance/start-slapd ") || die "Can't Start the Server \n";
  70. close(START_SERVER);
  71. if(-e $pidFile){
  72. print " ######## Started the Server \n";
  73. }
  74. else {
  75. print " ######## Unable to Start the Server \n";
  76. $serverStatus = 0;
  77. }
  78. }
  79. open(DSE_ORG, "$dseOrgFile") || die "Can't open $dseOrgFile for checks \n";
  80. while(<DSE_ORG>){
  81. $isEditedNode = 1 if (/^dn: cn=\"\",cn=mapping tree,cn=config/);
  82. $isEditedPlugin = 1 if (/^dn: cn=datainterop,cn=plugins,cn=config/);
  83. }
  84. close(DSE_ORG);
  85. open(DSE, ">$dseFile") || die "Can't open $dseFile for editing \n";
  86. my $changesMade = 0;
  87. unless($isEditedNode){
  88. print DSE "dn: cn=\"\",cn=mapping tree,cn=config\n";
  89. print DSE "objectClass: top\n";
  90. print DSE "objectClass: extensibleObject\n";
  91. print DSE "objectClass: nsMappingTree\n";
  92. print DSE "cn: \"\"\n";
  93. print DSE "nsslapd-state: container\n";
  94. print DSE "\n";
  95. $changesMade = 1;
  96. }
  97. unless($isEditedPlugin){
  98. print DSE "dn: cn=datainterop,cn=plugins,cn=config\n";
  99. print DSE "objectClass: top\n";
  100. print DSE "objectClass: nsSlapdPlugin\n";
  101. print DSE "cn: datainterop\n";
  102. print DSE "nsslapd-pluginPath: $installDir/plugins/slapd/slapi/examples/libtest-plugin.so\n";
  103. print DSE "nsslapd-pluginInitfunc: nullsuffix_init\n";
  104. print DSE "nsslapd-pluginType: preoperation\n";
  105. print DSE "nsslapd-pluginEnabled: on\n";
  106. print DSE "nsslapd-pluginId: nullsuffix-preop\n";
  107. print DSE "nsslapd-pluginVersion: 6.2\n";
  108. print DSE "nsslapd-pluginVendor: Netscape\n";
  109. print DSE "nsslapd-pluginDescription: sample pre-operation null suffix search plugin\n";
  110. $changesMade = 1;
  111. }
  112. close(DSE);
  113. if($changesMade){
  114. chdir "$installDir/shared/bin" or die "cannot cd over error=$! \n";
  115. open(LDAPMODIFY, "|ldapmodify -p \"${port}\" -h \"${host}\" -D \"${mgrdn}\" -w \"${mgrpass}\" -v -c -a -f $dseFile " ) || die "Can't modify the configuration of the Server \n";
  116. close(LDAPMODIFY);
  117. print " Modifications to the dse.ldif file have been done....restarting the server to load plugin \n";
  118. open( STOP_SERVER, "| $installDir/slapd-$instance/stop-slapd ") || die "Can't Stop the Server \n";;
  119. close(STOP_SERVER);
  120. print " Now stopped the Server to load the plugin \n";
  121. open( START_SERVER, "| $installDir/slapd-$instance/start-slapd ") || die "Can't Start the Server \n";
  122. close(START_SERVER);
  123. if(-e $pidFile){
  124. print " Started the Server Successfully\n";
  125. }
  126. else{
  127. $serverStatus = 0;
  128. print "Failure in starting the Server - Check to see if the sample plugin has been compiled \n";
  129. }
  130. }
  131. else {
  132. if($serverStatus){
  133. print " Nothing needs to be done \n";
  134. }
  135. else {
  136. print " The Server did not Start Successfully \n";
  137. }
  138. }