# HG changeset patch # User Paul Boddie # Date 1272925524 -7200 # Node ID 4e672de9a37375a9f7d409cd5e0554b6a8a2244d # Parent 12d0f84e9cbe2f0648083a4e657e05a2413fe9be Removed the use of private site definitions in favour of setting up a superuser during the Wiki setup process. diff -r 12d0f84e9cbe -r 4e672de9a373 TO_DO.txt --- a/TO_DO.txt Tue May 04 00:14:00 2010 +0200 +++ b/TO_DO.txt Tue May 04 00:25:24 2010 +0200 @@ -1,3 +1,3 @@ -Automatic superuser initialisation and/or avoidance of competing site definitions. Site directory detection. Enabled/available site listings. +HTTP user integration and Apache user/group file editing. diff -r 12d0f84e9cbe -r 4e672de9a373 moinsetup.py --- a/moinsetup.py Tue May 04 00:14:00 2010 +0200 +++ b/moinsetup.py Tue May 04 00:25:24 2010 +0200 @@ -1,6 +1,7 @@ #!/usr/bin/env python from os.path import abspath, exists, join, split +from getpass import getpass import os import sys import shutil @@ -31,13 +32,6 @@ Alias %(static_url_path)s "%(htdocs_dir)s/" """ -apache_site_host_restriction = """ - - Deny from all - Allow from %(superuser_client_host)s - -""" - # Utility functions. def readfile(filename): @@ -160,6 +154,7 @@ self.install_data() self.configure_moin() self.edit_moin_scripts() + self.add_superuser() self.make_site_files() self.make_post_install_script() @@ -264,6 +259,30 @@ writefile(moin_cgi_installed, s) os.system("chmod a+rx '%s'" % moin_cgi_installed) + def add_superuser(self): + + "Add the superuser account." + + moin_script = join(self.prefix, "bin", "moin") + + print "Creating superuser", self.superuser, "using..." + email = raw_input("E-mail address: ") + password = getpass("Password: ") + + path = os.environ.get("PYTHONPATH", "") + + if path: + os.environ["PYTHONPATH"] = path + ":" + self.conf_dir + else: + os.environ["PYTHONPATH"] = self.conf_dir + + os.system(moin_script + " account create --name='%s' --email='%s' --password='%s'" % (self.superuser, email, password)) + + if path: + os.environ["PYTHONPATH"] = path + else: + del os.environ["PYTHONPATH"] + def make_site_files(self): "Make the Apache site files." @@ -282,13 +301,6 @@ writefile(site_def, s) - # NOTE: By making the superuser in the installed Wiki, this site file - # NOTE: would no longer be required. - - s += apache_site_host_restriction % self.__dict__ - - writefile(site_def_private, s) - def make_post_install_script(self): "Write a post-install script with additional actions." @@ -296,7 +308,7 @@ this_user = os.environ["USER"] postinst_script = "moinsetup-post.sh" - s = "" + s = "#!/bin/sh\n" for d in ("data", "underlay"): s += "chown -R %s.%s '%s'\n" % (this_user, self.web_group, join(self.conf_dir, d)) @@ -306,6 +318,7 @@ s += "chown -R %s.%s '%s'\n" % (this_user, self.web_group, self.htdocs_dir) writefile(postinst_script, s) + os.chmod(postinst_script, 0755) note("Run %s as root to set file ownership and permissions." % postinst_script) # Main program.