Skip to content

Instantly share code, notes, and snippets.

@btbytes
Created August 21, 2008 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btbytes/6663 to your computer and use it in GitHub Desktop.
Save btbytes/6663 to your computer and use it in GitHub Desktop.
MoinMoin 1.7.1 install script for Webfaction
-----BEGIN WEBFACTION INSTALL SCRIPT-----
#!/usr/local/bin/python2.5
"""
MoinMoin-1.7.1.py install/uninstall script for WebFaction.
This installs the MoinMoin library in $HOME/lib/python2.5
and the MoinMoin CGI files in the webapp directory.
To prevent SPAM it removes the update rights for the anonymous
user and adds them for your username (you must create a MoinMoin
user with the same username in order to get these rights).
"autostart": not applicable
"extra info": leave empty
"""
"""
Command-line usage:
MoinMoin-1.7.1.py create|delete username pwd machine app_name autostart extra_info
"""
import xmlrpclib
import sys
def create(server, session_id, account, username, app_name, autostart, extra_info):
home_dir = "%s/%s" % (account['home'], username)
app_dir = '%s/webapps/%s' % (home_dir, app_name)
# Create a simple static/cgi/php application
new_app = server.create_app(session_id, app_name, 'static', False, '')
# Get tarball and untar it
cmd = """\
rm -f index.html
wget http://static.moinmo.in/files/moin-1.7.1.tar.gz > /dev/null 2>&1
tar xzvf moin-1.7.1.tar.gz > /dev/null 2>&1
cp -R moin-1.7.1/MoinMoin %(home_dir)s/lib/python2.4
cp moin-1.7.1/wiki/server/moin.cgi index.cgi
chmod 711 index.cgi .
cp moin-1.7.1/wiki/config/wikiconfig.py .
cp -R moin-1.7.1/wiki/data .
cp -R moin-1.7.1/wiki/underlay .
cp -R moin-1.7.1/wiki/htdocs wiki
""" % locals()
server.system(session_id, cmd)
server.replace_in_file(session_id, 'index.cgi', (
'/usr/bin/env python', '/usr/local/bin/python2.5'))
# Remove update rights for anonymous user and add them for your username
server.replace_in_file(session_id, 'wikiconfig.py', (
'#acl_rights_before = u"YourName:read,write,delete,revert,admin"',
'acl_rights_before = u"%(username)s:read,write,delete,revert,admin"\n acl_rights_default = u"All:read"' % locals()))
# We return the id of the new app
print new_app['id']
def delete(server, session_id, account, username, app_name, autostart, extra_info):
# Delete app
server.delete_app(session_id, app_name)
if __name__ == '__main__':
# Parse command line arguments
command, username, password, machine, app_name, autostart, extra_info = sys.argv[1:]
# Connect to API server
url = 'https://api.webfaction.com/'
server = xmlrpclib.ServerProxy(url)
# Login
session_id, account = server.login(username, password, machine)
# Call create or delete method
method = locals()[command] # create or delete
method(server, session_id, account, username, app_name, autostart, extra_info)
-----END WEBFACTION INSTALL SCRIPT-----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment