<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>install/recipes/etc/init.d/supervisord</filename>
    </added>
    <added>
      <filename>install/recipes/etc/nginx/mime.types</filename>
    </added>
    <added>
      <filename>install/recipes/etc/nginx/nginx.conf</filename>
    </added>
    <added>
      <filename>install/recipes/etc/nginx/sites-available/default</filename>
    </added>
    <added>
      <filename>install/recipes/etc/nginx/sites-enabled/demisauce</filename>
    </added>
    <added>
      <filename>install/recipes/etc/postfix/main.cf</filename>
    </added>
    <added>
      <filename>install/recipes/etc/supervisord.conf</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,7 @@
 http://dev.mysql.com/doc/refman/5.0/en/alter-table.html
 ADD [COLUMN] col_name column_definition [FIRST | AFTER col_name ]
 MODIFY [COLUMN] col_name column_definition [FIRST | AFTER col_name]
+#ALTER TABLE t ENGINE = MYISAM;
 10/23/09:
 ALTER TABLE comment ADD is_public tinyint(1) default '0' after `isuser`;
 </diff>
      <filename>demisauce/trunk/db/alters.sql</filename>
    </modified>
    <modified>
      <diff>@@ -24,6 +24,9 @@ beaker.session.key = demisauce
 beaker.session.secret = ${app_instance_secret}
 app_instance_uuid = ${app_instance_uuid}
 
+# use your api key from admin on wordpress.com
+akismet_api_key = 123abc456
+
 # If you'd like to fine-tune the individual locations of the cache data dirs
 # for the Cache data, or the Session saves, un-comment the desired settings
 # here:</diff>
      <filename>demisauce/trunk/demisauce.egg-info/paste_deploy_config.ini_tmpl</filename>
    </modified>
    <modified>
      <diff>@@ -150,11 +150,8 @@ class CommentController(BaseController):
                     item.set_email(sanitize(self.form_result['email']))
                 if item.blog == &quot;your blog url&quot;:
                     item.blog = ''
-            # prod environment proxy: apache
-            if 'HTTP_X_FORWARDED_FOR' in request.environ:
-                item.ip = request.environ['HTTP_X_FORWARDED_FOR']
-            elif 'REMOTE_ADDR' in request.environ:
-                item.ip = request.environ['REMOTE_ADDR']
+            
+            item.ip = request.environ['HTTP_X_REAL_IP']
             item.user_agent = request.environ['HTTP_USER_AGENT']
             item.referrer = request.environ['HTTP_REFERER']
             item.comment = sanitize(self.form_result['comment'])
@@ -228,12 +225,7 @@ class CommentController(BaseController):
                 if item.blog == &quot;your blog url&quot;:
                     item.blog = ''
             
-            # prod environment proxy: apache
-            if 'HTTP_X_FORWARDED_FOR' in request.environ:
-                item.ip = request.environ['HTTP_X_FORWARDED_FOR']
-            elif 'REMOTE_ADDR' in request.environ:
-                item.ip = request.environ['REMOTE_ADDR']
-            
+            item.ip = request.environ['HTTP_X_REAL_IP']
             item.user_agent = request.environ['HTTP_USER_AGENT']
             item.referrer = request.environ['HTTP_REFERER']
             if 'comment' in request.params:</diff>
      <filename>demisauce/trunk/demisauce/controllers/comment.py</filename>
    </modified>
    <modified>
      <diff>@@ -29,7 +29,7 @@ class SiteController(BaseController):
         return self.view(c.user.site_id)
     
     def view(self,id = 0):
-        id = int(id) if id not None else 0
+        id = int(id) if id is not None else 0
         if id &gt; 0 and (c.user is not None) and c.user.issysadmin:
             c.item = Site.saget(id)
         elif id is None or id == 0 and c.user:</diff>
      <filename>demisauce/trunk/demisauce/controllers/site.py</filename>
    </modified>
    <modified>
      <diff>@@ -193,6 +193,15 @@ class BaseController(WSGIController):
         c.help_url = h.help_url()
         c.adminsite_slug = config['demisauce.appname']
         c.demisauce_url = config['demisauce.url']
+        
+        #translate different web/app server ip addresss
+        if 'HTTP_X_FORWARDED_FOR' in request.environ:
+            request.environ['HTTP_X_REAL_IP'] = request.environ['HTTP_X_FORWARDED_FOR']
+        elif 'REMOTE_ADDR' in request.environ:
+            request.environ['HTTP_X_REAL_IP'] = request.environ['REMOTE_ADDR']
+        elif 'HTTP_X_REAL_IP' in request.environ:
+            # allready set correctly
+            pass
     
     @print_timing
     def __call__(self, environ, start_response):</diff>
      <filename>demisauce/trunk/demisauce/lib/base.py</filename>
    </modified>
    <modified>
      <diff>@@ -53,16 +53,16 @@ class Comment(ModelBase):
                         blog_url='http://www.demisauce.com/'
                     )
             if ak.verify_key():
-                    data = {
-                        'user_ip': self.ip,
-                        'user_agent': self.user_agent,
-                        'referrer': self.referrer,
-                        'comment_type': 'comment',
-                        'comment_author': u'%s' % self.authorname,
-                    }
-            if ak.comment_check(u'%s' % self.comment, data=data, build_data=True):
-                # true returns = spam
-                self.is_public = False
+                data = {
+                    'user_ip': self.ip,
+                    'user_agent': self.user_agent,
+                    'referrer': self.referrer,
+                    'comment_type': 'comment',
+                    'comment_author': u'%s' % self.authorname,
+                }
+                if ak.comment_check(u'%s' % self.comment, data=data, build_data=True):
+                    # true returns = spam
+                    self.is_public = False
         super(Comment, self).save()
     
     def set_email(self,email):</diff>
      <filename>demisauce/trunk/demisauce/model/comment.py</filename>
    </modified>
    <modified>
      <diff>@@ -68,7 +68,7 @@
             &lt;td&gt;
                 &lt;a rel='/comment/delete/${item.id}' href=&quot;#&quot; class=&quot;deletecomment&quot;&gt;Delete&lt;/a&gt;
                 % if item.isuser:
-                    &lt;a href='/account/viewh/${item.hashedemail}'  class_=&quot;xtitle&quot;&gt; item.email&lt;/a&gt;
+                    &lt;a href='/account/viewh/${item.hashedemail}'  class_=&quot;xtitle&quot;&gt;${item.email}&lt;/a&gt;
                 % else:
                     ${item.email}, ${item.isuser}
                 % endif</diff>
      <filename>demisauce/trunk/demisauce/templates/comment/comment_bits.html</filename>
    </modified>
    <modified>
      <diff>@@ -173,6 +173,36 @@ def create_data_new(classtype,drop=False):
     else:
         print 'no class'
 
+def create_fixture_data(classtype):
+    models = None
+    if classtype in dir(fixture):
+        json_list = getattr(fixture, classtype)
+        #print json_list
+        models = model.ModelBase.from_json(json_list)
+    if classtype == 'person':
+        [m.after_load() for m in models]
+    elif classtype == 'email':
+        [m.after_load() for m in models]
+    elif classtype == 'poll':
+        for m in models:
+            questions = model.ModelBase.from_json(fixture.poll_question)
+            options = model.ModelBase.from_json(fixture.poll_question_option)
+            for q in questions:
+                m.questions.append(q)
+                for o in options:
+                    q.options.append(o)
+    elif (classtype == 'app'):
+        json_list = getattr(fixture, 'service')
+        models.extend(model.ModelBase.from_json(json_list))
+    
+    if models:
+        for m in models:
+            #print m.to_json()
+            m.save()
+    else:
+        print 'no class'
+
+
 def create_data(ini_file):
     &quot;&quot;&quot;
     Creates initial data
@@ -187,7 +217,7 @@ def create_data(ini_file):
     s = meta.DBSession.query(site.Site).get(1)
     key = conf['demisauce.apikey']
     if not s:
-        create_data_new('site')
+        create_fixture_data('site')
         s = meta.DBSession.query(site.Site).get(1)
     
     if s.key != key:
@@ -196,7 +226,7 @@ def create_data(ini_file):
     user = meta.DBSession.query(person.Person).filter_by(site_id=s.id,id=1).first()
     if not user:
         # pwd = raw_input('Enter the Password for admin: ')
-        create_data_new('person',True)
+        create_fixture_data('person')
         user = person.Person.get(1,1)
     
     cmsitem = cms.Cmsitem.get_root(site_id=s.id)
@@ -220,11 +250,11 @@ def create_data(ini_file):
         cmsitem.save()
         print 'created items   '
         
-    create_data_new('comment',True)
-    create_data_new('poll',True)
-    create_data_new('email',True)
-    create_data_new('app',True)
-    create_data_new('tag',True)
+    create_fixture_data('comment')
+    create_fixture_data('poll')
+    create_fixture_data('email')
+    create_fixture_data('app')
+    create_fixture_data('tag')
 
     
 def setup_config(command, filename, section, vars):</diff>
      <filename>demisauce/trunk/demisauce/websetup.py</filename>
    </modified>
    <modified>
      <diff>@@ -42,9 +42,9 @@ Demisauce can be installed following these `instructions
         &quot;Topic :: Software Development :: Libraries :: Python Modules&quot;,
     ], 
     url='http://demisauce.googlecode.com',
-    install_requires=[&quot;Pylons==0.9.6.2&quot;,&quot;Routes==1.7.3&quot;, 'sqlalchemy==0.5.6',
-        'demisaucepy&gt;=0.0.2','tempita','simplejson',&quot;memcache&quot;,
-        'webhelpers==0.6'],
+    install_requires=[&quot;Routes==1.7.3&quot;,&quot;Pylons==0.9.6.2&quot;, 'sqlalchemy==0.5.6',
+        'demisaucepy&gt;=0.0.2','tempita','simplejson',
+        'webhelpers==0.6.4'],
     packages=find_packages(exclude=['ez_setup']),
     include_package_data=True,
     test_suite='nose.collector',</diff>
      <filename>demisauce/trunk/setup.py</filename>
    </modified>
    <modified>
      <diff>@@ -50,7 +50,7 @@ Demisauce can be installed with `Easy Install
     author_email='',
     url='http://github.com/araddon/demisauce',
     download_url='http://demisauce.googlecode.com/files/demisaucepy-0.1.1.tar.gz',
-    install_requires=[&quot;elementtree&gt;=1.1&quot;,&quot;nose&gt;=0.10.4&quot;,&quot;memcache&quot;],
+    install_requires=[&quot;elementtree&gt;=1.1&quot;,&quot;nose&gt;=0.10.4&quot;],
     license='MIT',
     packages=find_packages(exclude=['ez_setup', 'examples']),
     include_package_data=True,</diff>
      <filename>demisaucepy/trunk/setup.py</filename>
    </modified>
    <modified>
      <diff>@@ -10,16 +10,16 @@ This uses `Fabric &lt;http://docs.fabfile.org&gt;`_  for installation download and ins
 If doing local VM install, Get `Ubuntu Server &lt;http://www.ubuntu.com/getubuntu/download-server&gt;`_ and start the install by doing updates and adding SSH and wget.  This also prints out the IP address (use bridging in vm if you want access via web from your desktop)::
 
     apt-get update
-    apt-get install openssh-server wget
+    apt-get install openssh-server 
     ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}
 
 Download `Demisauce Source &lt;http://github.com/araddon/demisauce&gt;`_  using `git &lt;http://git-scm.com/&gt;`_ ::
 
     git clone git://github.com/araddon/demisauce.git
     
-Edit the Fab files for your IP addresses of VM and run the install on VM:
+Edit the Fab files for your IP(hostname) addresses of VM and run the install:
 
-    fab vm106 build_all:ospwd=&quot;demisauce&quot;,dbpwd=&quot;demisauce&quot; -p demisauce
+    fab vm107 build:rootmysqlpwd=&quot;demisauce&quot;,userdbpwd=&quot;demisauce&quot; -p demisauce
 
 
 Full Lifecycle Workflow:  Setup, dev, test, prod, deploy, repeat
@@ -30,9 +30,8 @@ VM's for dev on local.
 **1. Build Base Image (Dev, Test, Prod)**
     Build a machine from Scratch (see #2 for upgrades), you need to do the one step manually because it times out quite often::
     
-        fab vm107 build_step1:rootmysqlpwd=&quot;demisauce&quot;,userdbpwd=&quot;demisauce&quot; -p demisauce
-        apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1C73E014
-        fab vm107 build_step2:rootmysqlpwd=&quot;demisauce&quot;,userdbpwd=&quot;demisauce&quot; -p demisauce
+        fab vm107 build:rootmysqlpwd=&quot;demisauce&quot;,userdbpwd=&quot;demisauce&quot; -p demisauce
+
 
 **2. Deploy Latest code to your env (Dev, Test, Prod)**
     Get latest set of source code, and potentially DB changes to deploy to Dev, Test or Prod machine(s). Note, this does *Not* include db script updates (see below)::
@@ -40,7 +39,9 @@ VM's for dev on local.
         fab vm107 release:userdbpwd=&quot;demisauce&quot; -p demisauce
 
 **3. Backup DB on Prod Machine**
-    Backup/Copies of prod data for backup as well as usage on #4.  Combination of EC2 EBS as well as sql backups.  
+    Backup/Copies of prod data for backup as well as usage on #4.  Combination of EC2 EBS as well as sql backups.::
+    
+    fab vm107 db_backup_apply -p demisauce
 
 **4. Restore Prod Data on Dev, Test for testing next release**
     Getting your prod data onto machine to verify next release </diff>
      <filename>install/README.rst</filename>
    </modified>
    <modified>
      <diff>@@ -5,12 +5,11 @@ from __future__ import with_statement # needed for python 2.5
 from fabric.api import *
 from fabric.contrib.project import rsync_project
 import os, simplejson, datetime
-#from optparse import OptionParser
-#import fab_recipes
 
-# TODO
-#  - allow for remote networking on mysql  bind-address = 192.168.0.106 to allow from other servers in local
-#  - 
+# TODO:  convert paster/ds over to supervisord
+# TODO /etc/init.d/demisauce_web is owned by demisauce instead of root
+# TODO persistent state?   between runs?  
+
 # =============    globals
 env.project_name = 'demisauce'
 INSTALL_ROOT = os.path.dirname(os.path.realpath(__file__))
@@ -18,6 +17,7 @@ PROJECT_ROOT = os.path.realpath(INSTALL_ROOT + '/../' )
 env.path = &quot;/home/demisauce&quot;
 env.local_path = PROJECT_ROOT
 env.redis_version = &quot;redis-1.02&quot;
+env.keys_added = False
 
 # ============   environments
 class _server(object):
@@ -48,10 +48,11 @@ class _server(object):
 
 base_config = {
     &quot;host&quot;  : &quot;localhost&quot;,
+    &quot;ip&quot;    : &quot;192.168.0.1&quot;,
     &quot;user&quot; : &quot;demisauce&quot;,
     &quot;path&quot; : &quot;/home/demisauce&quot;,
     &quot;desc&quot; : &quot;Default demisauce server&quot;,
-    &quot;os&quot;   : &quot;ubuntu9.04&quot;,
+    &quot;os&quot;   : &quot;ubuntu9.10&quot;,
     &quot;type&quot; : 'vm',
     &quot;environment&quot; : 'dev',
     &quot;mailhostname&quot; : 'demisauce.org',
@@ -59,9 +60,11 @@ base_config = {
 }
 
 # environments  ========================
-vm106 = _server(base_config,{&quot;desc&quot;:&quot;VMware 106 Demisauce Server&quot;,&quot;host&quot;  : &quot;192.168.0.106&quot;})
-vm107 = _server(base_config,{&quot;desc&quot;:&quot;VMware 107 Demisauce Server&quot;,&quot;host&quot;  : &quot;192.168.0.107&quot;})
-ec2prod = _server(base_config,{&quot;desc&quot;:&quot;EC2 Prod 1&quot;,&quot;host&quot;  : &quot;aws.amazon.com&quot;,&quot;mailhostname&quot; : 'smtp.demisauce.org'})
+vm112 = _server(base_config,{&quot;desc&quot;:&quot;VMware 112 Demisauce Server&quot;,&quot;host&quot;  : &quot;192.168.0.112&quot;, &quot;ip&quot;:&quot;192.168.0.112&quot;})
+vm115 = _server(base_config,{&quot;desc&quot;:&quot;VMware 115 Demisauce Server&quot;,&quot;host&quot;  : &quot;192.168.0.115&quot;, &quot;ip&quot;:&quot;192.168.0.115&quot;})
+vm117 = _server(base_config,{&quot;desc&quot;:&quot;KVM 117 Demisauce Server&quot;,&quot;host&quot;  : &quot;192.168.0.117&quot;, &quot;ip&quot;:&quot;192.168.0.117&quot;})
+ec2prod = _server(base_config,{&quot;desc&quot;:&quot;EC2 Prod 1&quot;,&quot;host&quot;  : &quot;aws.amazon.com&quot;,
+    &quot;mailhostname&quot; : 'smtp.demisauce.org', &quot;ip&quot;:&quot;192.168.0.112&quot;})
 imac = _server(base_config,{&quot;desc&quot;:&quot;iMac Desktop Dev&quot;, &quot;os&quot;: &quot;osx&quot;, &quot;host&quot;  : &quot;localhost&quot;,&quot;user&quot;:&quot;aaron&quot;})
 
 &quot;&quot;&quot;{'mailhostname': 'localhost', 
@@ -88,9 +91,8 @@ def _nginx_release():
         with cd(&quot;/etc/nginx&quot;):
             sudo(&quot;rm nginx.conf&quot;)
             sudo(&quot;rm sites-enabled/demisauce;&quot;)
-            sudo(&quot;rm sites-enabled/defaultmd5&quot;)
-    put('%s/nginx/nginx.conf' % INSTALL_ROOT, '/tmp/nginx.conf')
-    put('%s/nginx/sites-enabled/demisauce' % INSTALL_ROOT, '/tmp/sa-ds')
+    put('%s/recipes/etc/nginx/nginx.conf' % INSTALL_ROOT, '/tmp/nginx.conf')
+    put('%s/recipes/etc/nginx/sites-enabled/demisauce' % INSTALL_ROOT, '/tmp/sa-ds')
     sudo('mv /tmp/nginx.conf /etc/nginx/nginx.conf')
     sudo('mv /tmp/sa-ds /etc/nginx/sites-enabled/demisauce')
 
@@ -104,6 +106,19 @@ def _mysql(rootmysqlpwd,mysqlpwd):
     put('%(local_path)s/install/install_mysql.sh' % env, '/tmp/install_mysql.sh' % env)
     sudo('chmod +x /tmp/install_mysql.sh; /tmp/install_mysql.sh %s %s %s' % (rootmysqlpwd,mysqlpwd,env.type))
     sudo('rm /tmp/install_mysql.sh')
+    if env.environment == 'dev':
+        &quot;&quot;&quot;mysql -u[user] -p[pass] &lt;&lt;QUERY_INPUT
+        [mysql commands]
+        QUERY_INPUT
+        or
+        mysql -u[user] -p[pass] -e&quot;use mysql;  select * from user;&quot;  &quot;&quot;&quot;
+        run(&quot;&quot;&quot;mysql -uroot -p%(pwd)s &lt;&lt;QUERY_INPUT
+            use mysql; 
+            update user set host = '%(host)s' where user = 'ds_web' and host = 'localhost';
+            \nQUERY_INPUT&quot;&quot;&quot; % ({'pwd':'demisauce', 'host':'%'}))
+        
+        sudo('perl -pi -e &quot;s/127.0.0.1/127.0.0.1\nbind-address = %s\n/g&quot; /etc/mysql/my.cnf' % (env.ip))
+        sudo('/etc/init.d/mysql restart')
 
 def _zamanda(mysqlpwd):
     &quot;&quot;&quot; install backup tools&quot;&quot;&quot;
@@ -118,19 +133,47 @@ def _zamanda(mysqlpwd):
     setting recipient_delimiter: +
     setting inet_interfaces: all
     &quot;&quot;&quot;
-    require('mailhostname', provided_by=[vm107,vm106,ec2prod])
     put('%(local_path)s/install/install_zamanda.sh' % env, '/tmp/install_zamanda.sh' % env)
     sudo('chmod +x /tmp/install_zamanda.sh; /tmp/install_zamanda.sh %s %s %s' % (mysqlpwd,mysqlpwd,env.type))
     sudo('rm /tmp/install_zamanda.sh')
+    #sudo('echo &quot;%(mailhostname)s&quot; &gt;&gt; /etc/mailname' % env)
+
+def _postfix():
+    &quot;&quot;&quot;Install Postfix mail server&quot;&quot;&quot;
+    sudo('mkdir -p /etc/postfix')
+    put('%s/recipes/etc/postfix/main.cf' % INSTALL_ROOT, '/tmp/main.cf')
+    sudo('mv /tmp/main.cf /etc/postfix/main.cf')
     sudo('echo &quot;%(mailhostname)s&quot; &gt;&gt; /etc/mailname' % env)
+    sudo(&quot;env DEBIAN_FRONTEND=noninteractive apt-get -y install postfix&quot;)
+    
+    # These are all the options, but we only use a couple above
+    #  http://reductivelabs.com/trac/puppet/wiki/Recipes/DebianPreseed
+    &quot;&quot;&quot;postfix postfix/root_address    string  
+        postfix postfix/rfc1035_violation   boolean false
+        postfix postfix/mydomain_warning    boolean 
+        postfix postfix/mynetworks  string  127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
+        postfix postfix/mailname    string  demisauce.org
+        postfix postfix/tlsmgr_upgrade_warning  boolean 
+        postfix postfix/recipient_delim string  +
+        postfix postfix/main_mailer_type    select  Internet Site
+        postfix postfix/destinations    string  demisauce.org, demisauce, localhost.localdomain, localhost
+        postfix postfix/retry_upgrade_warning   boolean 
+        postfix postfix/kernel_version_warning  boolean 
+        postfix postfix/not_configured  error   
+        postfix postfix/mailbox_limit   string  0
+        postfix postfix/relayhost   string  
+        postfix postfix/procmail    boolean false
+        postfix postfix/bad_recipient_delimiter error   
+        postfix postfix/protocols   select  all
+        postfix postfix/chattr  boolean false
+    &quot;&quot;&quot;
 
 def _nginx():
     &quot;&quot;&quot;Installs Nginx&quot;&quot;&quot;
-    sudo(&quot;&quot;&quot;echo &quot;deb http://ppa.launchpad.net/jdub/devel/ubuntu hardy main&quot; &gt;&gt; /etc/apt/sources.list
-apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E9EEF4A1&quot;&quot;&quot;)
     sudo(&quot;apt-get -y update; apt-get -y install nginx&quot;)
     #get('/etc/nginx/mime.types', '%s/nginx/mime.types' % INSTALL_ROOT)
     #get('/etc/nginx/nginx.conf', '%s/nginx/nginx.conf' % INSTALL_ROOT)
+    sudo(&quot;rm /etc/nginx/sites-enabled/default&quot;)
     sudo(&quot;mkdir -p /vol/log/nginx&quot;)
 
 def _gearmanDrizzle():
@@ -149,8 +192,9 @@ deb-src http://ppa.launchpad.net/drizzle-developers/ppa/ubuntu karmic main&quot; &gt;&gt; /
     sudo(&quot;apt-get -y update; apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 06899068&quot;)
     sudo(&quot;apt-get -y update; apt-get install -y gearman gearman-job-server gearman-tools libgearman2 libgearman-dev libgearman-dbg libgearman-doc&quot;)
 
-def _gearman():
-    &quot;&quot;&quot;Install Gearman, requires base linux&quot;&quot;&quot;
+def _gearman_sources():
+    &quot;&quot;&quot;Adds sources for gearman, tries to get key&quot;&quot;&quot;
+    # sources for gearman
     sudo(&quot;cp /etc/apt/sources.list /etc/apt/sources.list.orig&quot;)
     if env.os == 'ubuntu8.04':
         sudo(&quot;&quot;&quot;echo &quot;deb http://ppa.launchpad.net/gearman-developers/ppa/ubuntu hardy main
@@ -162,10 +206,8 @@ deb-src http://ppa.launchpad.net/gearman-developers/ppa/ubuntu jaunty main&quot; &gt;&gt; /
         sudo(&quot;&quot;&quot;echo &quot;deb http://ppa.launchpad.net/gearman-developers/ppa/ubuntu karmic main
 deb-src http://ppa.launchpad.net/gearman-developers/ppa/ubuntu karmic main&quot; &gt;&gt; /etc/apt/sources.list&quot;&quot;&quot;)
     
-    sudo(&quot;apt-get -y --force-yes update&quot;)
-    sudo(&quot;apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1C73E014&quot;)
 
-def _gearman_step2():
+def _gearman():
     &quot;&quot;&quot;you need to manually update key before this
     because it keeps !#%!#$ timing out&quot;&quot;&quot;
     sudo(&quot;apt-get -y update&quot;)
@@ -187,7 +229,94 @@ def _demisauce_pre_reqs():
     sudo('easy_install http://gdata-python-client.googlecode.com/files/gdata.py-1.1.1.tar.gz')
     sudo('easy_install http://boto.googlecode.com/files/boto-1.8d.tar.gz')
 
+def _exists(path):
+    with settings(
+        hide('warnings', 'running', 'stdout', 'stderr'),
+        warn_only=True
+    ):
+        if run(&quot;[ -d %s ] &amp;&amp; echo $? &quot; % path) == '0':
+            return True
+        else:
+            #run('ls /etc/redhat-release'):
+            return False
+
+def _redis_restart():
+    if run('ps -A | grep redis-server'):
+        print(&quot;Redis already running &quot;)
+        # this doesn't work, try the init-functions 
+        #sudo(&quot;kill `ps -A | grep redis-server | cut -b2-5`&quot;)
+    else:
+        if run('ls /var/run | grep redis.pid'):
+            # dead pid file
+            sudo(&quot;rm /var/run/redis.pid&quot;)
+    # run the server
+    sudo('/opt/%(redis_version)s/redis-server %(path)s/redis/redis.conf' % env)
+
+def _redis_install():
+    &quot;&quot;&quot;install redis&quot;&quot;&quot;
+    with settings(
+        hide('warnings', 'running', 'stdout', 'stderr'),
+        warn_only=True
+    ):
+        if not run('ls /opt | grep %(redis_version)s' % env):
+            with cd(&quot;/opt&quot;):
+                print(&quot;----  installing redis   ----------&quot;)
+                sudo(&quot;wget http://redis.googlecode.com/files/redis-1.02.tar.gz; tar xvzf redis*.tar.gz&quot;)
+                sudo(&quot;rm redis*.tar.gz; cd redis*; make&quot;)
+        with cd('/vol'): #/home/demisauce
+            if not run('ls | grep redis'):
+                sudo('mkdir -p redis', pty=True)
+            if not run('ls redis | grep data'):
+                sudo('mkdir -p redis/data', pty=True)
+                sudo('chown demisauce redis')
+
+def _redis_conf_update():
+    put('%(local_path)s/install/recipes/vol/redis/redis.conf' % env, '/vol/redis/redis.conf')
+
+def _supervisord_install():
+    sudo(&quot;easy_install supervisor&quot;)
+    
+
 #   Tasks   =======================
+def _x_supervisor_update():
+    &quot;&quot;&quot;Refresh conf file for supervisord, restart&quot;&quot;&quot;
+    put('%(local_path)s/install/recipes/etc/supervisord.conf' % env, '/tmp/supervisord.conf' % env)
+    sudo('mv /tmp/supervisord.conf /etc/supervisord.conf')
+    #sudo('/usr/local/bin/supervisord')
+    sudo('/etc/init.d/supervisord restart')
+
+def add_sources():
+    &quot;&quot;&quot;This often times out, so run it first&quot;&quot;&quot;
+    # sources for nginx
+    sudo('echo &quot;deb http://ppa.launchpad.net/jdub/devel/ubuntu hardy main&quot; &gt;&gt; /etc/apt/sources.list')
+    #sudo(&quot;&quot;&quot;echo &quot;deb http://ppa.launchpad.net/jdub/devel/ubuntu hardy main&quot; &gt;&gt; /etc/apt/sources.list
+    #    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E9EEF4A1&quot;&quot;&quot;)
+    _gearman_sources()
+    
+    with settings(hide('warnings'),warn_only=True):
+        # key for nginx
+        keeptrying, attempt = True, 1
+        while keeptrying == True:
+            print(&quot;about to try to get key, may take a while or time out, attempt #%s&quot; % attempt)
+            attempt += 1
+            output = sudo(&quot;apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1C73E014&quot;)
+            #print(&quot;just ran, .failed = %s, .return_code = %s,  string=%s&quot; % (output.failed,output.return_code,output))
+            keeptrying = output.failed
+        
+        # key for gearman
+        keeptrying, attempt = True, 1
+        while keeptrying == True:
+            print(&quot;about to try to get key, may take a while or time out, attempt #%s&quot; % attempt)
+            attempt += 1
+            output = sudo('apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E9EEF4A1')
+            #print(&quot;just ran, .failed = %s, .return_code = %s,  string=%s&quot; % (output.failed,output.return_code,output))
+            keeptrying = output.failed # if failed = True, keep trying
+            
+    env.keys_added = True
+    
+    # do update before getting keys
+    sudo(&quot;apt-get -y --force-yes update&quot;)
+
 def release(userdbpwd):
     'Deploy a new/updated release to the target environment'
     _nginx_release()
@@ -208,14 +337,20 @@ def release(userdbpwd):
     sudo(&quot;/etc/init.d/nginx restart&quot;)
 
 def simple_push():
-    &quot;&quot;&quot;Simple release, just web sync&quot;&quot;&quot;
-    rsync_project('/home/demisauce/ds/current_web/',local_dir='%(local_path)s/demisauce/trunk' % env)
+    &quot;&quot;&quot;Simple release, just web sync, no new folders&quot;&quot;&quot;
+    rsync_project('/home/demisauce/ds/current_web/',local_dir='%(local_path)s/demisauce/trunk/' % env)
     restart_web()
 
+def sync_etc():
+    &quot;&quot;&quot;Configuration Sync&quot;&quot;&quot;
+    rsync_project('/home/demisauce/',local_dir='%(local_path)s/install/recipes/etc' % env)
+    
+
 def db_backup_apply():
     &quot;&quot;&quot;Apply a backup &quot;&quot;&quot;
     require(&quot;mysql_root_pwd&quot;)
-    sudo(&quot;mysql -uroot -pdemisauce &lt; /home/demisauce/ds/current/backup-file.sql &quot;)
+    print(&quot;Mysql_root_pwd = %s&quot; % env.mysql_root_pwd)
+    #sudo(&quot;mysql -uroot -p%(mysql_root_pwd)s &lt; /home/demisauce/ds/current/backup-file.sql &quot; % env)
 
 def release_nginx():
     &quot;&quot;&quot;Updates nginx config, and restarts
@@ -238,24 +373,41 @@ def db_sqldump(pwd):
     &quot;&quot;&quot;Takes a full sql dump&quot;&quot;&quot;
     sudo(&quot;mysqldump -uroot -p%s demisauce &gt; backup-file.sql&quot; % pwd)
 
-def build_step1(rootmysqlpwd=&quot;demisauce&quot;,userdbpwd=&quot;demisauce&quot;):
-    &quot;&quot;&quot;Build base demisauce linux install, then manually run::
+def build(rootmysqlpwd=&quot;demisauce&quot;,userdbpwd=&quot;demisauce&quot;):
+    &quot;&quot;&quot;base linux install, then manually run::
         apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1C73E014
         as it will timeout
     &quot;&quot;&quot;
-    require('hosts', provided_by=[vm107,vm106,ec2prod])
+    sudo(&quot;apt-get -y install rsync&quot;)
+    sync_etc() # do this first to force rsynch/ssh pwd at beginning to it doesn't 255 error timeout
+    
+    add_sources()
     _linux_base()
+    # this would only work if we have a more persistent &quot;state&quot; across runs
+    #if not env.keys_added:
+    #    print(&quot;You need to run add_sources first, as it times out quite often we do that first in case it times out&quot;)
+    #    return
     _gearman()
-
-def build_step2(rootmysqlpwd=&quot;demisauce&quot;,userdbpwd=&quot;demisauce&quot;):
-    &quot;&quot;&quot;Step two updating keys, installs gearman,mysql,memcached,nginx, python dependencies&quot;&quot;&quot;
-    require('hosts', provided_by=[vm107,vm106,ec2prod])
-    _gearman_step2()
     _memcached()
+    _postfix()# must be installed before zamanda which installs it in interactive mode
     _mysql(rootmysqlpwd,userdbpwd)
     _zamanda(userdbpwd)
     _nginx()
     _demisauce_pre_reqs()
+    _redis_install()
+    _redis_conf_update()
+    _supervisord_install()
+    sudo(&quot;rsync  -pthrvz  /home/demisauce/etc /&quot;) #redis, nginx, supervisor init.d and .conf files
+    #supervisor_update() # also starts supervisord
+    sudo('/etc/init.d/supervisord restart')
+    sudo('sudo update-rc.d supervisord defaults')
+    
+def all(rootmysqlpwd=&quot;demisauce&quot;,userdbpwd=&quot;demisauce&quot;):
+    &quot;&quot;&quot;Build AND Release&quot;&quot;&quot;
+    build(rootmysqlpwd=rootmysqlpwd,userdbpwd=userdbpwd)
+    release(userdbpwd=userdbpwd)
+
+
 
 
 </diff>
      <filename>install/fabfile.py</filename>
    </modified>
    <modified>
      <diff>@@ -178,7 +178,7 @@ else
     #paster serve --daemon production.ini
     echo &quot;-----  Creating cron job to restart paster if it fails -----------&quot;
     cat &lt;&lt;EOL &gt; /var/spool/cron/crontabs/root.tmp
-*/2 * * * * /etc/init.d/demisauce_web start
+*/5 * * * * /etc/init.d/demisauce_web start
 EOL
     crontab /var/spool/cron/crontabs/root.tmp
 fi</diff>
      <filename>install/install_demisauce.sh</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ NAME=demisauce
 DEMISAUCE_HOME=&quot;/home/demisauce/ds/current_web/&quot;
 DESCRIPTION=&quot;Demisauce Pylons/Paster app&quot;
 PIDSPATH=$DEMISAUCE_HOME
-PS=$NAME              #the process, which happens to be the NAME
+PS=&quot;python&quot;           #the process, which happens to be python for some reason
 PIDFILE=$NAME.pid     #pid file
 RUNAS=root            #user to run as
 SCRIPT_OK=0           #ala error codes</diff>
      <filename>install/install_initd.sh</filename>
    </modified>
    <modified>
      <diff>@@ -133,8 +133,9 @@ echo &quot;---- making changes to /etc/mysql/my.cnf  &quot;
 perl -pi -e &quot;s/\/var\/lib\/mysql/$escaped_mysql_home/g&quot; /etc/mysql/my.cnf || die &quot;could not change my.cnf&quot;
 perl -pi -e &quot;s/\/tmp/\/vol\/tmp/g&quot; /etc/mysql/my.cnf || die &quot;could not change my.cnf&quot;
 perl -pi -e &quot;s/skip\-external\-locking/skip\-external\-locking\nlog\-bin/g&quot; /etc/mysql/my.cnf || die &quot;could not change my.cnf&quot;
-cat &gt; /etc/mysql/conf.d/mysql-ec2.cnf &lt;&lt;EOM
+cat &gt; /etc/mysql/conf.d/demisauce.cnf &lt;&lt;EOM
 [mysqld]
+default-storage-engine = InnoDB
 innodb_file_per_table
 datadir          = /vol/lib/mysql
 log_bin          = /vol/log/mysql/mysql-bin.log</diff>
      <filename>install/install_mysql.sh</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>install/install_func.sh</filename>
    </removed>
    <removed>
      <filename>install/install_wordpress.sh</filename>
    </removed>
    <removed>
      <filename>install/nginx/mime.types</filename>
    </removed>
    <removed>
      <filename>install/nginx/nginx.conf</filename>
    </removed>
    <removed>
      <filename>install/nginx/sites-available/default</filename>
    </removed>
    <removed>
      <filename>install/nginx/sites-enabled/demisauce</filename>
    </removed>
    <removed>
      <filename>install/rabbitmq.sh</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>9a6d61915bfa8c09ff7b7fb89316686e13d6ca20</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Raddon</name>
    <email>araddon@yahoo.com</email>
  </author>
  <url>http://github.com/araddon/demisauce/commit/dd4d375c0af90f87c3595eae042f128d6d6890ef</url>
  <id>dd4d375c0af90f87c3595eae042f128d6d6890ef</id>
  <committed-date>2009-11-05T19:40:28-08:00</committed-date>
  <authored-date>2009-11-05T19:40:28-08:00</authored-date>
  <message>adding redis, supervisord, fixing a few bugs in installer</message>
  <tree>3f98ec5d9a9e9f19f48b90edc69ca0145d48d2c7</tree>
  <committer>
    <name>Aaron Raddon</name>
    <email>araddon@yahoo.com</email>
  </committer>
</commit>
