Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:mkudlvasr
zope-python-2.4
Zope-2.7.0-mkinstance.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File Zope-2.7.0-mkinstance.patch of Package zope-python-2.4
--- utilities/mkzopeinstance.py +++ utilities/mkzopeinstance.py @@ -32,6 +32,10 @@ import shutil import sys import copyzopeskel +import pwd +import grp + +INSTANCES_HOME='/var/opt/zope' def main(): try: @@ -51,7 +55,7 @@ for opt, arg in opts: if opt in ("-d", "--dir"): - skeltarget = os.path.abspath(os.path.expanduser(arg)) + skeltarget = os.path.expanduser(arg) if not skeltarget: usage(sys.stderr, "dir must not be empty") sys.exit(2) @@ -76,9 +80,11 @@ # interactively ask for skeltarget and initial user name/passwd. # cant set custom instancehome in interactive mode, we default # to skeltarget. - skeltarget = instancehome = os.path.abspath( - os.path.expanduser(get_skeltarget()) - ) + skeltarget = os.path.expanduser(get_skeltarget()) + + if skeltarget[0] != '/': + print 'Instance home not absolute, placing under %s.' % INSTANCES_HOME + skeltarget = "%s/%s" % (INSTANCES_HOME, skeltarget) instancehome = skeltarget zopehome = os.path.dirname(os.path.dirname(script)) @@ -121,9 +127,23 @@ "ZOPE_HOME": zopehome, } - copyzopeskel.copyskel(skelsrc, skeltarget, None, None, **kw) + try: + uid = pwd.getpwnam("zope")[2] + except: + print 'Could not get uid for zope, check your zope installation!' + sys.exit(1) + + try: + gid = grp.getgrnam("zope")[2] + except: + print 'Could not get gid for zope, check your zope installation!' + sys.exit(1) + + copyzopeskel.copyskel(skelsrc, skeltarget, uid, gid, **kw) + os.chown(skeltarget, uid, gid) + if user and password: - write_inituser(inituser, user, password) + write_inituser(inituser, user, password, uid, gid) def usage(stream, msg=None): if msg: @@ -133,10 +153,13 @@ print >>stream, __doc__ % {"program": program} def get_skeltarget(): + print print 'Please choose a directory in which you\'d like to install' print 'Zope "instance home" files such as database files, configuration' print 'files, etc.' print + print 'If you do not enter absolute path, it will be placed under %s' % INSTANCES_HOME + print while 1: skeltarget = raw_input("Directory: ").strip() if skeltarget == '': @@ -148,6 +171,7 @@ def get_inituser(): import getpass + print print 'Please choose a username and password for the initial user.' print 'These will be the credentials you use to initially manage' print 'your new Zope instance.' @@ -165,7 +189,7 @@ print "Password mismatch, please try again..." return user, passwd -def write_inituser(fn, user, password): +def write_inituser(fn, user, password, uid, gid): import binascii import sha fp = open(fn, "w") @@ -173,6 +197,7 @@ fp.write('%s:{SHA}%s\n' % (user, pw)) fp.close() os.chmod(fn, 0644) + os.chown(fn, uid, gid) if __name__ == "__main__": main()
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor