Newer
Older
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import utils
def setup(interactive=True):
dir_path = utils.get_dir(__file__)
server_name = utils.get_conf('CACHE_SERVER_NAME') or 'cache'
source_server = utils.get_conf('CACHE_SOURCE') or 'http://undefined'
'apt-get remove -y apache2',
'apt-get install -y nginx',
'mkdir -p /var/www/cache',
'cp %s/index.html /var/www/cache/index.html' % dir_path,
'cp %s/crossdomain.xml /var/www/cache/crossdomain.xml' % dir_path,
'cp %s/nginx-limits.conf /etc/security/limits.d/nginx.conf' % dir_path,
'cp %s/vhost_cache.conf /etc/nginx/sites-available/cache.conf' % dir_path,
'sed -i "s@server_name cache;@server_name %s;@" "/etc/nginx/sites-available/cache.conf"' % server_name,
'sed -i "s@proxy_pass http://undefined;@proxy_pass %s;@" "/etc/nginx/sites-available/cache.conf"' % source_server,
'ln -sfn ../sites-available/cache.conf /etc/nginx/sites-enabled/cache.conf',
]
utils.run_commands(cmds)
utils.add_hosts_to_localhost([server_name])