moinsetup

Change of moinsetup.py

4:4e672de9a373
moinsetup.py
     1.1 --- a/moinsetup.py	Tue May 04 00:14:00 2010 +0200
     1.2 +++ b/moinsetup.py	Tue May 04 00:25:24 2010 +0200
     1.3 @@ -1,6 +1,7 @@
     1.4  #!/usr/bin/env python
     1.5  
     1.6  from os.path import abspath, exists, join, split
     1.7 +from getpass import getpass
     1.8  import os
     1.9  import sys
    1.10  import shutil
    1.11 @@ -31,13 +32,6 @@
    1.12  Alias %(static_url_path)s "%(htdocs_dir)s/"
    1.13  """
    1.14  
    1.15 -apache_site_host_restriction = """
    1.16 -<Location "%(url_path)s">
    1.17 -    Deny from all
    1.18 -    Allow from %(superuser_client_host)s
    1.19 -</Location>
    1.20 -"""
    1.21 -
    1.22  # Utility functions.
    1.23  
    1.24  def readfile(filename):
    1.25 @@ -160,6 +154,7 @@
    1.26          self.install_data()
    1.27          self.configure_moin()
    1.28          self.edit_moin_scripts()
    1.29 +        self.add_superuser()
    1.30          self.make_site_files()
    1.31          self.make_post_install_script()
    1.32  
    1.33 @@ -264,6 +259,30 @@
    1.34          writefile(moin_cgi_installed, s)
    1.35          os.system("chmod a+rx '%s'" % moin_cgi_installed)
    1.36  
    1.37 +    def add_superuser(self):
    1.38 +
    1.39 +        "Add the superuser account."
    1.40 +
    1.41 +        moin_script = join(self.prefix, "bin", "moin")
    1.42 +
    1.43 +        print "Creating superuser", self.superuser, "using..."
    1.44 +        email = raw_input("E-mail address: ")
    1.45 +        password = getpass("Password: ")
    1.46 +
    1.47 +        path = os.environ.get("PYTHONPATH", "")
    1.48 +
    1.49 +        if path:
    1.50 +            os.environ["PYTHONPATH"] = path + ":" + self.conf_dir
    1.51 +        else:
    1.52 +            os.environ["PYTHONPATH"] = self.conf_dir
    1.53 +
    1.54 +        os.system(moin_script + " account create --name='%s' --email='%s' --password='%s'" % (self.superuser, email, password))
    1.55 +
    1.56 +        if path:
    1.57 +            os.environ["PYTHONPATH"] = path
    1.58 +        else:
    1.59 +            del os.environ["PYTHONPATH"]
    1.60 +
    1.61      def make_site_files(self):
    1.62  
    1.63          "Make the Apache site files."
    1.64 @@ -282,13 +301,6 @@
    1.65  
    1.66          writefile(site_def, s)
    1.67  
    1.68 -        # NOTE: By making the superuser in the installed Wiki, this site file
    1.69 -        # NOTE: would no longer be required.
    1.70 -
    1.71 -        s += apache_site_host_restriction % self.__dict__
    1.72 -
    1.73 -        writefile(site_def_private, s)
    1.74 -
    1.75      def make_post_install_script(self):
    1.76  
    1.77          "Write a post-install script with additional actions."
    1.78 @@ -296,7 +308,7 @@
    1.79          this_user = os.environ["USER"]
    1.80          postinst_script = "moinsetup-post.sh"
    1.81  
    1.82 -        s = ""
    1.83 +        s = "#!/bin/sh\n"
    1.84  
    1.85          for d in ("data", "underlay"):
    1.86              s += "chown -R %s.%s '%s'\n" % (this_user, self.web_group, join(self.conf_dir, d))
    1.87 @@ -306,6 +318,7 @@
    1.88              s += "chown -R %s.%s '%s'\n" % (this_user, self.web_group, self.htdocs_dir)
    1.89  
    1.90          writefile(postinst_script, s)
    1.91 +        os.chmod(postinst_script, 0755)
    1.92          note("Run %s as root to set file ownership and permissions." % postinst_script)
    1.93  
    1.94  # Main program.