Ignore:
Timestamp:
2012-04-03T20:56:04+12:00 (12 years ago)
Author:
ak19
Message:
  1. Replacing ChangePwdUsersDB.java with new file ModifyUsersDB.java, since the latter allows you to modify any and all fields for a username. 2. Now build.xml's config-admin target has been updated to call ModifyUsersDB with a new password for the admin user. A new target, config-user, takes user input to set any or all fields of any username. This can then be called by the release-kit if we wish to add a demo user during installation as we did in the GS2 releasekit. 3. Updated txt2usersDB.java to take the append flag: with this flag on, it will no longer delete the entire DB and read a new DB in from the input text file, but will append the additional entries in the input text file to the existing entries in the usersDB.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/build.xml

    r25321 r25338  
    11171117  </target>
    11181118
    1119   <target name="check-tomcat-running">
     1119  <target name="check-tomcat-running"><!--if you update this target, may want to change similar elements in config-admin-->
    11201120    <!--can also try the "socket" condition in place of the "http" condition-->
    11211121    <condition property="tomcat.isrunning"><!--<waitfor maxwait="5" maxwaitunit="second" timeoutproperty="tomcat.isstopped">-->
     
    11791179    </if>
    11801180  </target>
     1181
     1182  <!-- ======================= Admin Targets ============================ --> 
     1183
     1184  <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
     1185    See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
     1186    But you can do: echo mypassword | ant config-admin -->
     1187  <target name="config-admin" description="Reset admin password">
     1188    <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-8 characters):&gt;">
     1189      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
     1190    </input>
     1191    <echo>PWD: ${admin.password}</echo>
     1192    <antcall target="update-userdb">
     1193      <param name="user.username" value="admin"/>
     1194      <param name="user.password" value="${admin.password}"/>
     1195      <param name="user.groups" value=""/>
     1196      <param name="user.status" value=""/>
     1197      <param name="user.comment" value="Password updated."/>
     1198      <param name="user.email" value=""/>
     1199    </antcall>
     1200  </target>
     1201
     1202  <target name="config-user" description="Add or modify users" depends="get-user-data,update-userdb"/>
     1203
     1204  <target name="get-user-data" description="Get user details">
     1205    <input addproperty="user.username" message="Username:&gt;"/>
     1206    <input addproperty="user.password" defaultvalue="" message="Password (3-8 characters):&gt;">
     1207      <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
     1208    </input>
     1209    <input addproperty="user.groups" defaultvalue="" message="Groups (comma-separated list):&gt;"/>
     1210    <input addproperty="user.status" defaultvalue="true" message="Enabled (true/false):&gt;"/>
     1211    <input addproperty="user.comment" defaultvalue="" message="Comment:&gt;"/>
     1212    <input addproperty="user.email" defaultvalue="" message="Email:&gt;"/>
     1213  </target>
     1214
     1215<!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
     1216    See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
     1217    But you can do: echo mypassword | ant config-admin -->
     1218  <target name="update-userdb" description="Add or modify users">
     1219    <echo>username: ${user.username}</echo>
     1220    <echo>groups: ${user.groups}</echo>
     1221
     1222    <!-- stop tomcat if running, since derby db is embedded and only allows connections from one jvm instance at a time
     1223      See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html -->
     1224    <!--<antcall target="check-tomcat-running"/>--><!--won't set the tomcat.isrunning property for use below-->
     1225    <condition property="tomcat.isrunning">
     1226      <http url="http://${tomcat.server}:${tomcat.port}${app.path}"/><!--can also try the "socket" condition in place of the "http" condition-->
     1227    </condition>
     1228    <if>
     1229      <bool>
     1230    <istrue value="${tomcat.isrunning}"/>
     1231      </bool>
     1232      <antcall target="force-stop-tomcat"/>
     1233    </if>
     1234
     1235    <!--<echo>${admin.password}</echo>--> <!-- for testing -->
     1236    <java classname="org.greenstone.gsdl3.util.ModifyUsersDB">
     1237      <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
     1238      <arg file="${web.home}/sites/localsite/etc/usersDB"/>
     1239      <arg value="${user.username}"/>
     1240      <arg value="password=${user.password}"/>
     1241      <arg value="groups=${user.groups}"/>
     1242      <arg value="status=${user.status}"/>
     1243      <arg value="comment=${user.comment}"/>
     1244      <arg value="email=${user.email}"/>
     1245    </java>
     1246   
     1247    <!-- run tomcat again if it used to be running -->
     1248    <if>
     1249      <bool>
     1250    <istrue value="${tomcat.isrunning}"/>
     1251    </bool>
     1252      <antcall target="start-tomcat"/>
     1253    </if>
     1254  </target>
     1255
    11811256
    11821257  <!-- ======================= Axis Targets ============================ --> 
     
    12251300      </else>
    12261301
    1227     </if>
    1228   </target>
    1229 
    1230   <!-- This target won't work with Eclipse because the SecureInputHandler used below conflicts with it.
    1231     See http://www.dcepler.net/post.cfm/hiding-password-input-in-ant
    1232     But you can do: echo mypassword | ant config-admin -->
    1233   <target name="config-admin" description="Reset admin password">
    1234     <input addproperty="admin.password" defaultvalue="admin" message="New admin password (3-8 characters):&gt;">
    1235       <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> <!-- password won't be visible on screen -->
    1236     </input>
    1237 
    1238     <!-- stop tomcat if running, since derby db is embedded and only allows connections from one jvm instance at a time
    1239       See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html -->
    1240 
    1241     <!--<antcall target="check-tomcat-running"/>--><!--won't set the tomcat.isrunning property for use below-->
    1242     <condition property="tomcat.isrunning">
    1243       <http url="http://${tomcat.server}:${tomcat.port}${app.path}"/><!--can also try the "socket" condition in place of the "http" condition-->
    1244     </condition>
    1245     <if>
    1246       <bool>
    1247     <istrue value="${tomcat.isrunning}"/>
    1248       </bool>
    1249       <antcall target="force-stop-tomcat"/>
    1250     </if>
    1251 
    1252     <!--<echo>${admin.password}</echo>--> <!-- for testing -->
    1253     <java classname="org.greenstone.gsdl3.util.ChangePwdUsersDB">
    1254       <classpath refid="compile.classpath"/> <!--for ${web.lib}/gsdl3.jar and supporting files-->
    1255       <arg file="${web.home}/sites/localsite/etc/usersDB"/>
    1256       <arg value="admin"/>
    1257       <arg value="${admin.password}"/>
    1258     </java>
    1259 
    1260     <!-- run tomcat again if it used to be running -->
    1261     <if>
    1262       <bool>
    1263     <istrue value="${tomcat.isrunning}"/>
    1264     </bool>
    1265       <antcall target="start-tomcat"/>
    12661302    </if>
    12671303  </target>
Note: See TracChangeset for help on using the changeset viewer.