Custom CakePHP install script for WebFaction

In: development|startup

13 Jul 2009

The WebFaction install script for CakePHP (at http://wiki.webfaction.com/wiki/InstallScripts) was a bit outdated so I modified it for CakePHP 1.2.3.8166. Enjoy!

Update: Apparently WordPress wasn’t displaying the code correctly. I’ve saved the file locally so you can install it just by clicking here.

#!/usr/local/bin/python2.5

"""
CakePHP 1.2.3.8166

Notes:
-If CakePHP isn't going to be web accessible at / you'll need to update the following line in ~/webapps/(Application Name)/.htaccess accordingly:

RewriteBase /

"autostart": "not applicable"
"extra info": "leave empty"

"""

import sys
import xmlrpclib

def create(app_name, server, session_id):
app = server.create_app(session_id, app_name, 'static', False, '')

# Download, extract, and organize.
cmd = (
'wget http://cakeforge.org/frs/download.php/717/cake_1.2.3.8166.tar.gz/donation=complete -O cake_1.2.3.8166.tar.gz > /dev/null 2>&1;'
'tar fxz cake_1.2.3.8166.tar.gz;'
'mv --target-directory=. cake_1.2.3.8166/* cake_1.2.3.8166/.htaccess;'
)
server.system(session_id, cmd)

str = (
'RewriteEngine onn'
'RewriteBase /n'
'RewriteRule ^$ app/webroot/ [L]n'
'RewriteRule (.*) app/webroot/$1 [L]n'
)
server.write_file(session_id, '.htaccess', str)

# Clean Up
server.system(session_id, 'rm -fr cake_1.2.3.8166/ cake_1.2.3.8166.tar.gz index.html')

print app['id']

def delete(app_name, server, session_id):
server.delete_app(session_id, app_name)

if __name__ == '__main__':
action, username, password, machine, app_name, autostart, extra_info = sys.argv[1:]
server = xmlrpclib.Server('https://api.webfaction.com/')
session_id, account = server.login(username, password, machine)

locals()[action](app_name, server, session_id)

Comment Form

About this blog

I'm Jon Chin. I love technology, food, and learning. I served a mission in the Philippines and loved it. You probably can't type on my keyboard because I don't have qwerty installed--I use Colemak. I'm obsessed with learning about North Korea and abandoned anything.

Photostream