Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nginx 0.7.65 installer for Webfaction
-----BEGIN WEBFACTION INSTALL SCRIPT-----
#!/bin/env python2.4
"""
Nginx 0.7.65 Installer New
"autostart": not applicable
"extra info": Enter domain name for the nginx app
"""
import sys
from webfaction.api import *
def create(api, app_name, app_domain):
#Create app
app = api.create_app(app_name, 'custom_app_with_port')
#Retrieve, extract
cmd = """\
wget http://sysoev.ru/nginx/nginx-0.7.65.tar.gz > /dev/null 2>&1;
tar -xzf nginx-0.7.65.tar.gz
"""
api.system(cmd)
#Configure, make, install, remove
cmd = """\
cd nginx-0.7.65
./configure --prefix=$HOME/webapps/%s --with-http_ssl_module
make && make install
cd ..
rm -fr nginx-0.7.65*
""" % (app_name)
api.system(cmd)
#Edit Nginx config
cmd = """\
sed -i 's/listen 80/listen %s/' $HOME/webapps/%s/conf/nginx.conf
sed -i 's/localhost/%s/' $HOME/webapps/%s/conf/nginx.conf
""" % (app['port'], app_name, app_domain, app_name)
api.system(cmd)
cmd = """\
cd ~/webapps/%s
./sbin/nginx
""" % (app_name)
api.system(cmd)
print app['id']
def delete(api, app_name, app_domain):
# Delete app
api.delete_app(app_name)
if __name__ == '__main__':
action, username, password, server, app_name, autostart, extra_info = \
sys.argv[1:]
api = API(username, password, server)
if extra_info:
app_domain = extra_info
else:
app_domain = 'www.example.com'
try:
locals()[action](api, app_name, app_domain)
except APIError, e:
print e
sys.exit()
-----END WEBFACTION INSTALL SCRIPT-----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.