incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1297104 - in /incubator/bloodhound/trunk/installer: ./ LICENSE NOTICE README.rst createdigest.py installer.py pgrequirements.txt requirements.txt
Date Mon, 05 Mar 2012 15:57:01 GMT
Author: gjm
Date: Mon Mar  5 15:57:00 2012
New Revision: 1297104

URL: http://svn.apache.org/viewvc?rev=1297104&view=rev
Log:
very basic candidate bloodhound installer

Added:
    incubator/bloodhound/trunk/installer/
    incubator/bloodhound/trunk/installer/LICENSE   (with props)
    incubator/bloodhound/trunk/installer/NOTICE   (with props)
    incubator/bloodhound/trunk/installer/README.rst   (with props)
    incubator/bloodhound/trunk/installer/createdigest.py   (with props)
    incubator/bloodhound/trunk/installer/installer.py   (with props)
    incubator/bloodhound/trunk/installer/pgrequirements.txt   (with props)
    incubator/bloodhound/trunk/installer/requirements.txt   (with props)

Added: incubator/bloodhound/trunk/installer/LICENSE
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/installer/LICENSE?rev=1297104&view=auto
==============================================================================
--- incubator/bloodhound/trunk/installer/LICENSE (added)
+++ incubator/bloodhound/trunk/installer/LICENSE Mon Mar  5 15:57:00 2012
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Propchange: incubator/bloodhound/trunk/installer/LICENSE
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bloodhound/trunk/installer/NOTICE
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/installer/NOTICE?rev=1297104&view=auto
==============================================================================
--- incubator/bloodhound/trunk/installer/NOTICE (added)
+++ incubator/bloodhound/trunk/installer/NOTICE Mon Mar  5 15:57:00 2012
@@ -0,0 +1,6 @@
+Apache Bloodhound
+Copyright 2012 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/)
+

Propchange: incubator/bloodhound/trunk/installer/NOTICE
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bloodhound/trunk/installer/README.rst
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/installer/README.rst?rev=1297104&view=auto
==============================================================================
--- incubator/bloodhound/trunk/installer/README.rst (added)
+++ incubator/bloodhound/trunk/installer/README.rst Mon Mar  5 15:57:00 2012
@@ -0,0 +1,312 @@
+=========================================
+ General Installion of Apache Bloodhound
+=========================================
+
+With the basic scripts in this directory you will eventually be able to install
+the Apache Bloodhound source with limited fuss.
+
+The following decribes how to install using the installer.py script with either
+SQLite or PostgreSQL databases.
+
+For simplicity, this document usually describes installation from the point of
+view of using ubuntu 11.10 and so commands will probably have to be adjusted
+to take your operating system version into account.
+
+General Prerequisites
+=====================
+
+The provided script requires at least:
+
+ * Python (2.6 >= version < 3.0)
+ * setuptools
+ * pip
+ * virtualenv
+
+Most distributions of linux should have these in their repositories (pip and
+virutalenv are likely to be python-pip and python-virtualenv respectively.) 
+If these are not readily available, the instructions for downloading and 
+installing for your system should be at:
+
+ * Python: http://www.python.org/
+ * setuptools: http://pypi.python.org/pypi/setuptools#id1
+ * pip: http://www.pip-installer.org/en/latest/installing.html
+
+Once you have pip you should be able to::
+ pip install virtualenv
+
+Database Prerequisites
+======================
+
+Although Apache Bloodhound supports a number of databases, this installer
+currently only sets up either SQLite or PostgreSQL databases.
+
+Installing Apache Bloodhound with SQLite should be considerably easier than
+PostgreSQL as Python comes with SQLite integrated into it. In addition, no
+special access rights are required to create an SQLite database as it is stored
+in a local file.
+
+However, SQLite may not be appropriate for larger production installations and
+so using PostgreSQL is generally encouraged. On the other hand, for less
+intensive use or evaluation, SQLite should be a good choice. If you think that
+SQLite is for you, skip to the next section now.
+
+Using PostgreSQL is complicated by having to create users and a database on
+the server and the appropriate permissions to access it. It also adds the
+following dependencies:
+
+ * PostgreSQL
+ * psycopg2
+
+Again, for linux distributions, these are probably available from the relevant
+distribution repositories. Otherwise you should be able to download and find
+instructions for installing from:
+
+ * PostgreSQL: http://www.postgresql.org/
+ * psycopg2: http://initd.org/psycopg/
+
+Alternatively, it might be possible to install psycopg2 with a pip install
+command but this may require additional dependencies to compile the package.
+This is also why it is generally considered a prerequisite.
+
+With these in place, you will also need to add a user and database and make sure
+that the created user is able to access the database. For example::
+
+  $ sudo su - postgres
+  $ createuser -U postgres -S -D -R -E -P bloodhound
+  $ createdb -U postgres -O bloodhound -E UTF-8 bloodhound
+  $ logout
+
+and (on ubuntu 11.10)::
+
+  $ sudo vi /etc/postgresql/9.1/main/pg_hba.conf
+
+In that file you should change::
+  local   all             all                                     peer
+to::
+  local   all             all                                     md5
+
+After saving and restarting the database::
+  $ sudo /etc/init.d/postgresql restart
+
+Guided Installation
+===================
+
+If no options are provided, the installer will ask you some of the more
+important questions to help set up Apache Bloodhound. As such you can just
+run::
+
+  $ python installer.py
+
+and answer the questions, providing details depending on the choices you made
+about the database.
+
+Specifically, if you choose SQLite, you will only be asked to provide an admin
+user name and a password to use. For the PostgreSQL choice, you are also asked
+for the database name, database user and the associated password.
+
+It is also possible to specify all these details on the command line and set
+additional options like the host for the postgres database and the location of
+the installation. For more information on these options, try running::
+
+  $ python installer.py --help
+
+Testing the Server
+==================
+
+On linux and other unix-like systems you can then run bloodhound using::
+  $ source ./bloodhound/bin/activate
+  $ tracd ./bloodhound/environments/main --port=8000
+
+On windows you should instead use::
+  $ bloodhound\bin\activate.bat
+  $ tracd bloodhound\environments\main --port-8000
+
+Note that it is necessary to use the activate script to activate the python
+virtual environment before you are able to run the tracd command. It is
+generally only required once per shell session.
+
+At this point you should be able to access Apache Bloodhound on
+  http://localhost:8000/main/
+
+where you can login with the admin user and password details you supplied.
+
+Web Server
+==========
+
+If you have managed to prove that you can run the system with the standalone
+tracd, you should now also be able to run through a web server. Here we provide
+details about how to use the Apache webserver. It is currently recommended to
+use Apache with mod_wsgi to serve Bloodhound. The following instructions
+require apache to be installed along with the wsgi and auth_digest modules.
+
+It is possible to get the trac-admin command to reduce some of the work of
+creating the wsgi file::
+  $ source ./bloodhound/bin/activate
+  $ trac-admin ./bloodhound/environments/main/ deploy ./bloodhound/site
+
+You should also make sure that the appropriate modules are enabled for wsgi
+and htdigest authentication. On ubuntu this would be::
+  $ sudo a2enmod wsgi
+  $ sudo a2enmod auth_digest
+
+You will then need to create a site configuation for Apache. In ubuntu this can
+be done like this::
+  $ sudo vi /etc/apache2/sites-available/bloodhound
+
+Add to this something like::
+  <VirtualHost *:8080>
+    WSGIDaemonProcess bloodhound_tracker user=bloodhound python-path=/path/to/bloodhound/lib/python2.7/site-packages
+    WSGIScriptAlias /bloodhound /path/to/bloodhound/site/cgi-bin/trac.wsgi
+    <Directory /path/to/bloodhound/site/cgi-bin>
+      WSGIProcessGroup bloodhound_tracker
+      WSGIApplicationGroup %{GLOBAL}
+      Order deny,allow
+      Allow from all
+    </Directory>
+    <LocationMatch "/bloodhound/[^/]+/login">
+      AuthType Digest
+      AuthName "Bloodhound"
+      AuthDigestDomain /bloodhound
+      AuthUserFile /path/to/bloodhound/environments/bloodhound.htdigest
+      Require valid-user
+    </LocationMatch>
+  </VirtualHost>
+
+The user referred to in the WSGIDaemonProcess should be the user that you wish
+bloodhound to be run as and so that user must have the appropriate set of
+permissions to access the Bloodhound installation. Running with any special
+system level priviledges should not be required and is not recommended.
+
+Then enable the new site, check the apache configuration and restart apache::
+
+  $ sudo a2ensite bloodhound
+  $ sudo apachectl configtest
+  $ sudo apachectl graceful
+
+If that all worked, you will now be able to see Apache Bloodhound running on:
+  http://localhost:8080/bloodhound/
+
+Notes on Authentication
+=======================
+
+The installation procedure assumes that you will want to create an admin user
+to access the site with. The details can be specified by the --admin-user and
+--admin-password options. If they are not provided, the script will ask for the
+details instead. The authentication mechanism is created from these details by
+creating an htdigest file, setting up htdigest authentication with the account
+manager and giving the initial user full admin access in the web frontend.
+
+It is also possible to set the digest realm by using the --digest-realm option.
+
+Once you are running the web application, it is possible to modify the
+authentication mechanism further through the admin pages.
+
+Overview of Manual Installation Instruction Assuming Ubuntu 11.10
+================================================================
+
+The following table describes steps to install bloodhound with (at least) the
+following assumptions:
+ * Ubuntu 11.10
+ * Python already installed
+ * Required database installed (not the python bindings)
+ * Database user and database created (not for SQLite) and
+   * the database will be on localhost (default port)
+   * db user is user; db user's password is pass; database name is dbname
+
++---------------------+-------------------------------------------------+----------------------------------------+
+| Step Description    | Common Steps                                    | Optional (recommended)
Steps           |
++=====================+=================================================+========================================+
+| install pip         | sudo apt-get install python-pip                 |               
                        |
++---------------------+-------------------------------------------------+----------------------------------------+
+| install virtualenv  |                                                 | sudo apt-get install
python-virtualenv |
++---------------------+-------------------------------------------------+----------------------------------------+
+| create and activate |                                                 | virtualenv bloodhound
                 |
+|  an environment     |                                                 | source bloodhound/bin/activate
        |
+| (commands from now  |                                                 |               
                        |
+|  on should be run   |                                                 |               
                        |
+|  in the active env) |                                                 |               
                        |
++---------------------+-------------------------------------------------+----------------------------------------+
+| install reqs        | pip install -r requirements.txt                 |               
                        |
++---------------------+-------------------------------------------------+----------------------------------------+
+| create environments | mkdir -p bloodhound/environments/               |               
                        |
+|  directory          | cd bloodhound/environments/                     |               
                        |
++---------------------+-------------------------------------------------+----------------------------------------+
+| create htdigest     | python ../../createdigest.py --user=admin \     |               
                        |
+|                     |   --password=adminpasswd --realm=bloodhound \   |               
                        |
+|                     |   -f bloodhound.htdigest                        |               
                        |
++---------------------+-------------------------------------------------+----------------------------------------+
+| add a base config   | nano base.ini                                   |               
                        |
+|  file (see below)   |                                                 |               
                        |
++---------------------+-------------------------------------------------+----------------------------------------+
+
+In base.ini save the following (replacing each /path/to with the real path) ::
+[account-manager]
+account_changes_notify_addresses = 
+authentication_url = 
+db_htdigest_realm = 
+force_passwd_change = true
+hash_method = HtDigestHashMethod
+htdigest_file = /path/to/bloodhound/environments/bloodhound.htdigest
+htdigest_realm = bloodhound
+htpasswd_file = 
+htpasswd_hash_type = crypt
+password_file = /path/to/bloodhound/environments/bloodhound.htdigest
+password_store = HtDigestStore
+persistent_sessions = False
+refresh_passwd = False
+user_lock_max_time = 0
+verify_email = True
+
+[components]
+acct_mgr.admin.*= enabled
+acct_mgr.api.accountmanager = enabled
+acct_mgr.guard.accountguard = enabled
+acct_mgr.htfile.htdigeststore = enabled
+acct_mgr.web_ui.accountmodule = enabled
+acct_mgr.web_ui.loginmodule = enabled
+multiproduct.model.multiproductenvironmentprovider = enabled
+multiproduct.product_admin.productadminpanel = enabled
+multiproduct.product_admin.productpermissions = enabled
+multiproduct.ticket.api.productticketsystem = enabled
+multiproduct.ticket.web_ui.productticketmodule = enabled
+trac.web.auth.loginmodule = disabled
+trac.ticket.api.ticketsystem = disabled
+trac.ticket.web_ui.ticketmodule = disabled
+
+
+The double specification of htdigest_file and password_file is because of
+differences between versions of the account manager plugin.
+
+Continue with the following table that shows the completion of the installation
+for a few databases types.
+
++---------------------+-------------------------------------------------+--------------------------------------------+-------------------+
+| Step Description    | Common Steps                                    | PostgreSQL Only
                           | SQLite Only       |
++=====================+=================================================+============================================+===================+
+| install python      |                                                 | sudo apt-get install
python-psycopg2       |                   |
+|  database bindings  |                                                 |               
                            |                   |
++---------------------+-------------------------------------------------+--------------------------------------------+-------------------+
+| set $DBSTING adding | export DBSTRING=[db specific string ->]         | postgres://user:pass@localhost:5432/dbname
| sqlite:db/trac.db |
+|  db specific string |                                                 |               
                            |                   |
++---------------------+-------------------------------------------------+--------------------------------------------+-------------------+
+| initialise          | trac-admin main initenv ProjectName $DBSTRING \ |               
                            |                   |
+|                     |   --inherit=base.ini                            |               
                            |                   |
++---------------------+-------------------------------------------------+--------------------------------------------+-------------------+
+| upgrade wiki        | trac-admin main wiki upgrade                    |               
                            |                   |
+| set permissions     | trac-admin main permission add admin TRAC_ADMIN |               
                            |                   |
++---------------------+-------------------------------------------------+--------------------------------------------+-------------------+
+
+Now it should be possible to start bloodhound with::
+
+  $ tracd --port=8000 main
+
+and login from http://localhost:8000/main/login
+
+Also note that if you are starting from a new shell session, if you are using
+virtualenv you should::
+  $ source path/to/bloodhound/bin/activate
+
+then::
+  $ tracd --port=8000 path/to/bloodhound/environments/main
+
+

Propchange: incubator/bloodhound/trunk/installer/README.rst
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bloodhound/trunk/installer/createdigest.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/installer/createdigest.py?rev=1297104&view=auto
==============================================================================
--- incubator/bloodhound/trunk/installer/createdigest.py (added)
+++ incubator/bloodhound/trunk/installer/createdigest.py Mon Mar  5 15:57:00 2012
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+"""Simple htdigest file creation.
+Saves the need for an installed htdigest program"""
+
+import os
+import shutil
+import sys
+from tempfile import mkstemp
+from optparse import OptionParser
+from hashlib import md5
+from getpass import getpass
+
+DEFAULT_USER = 'admin'
+DEFAULT_REALM = 'default'
+DEFAULT_FILE = 'default.htdigest'
+
+def htdigest_create(filename, user, realm, password, path=''):
+    """Create an htdigest file by adding the user to the file
+    Just in case an htdigest file already exists, this function will copy the
+    data line by line into a temporary file, commenting out any lines that match
+    the user and realm data. The new entry is then appended before the temporary
+    copy is moved back to the original location"""
+    
+    user_realm = ':'.join((user, realm))
+    digest = md5(':'.join((user_realm, password))).hexdigest()
+    data = ':'.join((user_realm, digest)) + '\n'
+    
+    filepath = os.path.join(path, filename)
+    temp, tempfilepath = mkstemp()
+    with open(tempfilepath,'w') as tempdigestfile:
+        if os.path.exists(filepath):
+            with open(filepath) as origdigestfile:
+                for line in origdigestfile:
+                    if line.strip().startswith(user_realm + ':'):
+                        tempdigestfile.write('#' + line)
+                    else:
+                        tempdigestfile.write(line)
+        tempdigestfile.write(data)
+    os.close(temp)
+    if os.path.exists(filepath):
+        os.remove(filepath)
+    shutil.move(tempfilepath, filepath)
+
+def main():
+    """Parse arguments and run the  function"""
+    
+    parser = OptionParser()
+    parser.add_option('-f', '--digestfile', dest='digestfile',
+                      help='htdigest filename')
+    parser.add_option('-r', '--realm', dest='realm',
+                      help='authentication realm')
+    parser.add_option('-u', '--user', dest='user',
+                      help='user name')
+    parser.add_option('-p', '--password', dest='password',
+                      help='password for USER')
+    
+    (opts, args) = parser.parse_args()
+    
+    if not opts.digestfile:
+        input_file = raw_input('Enter the file [%s]: ' % DEFAULT_FILE)
+        opts.digestfile = input_file if input_file else DEFAULT_FILE
+    path, filename = os.path.split(opts.digestfile)
+    
+    if not opts.user:
+        input_user = raw_input('Enter the user [%s]: ' % DEFAULT_USER)
+        opts.user = input_user if input_user else DEFAULT_USER
+        
+    if not opts.password:
+        attempts = 3
+        for attempt in range(attempts):
+            if attempt > 0:
+                print "Passwords empty or did not match. Please try again",
+                print "(attempt %d/%d)""" % (attempt+1, attempts)
+            password1 = getpass('Enter a new password for "%s": ' % opts.user)
+            password2 = getpass('Please reenter the password: ')
+            if password1 and password1 == password2:
+                opts.password = password1
+                break
+        if not opts.password:
+            print "Passwords did not match. Quitting."
+            sys.exit(1)
+    
+    if not opts.realm:
+        input_realm = raw_input('Enter the auth realm [%s]: ' % DEFAULT_REALM)
+        opts.realm = input_realm if input_realm else DEFAULT_REALM
+    
+    htdigest_create(filename, opts.user, opts.realm, opts.password, path)
+
+if __name__ == '__main__':
+    main()

Propchange: incubator/bloodhound/trunk/installer/createdigest.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bloodhound/trunk/installer/installer.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/installer/installer.py?rev=1297104&view=auto
==============================================================================
--- incubator/bloodhound/trunk/installer/installer.py (added)
+++ incubator/bloodhound/trunk/installer/installer.py Mon Mar  5 15:57:00 2012
@@ -0,0 +1,293 @@
+#!/usr/bin/env python
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+"""Installer for Bloodhound - depends on the supplied requirements.txt file
+to determine the installation packages"""
+
+import os
+from optparse import OptionParser
+import subprocess
+import platform
+import sys
+from getpass import getpass
+
+from virtualenv import create_environment
+from createdigest import htdigest_create
+
+DEFAULT_DB_USER = 'bloodhound'
+DEFAULT_DB_NAME = 'bloodhound'
+DEFAULT_ADMIN_USER = 'admin'
+
+BASE_CONFIG = """
+"""
+
+ACCOUNTMGRSTR = """
+[account-manager]
+account_changes_notify_addresses = 
+authentication_url = 
+db_htdigest_realm = 
+force_passwd_change = true
+hash_method = HtDigestHashMethod
+htdigest_file = %(htdigest)s
+htdigest_realm = %(realm)s
+htpasswd_file = 
+htpasswd_hash_type = crypt
+password_file = %(htdigest)s
+password_store = HtDigestStore
+persistent_sessions = False
+refresh_passwd = False
+user_lock_max_time = 0
+verify_email = True
+
+[components]
+acct_mgr.admin.*= enabled
+acct_mgr.api.accountmanager = enabled
+acct_mgr.guard.accountguard = enabled
+acct_mgr.htfile.htdigeststore = enabled
+acct_mgr.web_ui.accountmodule = enabled
+acct_mgr.web_ui.loginmodule = enabled
+multiproduct.model.multiproductenvironmentprovider = enabled
+multiproduct.product_admin.productadminpanel = enabled
+multiproduct.product_admin.productpermissions = enabled
+multiproduct.ticket.api.productticketsystem = enabled
+multiproduct.ticket.web_ui.productticketmodule = enabled
+trac.web.auth.loginmodule = disabled
+trac.ticket.api.ticketsystem = disabled
+trac.ticket.web_ui.ticketmodule = disabled
+"""
+
+def install_virtualenv(venvpath, syspackages):
+    """Install virtualenv - should be done before any pip installs, and
+    runs a command like: virtualenv bloodhound --no-site-packages
+    """
+    create_env_cmd = ['virtualenv', venvpath]
+    if not syspackages:
+        create_env_cmd.append('--no-site-packages')
+    print 'Running: ' + ' '.join(create_env_cmd)
+    try:
+        code = subprocess.call(create_env_cmd)
+    except OSError:
+        print "Could not create the virtualenv - is virtualenv installed?"
+        sys.exit(-1)
+    if code != 0:
+        print "Creation of virtual environment failed. Exit code=", code
+        sys.exit(code)
+
+def trac_config_create(adminuser, adminpass, realm, digestfile, trac_ini):
+    """Create the config and optionally a htdigest file"""
+    config_str = ''
+    config_str += BASE_CONFIG
+    
+    htdigest_create(digestfile, adminuser, realm, adminpass)
+    # adding appropriate configuration to use the digestfile with the
+    # account manager plugin
+    config_str += ACCOUNTMGRSTR % {'htdigest':digestfile,
+                                   'realm':realm}
+    with open(trac_ini, 'a') as inifile:
+        inifile.write(config_str)
+    return adminpass
+
+def do_install(options):
+    """Perform the installation"""
+    data = {'dbuser':options.dbuser, 'dbpass':options.dbpass,
+            'host':options.dbhost, 'dbname':options.dbname}
+    dbtype = options.dbtype.lower()
+    
+    if (not options.dbuser or not options.dbpass) and dbtype != 'sqlite':
+        dbtype = 'sqlite'
+    if dbtype in ['postgres', 'postgresql']:
+        dbstr = 'postgres://%(dbuser)s:%(dbpass)s@%(host)s/%(dbname)s' % data
+    else:
+        dbstr = 'sqlite:db/bloodhound.db'
+    
+    bindir = os.path.join(options.venvpath,'bin')
+    admin = os.path.join(bindir, 'trac-admin')
+    
+    create_environment(options.venvpath, site_packages=options.syspackages)
+    
+    def run_pip(venvpath, requirements):
+        """Run pip install"""
+        if platform.system() in ('Windows', 'Microsoft'):
+            pip = os.path.join(venvpath, 'scripts', 'pip')
+        else:
+            pip = os.path.join(venvpath, 'bin', 'pip')
+        prefix = os.path.abspath(venvpath)
+        code = subprocess.call([pip, 'install',
+                                '--requirement=%s' % requirements,
+                                '--install-option=--prefix=%s' % prefix])
+                      #'--environment=%s' % venvpath,
+        if code:
+            raise Exception
+        return code
+    
+    if dbtype in ['postgres', 'postgresql']:
+        run_pip(options.venvpath, 'pgrequirements.txt')
+    run_pip(options.venvpath, options.requirements)
+    
+    environments_path = os.path.join(options.venvpath, 'environments')
+    if not os.path.exists(environments_path):
+        os.makedirs(environments_path)
+    
+    new_env = os.path.join(environments_path, options.project)
+    
+    if platform.system() in ('Windows', 'Microsoft'):
+        data['activate'] = os.path.join(bindir,'activate.bat')
+    else:
+        data['activate'] = 'source ' + os.path.join(bindir, 'activate')
+    project_dir = os.path.join(environments_path,
+                               options.project)
+    data['tracd'] = 'tracd --port=8000 ' + project_dir
+    digestfile = os.path.abspath(
+            os.path.join(environments_path,options.digestfile)
+            )
+    base_ini = os.path.abspath(
+            os.path.join(environments_path, 'base.ini')
+            )
+    trac_config_create(options.adminuser, options.adminpass, options.realm,
+            digestfile, base_ini)
+
+    def trac_admin_run_cmd(cmd):
+        """Runs a command (assumes that it is trac-admin)"""
+        print 'Running: ' + ' '.join(cmd)
+        try:
+            code = subprocess.call(cmd)
+        except OSError:
+            print "Error: trac-admin command was not installed in previous step"
+            sys.exit(-3)
+        if code != 0:
+            print "Error while running trac-admin command. Exit code=", code
+            sys.exit(code)
+
+    
+    trac_admin_run_cmd([admin, new_env, 'initenv', options.project, dbstr,
+                       '--inherit=%s' % base_ini])
+    trac_admin_run_cmd([admin, new_env, 'upgrade'])
+    trac_admin_run_cmd([admin, new_env, 'wiki', 'upgrade'])
+    trac_admin_run_cmd([admin, new_env, 'permission', 'add', options.adminuser,
+                        'TRAC_ADMIN'])
+    
+    print """To run you must first activate the virtual environment: 
+  %(activate)s
+then:
+  %(tracd)s""" % data
+    
+
+def main():
+    """Parse arguments and call the installer function"""
+    parser = OptionParser()
+    parser.add_option('-e', '--environment', dest='venvpath',
+                      help='Use virtual environment name',
+                      default='bloodhound')
+    parser.add_option('--project', dest='project',
+                      help='Set the top project name', default='main')
+    parser.add_option('-r', '--requirements', dest='requirements',
+                      help='Use requirements file',
+                      default='requirements.txt')
+    parser.add_option('-d', '--database-type', dest='dbtype',
+                      help="Specify as one of 'postgres' or 'sqlite'",
+                      default='')
+    parser.add_option('--database-name', dest='dbname',
+                      help='Specify the database name (option for postgres)')
+    parser.add_option('-u', '--user', dest='dbuser',
+                      help='Specify the db user (required for postgres)',
+                      default='')
+    parser.add_option('-p', '--password', dest='dbpass',
+                      help='Specify the db password (option for postgres)')
+    parser.add_option('--database-host', dest='dbhost',
+                      help='Specify the database host (optional for postgres)',
+                      default='localhost')
+    parser.add_option('--no-site-packages', dest='syspackages',
+                      action='store_false', default=True,
+                      help="Don't use system installed packages in virtualenv")
+    parser.add_option('--admin-password', dest='adminpass',
+                      help='create an admin user in an htdigest file')
+    parser.add_option('--digest-realm', dest='realm', default='bloodhound',
+                      help='authentication realm for htdigest file')
+    parser.add_option('--admin-user', dest='adminuser', default='',
+                      help='admin user name for htdigest file')
+    parser.add_option('--digest-file', dest='digestfile',
+                      default='bloodhound.htdigest',
+                      help='filename for the htdigest file')
+    
+    (options, args) = parser.parse_args()
+    if args:
+        print "Unprocessed options/arguments: ", args
+    
+    def ask_question(question, default=None):
+        """Basic question asking functionality"""
+        if default:
+            answer = raw_input(question % default)
+        else:
+            answer = raw_input(question)
+        return answer if answer else default
+    
+    def ask_password(user):
+        """Asks for a password to be provided for setting purposes"""
+        attempts = 3
+        for attempt in range(attempts):
+            if attempt > 0:
+                print "Passwords empty or did not match. Please try again",
+                print "(attempt %d/%d)""" % (attempt+1, attempts)
+            password1 = getpass('Enter a new password for "%s": ' % user)
+            password2 = getpass('Please reenter the password: ')
+            if password1 and password1 == password2:
+                return password1
+        print "Passwords did not match. Quitting."
+        sys.exit(1)
+
+    if options.dbtype.lower() not in ['postgres','sqlite']:
+        answer = ask_question("""
+This installer is able to install Apache Bloodhound with either SQLite or
+PostgreSQL databases. SQLite is an easier option for installing Bloodhound as
+SQLite is usually built into Python and also requires no special permissions to
+run. However, PostgreSQL is generally expected to be more robust for production
+use.
+Do you want to install to a PostgreSQL database [Y/n]: """)
+        options.dbtype = 'postgres' if answer.lower() not in ['n','no'] else 'sqlite'
+    else:
+        options.dbtype = options.dbtype.lower()
+
+    if options.dbtype == 'postgres':
+        if not options.dbuser:
+            options.dbuser = ask_question("""
+For PostgreSQL you need to have PostgreSQL installed and you need to have
+created a database user to connect to the database with. Setting this up may
+require admin access rights to the server.
+DB user name [%s]: """, DEFAULT_DB_USER)
+        
+        if not options.dbpass:
+            options.dbpass = ask_password(options.dbuser)
+        
+        if not options.dbname:
+            options.dbname = ask_question("""
+For PostgreSQL setup, you need to specify a database that you have created for
+Bloodhound to use. This installer currently assumes that this database will be
+empty.
+DB name [%s]: """, DEFAULT_DB_NAME)
+    if not options.adminuser:
+        options.adminuser = ask_question("""
+Please supply a username for the admin user [%s]: """, DEFAULT_ADMIN_USER)
+    if not options.adminpass:
+        options.adminpass = ask_password(options.adminuser)
+    
+    do_install(options)
+
+if __name__ == '__main__':
+    main()
+

Propchange: incubator/bloodhound/trunk/installer/installer.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bloodhound/trunk/installer/pgrequirements.txt
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/installer/pgrequirements.txt?rev=1297104&view=auto
==============================================================================
--- incubator/bloodhound/trunk/installer/pgrequirements.txt (added)
+++ incubator/bloodhound/trunk/installer/pgrequirements.txt Mon Mar  5 15:57:00 2012
@@ -0,0 +1,2 @@
+psycopg2
+

Propchange: incubator/bloodhound/trunk/installer/pgrequirements.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/bloodhound/trunk/installer/requirements.txt
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/installer/requirements.txt?rev=1297104&view=auto
==============================================================================
--- incubator/bloodhound/trunk/installer/requirements.txt (added)
+++ incubator/bloodhound/trunk/installer/requirements.txt Mon Mar  5 15:57:00 2012
@@ -0,0 +1,7 @@
+Pygments
+pytz
+Babel
+Genshi
+-e svn+https://svn.github.com/bloodhound-trac/trac.git#egg=Trac
+-e svn+https://trac-hacks.org/svn/accountmanagerplugin/0.11#egg=TracAccountManager
+-e svn+https://svn.apache.org/repos/asf/incubator/bloodhound/trunk/bloodhound_multiproduct#egg=BloodhoundMultiProduct

Propchange: incubator/bloodhound/trunk/installer/requirements.txt
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message