Author: degenaro
Date: Thu Jun  2 09:51:16 2016
New Revision: 1746544

URL: http://svn.apache.org/viewvc?rev=1746544&view=rev
Log:
UIMA-4926 No need to prompt for passwords when installing DUCC

db_create should also automatically generate PW, when necessary

Modified:
    uima/sandbox/uima-ducc/trunk/src/main/admin/db_create
    uima/sandbox/uima-ducc/trunk/src/main/admin/db_util.py

Modified: uima/sandbox/uima-ducc/trunk/src/main/admin/db_create
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/src/main/admin/db_create?rev=1746544&r1=1746543&r2=1746544&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/src/main/admin/db_create (original)
+++ uima/sandbox/uima-ducc/trunk/src/main/admin/db_create Thu Jun  2 09:51:16 
2016
@@ -27,8 +27,10 @@ import shutil
 import subprocess
 from  stat import *
 
-from ducc_util import DuccUtil
+import string
+import random
 
+from ducc_util import DuccUtil
 
 from ducc_base import Properties
 from ducc_base import Property
@@ -57,7 +59,7 @@ class DbCreate(DuccUtil):
         print ''
         print "Usage:"
         print "   db_create [options]"
-        print "        If no options prompts are given for expected 
parameters."
+        print "        If no options defaults are used for expected 
parameters."
         print ""
         print "Options:"
         print "   [-d, --db-password] <root password for database>"
@@ -86,7 +88,7 @@ class DbCreate(DuccUtil):
         
 
         if ( self.database_pw == None ):
-            self.usage("Must specify your database password.");
+            self.database_pw = self.generate_pw()
 
         # start with merged properties
         self.merge_properties();
@@ -118,7 +120,13 @@ class DbCreate(DuccUtil):
 
         # remerge to insure it's all correct and ready to go
         self.merge_properties();
-
+    
+    # generate a random string between 8 and 16 characters long
+    def generate_pw(self):
+        pwlen = random.randrange(8,16)
+        reply = ''.join([random.choice(string.ascii_letters + string.digits) 
for n in xrange(pwlen)])
+        return reply
+        
 if __name__ == "__main__":
 
     postinstall = DbCreate()

Modified: uima/sandbox/uima-ducc/trunk/src/main/admin/db_util.py
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/src/main/admin/db_util.py?rev=1746544&r1=1746543&r2=1746544&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/src/main/admin/db_util.py (original)
+++ uima/sandbox/uima-ducc/trunk/src/main/admin/db_util.py Thu Jun  2 09:51:16 
2016
@@ -89,7 +89,7 @@ def format(header, lines):
 # 
--------------------------------------------------------------------------------
 
 def stop_database(pidfile):
-    print "Stopping the dtabase."
+    print "Stopping the database."
 
     CMD = ['kill', '-TERM', '`cat ' + pidfile + '`']
     CMD = ' '.join(CMD)
@@ -136,7 +136,7 @@ def configure_database(DUCC_HOME, DUCC_H
             print "Must enter a DB password or 'bypass' to continue."
         return False
 
-    if ( os.path.exists(DUCC_HOME + "/database/data") ):
+    if ( os.path.exists(DUCC_HOME + "/state/database/data") ):
         print 'Database is already defined in', DUCC_HOME + '/database', '- 
not rebilding.'
         return False
 


Reply via email to