[Zope-Checkins] CVS: Zope/inst - configure.py:1.1.2.6 make_instance.py:1.3.4.5
Chris McDonough
chrism@zope.com
Thu, 29 Aug 2002 12:38:14 -0400
Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv18143/inst
Modified Files:
Tag: chrism-install-branch
configure.py make_instance.py
Log Message:
Made make_instance.py take getopt arguments to gather info programmatically
instead of interactively if necessary (for automated installs).
Changed Makefile to put quotes around paths as necessary to fix bug
reported by Jens
Cleaned up some output.
=== Zope/inst/configure.py 1.1.2.5 => 1.1.2.6 ===
--- Zope/inst/configure.py:1.1.2.5 Wed Aug 28 00:12:30 2002
+++ Zope/inst/configure.py Thu Aug 29 12:38:14 2002
@@ -98,14 +98,17 @@
f.close()
if OK:
return
- print ("This Python interpreter does not have 'large file support'"
- "enabled. Large file support is required to allow the default"
- "Zope database to grow larger than 2GB. Either install a Python "
- "interpreter with large file support"
- "(see http://www.python.org/doc/current/lib/posix-large-files.html)"
- "or run %s again with the --ignore-largefile option to proceed"
- "ignoring this warning and accepting the consequences." %
- sys.argv[0])
+ print (
+ """
+This Python interpreter does not have 'large file support' enabled. Large
+file support is required to allow the default Zope database to grow larger
+than 2GB on most platforms. Either install a Python interpreter with large
+file support (see http://www.python.org/doc/current/lib/posix-large-files.html)
+or run this program again with the --ignore-largefile option to prevent this
+warning, with the understanding that your Zope may fail if the database size
+ever exceeds 2GB.
+"""
+ )
sys.exit(127)
if __name__ == '__main__':
=== Zope/inst/make_instance.py 1.3.4.4 => 1.3.4.5 ===
--- Zope/inst/make_instance.py:1.3.4.4 Thu Aug 29 02:14:52 2002
+++ Zope/inst/make_instance.py Thu Aug 29 12:38:14 2002
@@ -12,16 +12,55 @@
##############################################################################
"""Make an INSTANCE_HOME."""
-import sys, os, string
+import sys, os, string, stat, getopt
-def setup(me):
- home=os.path.abspath(os.path.split(me)[0])
- return os.path.split(home)[0]
+def main():
+ home=os.path.split(os.path.abspath(os.path.split(sys.argv[0])[0]))[0]
+ sys.path.insert(0, home)
+ ih = None
+ user = None
+ passwd = None
+ try:
+ longopts = ["home=", "inituser=", "help"]
+ opts, args = getopt.getopt(sys.argv[1:], "h", longopts)
+ except getopt.GetoptError, v:
+ print v
+ usage()
+ sys.exit(0)
+ for o, a in opts:
+ if o in ('-h', '--help'):
+ usage()
+ sys.exit()
+ if o == '--home':
+ ih = os.path.abspath(os.path.expanduser(a))
+ if o == '--inituser':
+ user, passwd=a.split(':', 1)
+ if not user or not passwd:
+ print(
+ '--inituser must be specified in the format'
+ ' "username:password"'
+ )
+ usage()
+ sys.exit(127)
+ if ih is None:
+ ih = get_ih(home)
+ make_ih(home, ih)
+ if user is None or passwd is None:
+ user, passwd = get_inituser(home, ih)
+ write_inituser(ih, user, passwd)
+ print 'Done! Use "%s/zctl start" to start Zope.' % ih
+def usage():
+ print ("%s [--home=dir] [--inituser=username:passwd] | [--help]" %
+ sys.argv[0])
+ print " If 'home' or 'inituser' are not specified as options, they are"
+ print " gathered interactively"
+
def get_ih(home):
- print 'The instance home is the directory from which you will run Zope.'
- print 'Several instance homes, each with their own data and'
- print 'configuration, can share one copy of Zope.'
+ print
+ print 'An instance home is a directory from which you will run Zope.'
+ print 'Each instance home contains its own data and configuration but'
+ print 'shares "base" Zope software from %s.' % home
while 1:
print
ih = raw_input('Instance home [%s]: ' % home)
@@ -44,16 +83,14 @@
print "%s exists, so I left it alone." % `ih`
return ih
-def main(me):
- home=setup(me)
- ih = get_ih(home)
-
+def make_ih(home, ih):
+ print '-'*78
# Make skeleton
for dirname in ('Extensions', 'import', 'Products', 'var'):
mode = (dirname == 'var') and 0711 or 0775
dirpath = os.path.join(ih, dirname)
if not os.path.isdir(dirpath):
- os.mkdir(dirpath, mode)
+ os.makedirs(dirpath, mode)
print 'Created %s directory.' % `dirname`
# Set up Data.fs
@@ -79,41 +116,45 @@
outfile = open(target, 'wb')
outfile.write(txt)
outfile.close()
- os.chmod(target, 0700)
+ st = os.stat(infile)
+ srcmode = st[stat.ST_MODE]
+ if srcmode & stat.S_IEXEC:
+ os.chmod(target, 0755)
+ else:
+ os.chmod(target, 0644)
print 'Created %s' % fn
print '-'*78
print
- print ('Now to create a starting user. Leave the username '
- 'blank if you want to skip this step.')
+
+def write_inituser(ih, username, passwd):
+ ac_path=os.path.join(ih, 'inituser')
+ acfile=open(ac_path, 'w')
+ import zpasswd
+ acfile.write('%s:%s'%(username,zpasswd.generate_passwd(passwd, 'SHA')))
+ acfile.close()
+ os.chmod(ac_path, 0644)
+
+def get_inituser(home, ih):
+ import getpass
+ print 'Please choose a username and password for the initial user.'
+ print 'These will be the credentials you use to initially manage'
+ print 'your %s Zope instance.' % ih
print
- sys.path.insert(0, home)
- choose_inituser(ih)
- print 'Done! Use "%s/zctl start" to start Zope.' % ih
+ user = raw_input("Username: ")
+ if user == '':
+ return
-def choose_inituser(home):
- ac_path=os.path.join(home, 'inituser')
- if not os.path.exists(ac_path):
- import getpass, zpasswd
- print '-'*78
- print 'Please choose a username and password.'
- print 'This will create the initial user with which you manage Zope.'
- username = raw_input("Username: ")
- if username == '':
- return
-
- while 1:
- pw = getpass.getpass("Password: ")
- verify = getpass.getpass("Verify password: ")
- if verify == pw:
- break
- else:
- pw = verify = ''
- print "Password mismatch, please try again..."
- acfile=open(ac_path, 'w')
- acfile.write('%s:%s' % (username, zpasswd.generate_passwd(pw, 'SHA')))
- acfile.close()
+ while 1:
+ passwd = getpass.getpass("Password: ")
+ verify = getpass.getpass("Verify password: ")
+ if verify == passwd:
+ break
+ else:
+ passwd = verify = ''
+ print "Password mismatch, please try again..."
- import do; do.ch(ac_path, '', '', mode=0644)
+ return user, passwd
-if __name__=='__main__': main(sys.argv[0])
+if __name__=='__main__':
+ main()