Example #1
0
def sfs_install():
	""" Install SmartFoxServer Pro v.1.6.6 """

	if not _java_is_installed():
		fabric.api.warn(fabric.colors.yellow('Sun Java6 JDK must be installed'))
		return
	
	if _sfs_is_installed():
		fabric.api.warn(fabric.colors.yellow('SmartFoxServer Pro is already installed'))
		return

	# Get SmartFoxServer Pro
	sfs_filename = 'SFSPRO_linux64_1.6.6'
	with fabric.api.cd('/srv'):
		fabric.api.run('wget http://www.smartfoxserver.com/products/download.php?d=77 -O %s.tar.gz' % sfs_filename)
		fabric.api.run('gzip -d %s.tar.gz' % sfs_filename)
		fabric.api.run('tar xf %s.tar'     % sfs_filename)
	
	# Install SmartFoxServer Pro
	with fabric.api.cd('/srv/SmartFoxServer_PRO_1.6.6'):
		fabric.api.run('./install')
	
	# Install the 64-bit wrapper
	with fabric.api.cd('/srv'):
		fabric.api.run('wget http://www.smartfoxserver.com/download/wrapper/wrapper_linux64.zip')
		package_install(['unzip'],"--no-install-recommends")
		fabric.api.run('cp linux64/libwrapper.so  /srv/%s/Server/lib' % (SFS_VERSION))
		fabric.api.run('cp linux64/wrapper.jar    /srv/%s/Server/lib' % (SFS_VERSION))
		fabric.api.run('cp linux64/wrapper        /srv/%s/Server/wrapper_64'  % (SFS_VERSION))
		fabric.api.run('mv /srv/%s/Server/wrapper /srv/%s/Server/wrapper_32'  % (SFS_VERSION))
		link('/srv/%s/Server/wrapper_64' % (SFS_VERSION),dest='/srv/%s/Server/wrapper' % (SFS_VERSION))
Example #2
0
def uwsgi_setup(stage=''):
	""" Setup uWSGI. """
	
	# Service script
	uwsgi_service_script = '/etc/init.d/uwsgi'
	if fabric.contrib.files.exists(uwsgi_service_script):
		fabric.api.sudo('mv %s %s.bkp' % (uwsgi_service_script, uwsgi_service_script))
	fabric.api.put(os.path.join(fabric.api.env.conf['FILES'], 'uwsgi_init.sh'), uwsgi_service_script, use_sudo=True)
	fabric.api.sudo('chmod 755 %s' % uwsgi_service_script)
	fabric.api.sudo('chown root:root %s' % uwsgi_service_script)

	# INI File
	fabric.api.sudo('mkdir -p /etc/uwsgi')
	uwsgi_file = '/etc/uwsgi/uwsgi.ini'
	if fabric.contrib.files.exists(uwsgi_file):
		fabric.api.sudo('mv %s %s.bkp' % (uwsgi_file, uwsgi_file))
	if stage:
		stage = '.%s' % stage
	link('/srv/active/deploy/uwsgi%s.ini' % stage, dest=uwsgi_file, 
		use_sudo=True, do_unlink=True, silent=True)

	# Log File
	fabric.api.sudo('mkdir -p /var/log/uwsgi')
	fabric.api.sudo('touch /var/log/uwsgi/errors.log')
	fabric.api.sudo('chmod -R a+w /var/log/uwsgi')

	# Set up startup
	with fabric.api.cd('/etc/rc2.d'):
		link('/etc/init.d/uwsgi','S80uwsgi',use_sudo=True,do_unlink=True,silent=True)
Example #3
0
def redis_setup(stage=""):
    """ Setup redis. """
    redis_file = "/etc/redis/redis.conf"
    if fabric.contrib.files.exists(redis_file):
        fabric.api.sudo("mv %s %s.bkp" % (redis_file, redis_file))
    if stage:
        stage = ".%s" % stage
    link("/srv/active/deploy/redis%s.conf" % stage, dest=redis_file, use_sudo=True, do_unlink=True, silent=True)
Example #4
0
def apache_setup(stage=''):
	""" Setup apache. """
	apache_file = '/etc/apache2/httpd.conf'
	if fabric.contrib.files.exists(apache_file):
		fabric.api.sudo('mv %s %s.bkp' % (apache_file,apache_file))
	if stage:
		stage = '.%s' % stage
	link('/srv/active/deploy/httpd%s.conf' % stage, dest=apache_file,
		use_sudo=True, do_unlink=True, silent=True)
Example #5
0
def virtualenv_create(dir='/srv/active/',site_packages=True):
	""" 
	Create a virtual environment in the /<dir>/env/ directory
	"""
	if site_packages:
		fabric.api.run('virtualenv %s' % os.path.join(dir,'env/'))
	else:
		fabric.api.run('virtualenv --no-site-packages %s' % os.path.join(dir,'env/'))
	link('env/bin/activate',do_unlink=True,silent=True)
Example #6
0
def nginx_setup(stage=''):
	""" Setup nginx. """
	nginx_file = '/etc/nginx/nginx.conf'
	if fabric.contrib.files.exists(nginx_file):
		fabric.api.sudo('mv %s %s.bkp' % (nginx_file,nginx_file))
	if stage:
		stage = '.%s' % stage
	link('/srv/active/deploy/nginx%s.conf' % stage, dest=nginx_file,
		use_sudo=True, do_unlink=True, silent=True)
Example #7
0
def sfs_setup():
	""" Setup SmartFoxPro Server """
	# Link the config file
	sfs_config = '/srv/%s/Server/config.xml' % (SFS_VERSION)
	if fabric.contrib.files.exists(sfs_config):
		fabric.api.run('mv %s %s.bkp' % (sfs_config, sfs_config))
	link('/srv/active/deploy/config.xml',dest=sfs_config,do_unlink=True,silent=True)
	
	# Make smartfox a startup process
	link(SFS_PROGRAM, dest='/etc/rc2.d/S99sfs',use_sudo=True,do_unlink=True,silent=True)
Example #8
0
def virtualenv_create(dir='/srv/active/', site_packages=True):
    """ 
	Create a virtual environment in the /<dir>/env/ directory
	"""
    if site_packages:
        fabric.api.run('virtualenv %s' % os.path.join(dir, 'env/'))
    else:
        fabric.api.run('virtualenv --no-site-packages %s' %
                       os.path.join(dir, 'env/'))
    link('env/bin/activate', do_unlink=True, silent=True)
Example #9
0
def nginx_setup(stage=''):
    """ Setup nginx. """
    nginx_file = '/etc/nginx/nginx.conf'
    if fabric.contrib.files.exists(nginx_file):
        fabric.api.sudo('mv %s %s.bkp' % (nginx_file, nginx_file))
    if stage:
        stage = '.%s' % stage
    link('/srv/active/deploy/nginx%s.conf' % stage,
         dest=nginx_file,
         use_sudo=True,
         do_unlink=True,
         silent=True)
Example #10
0
def link_host(hostfile):
    """ Link the hostname to the host file """
    check_active()
    link(os.path.join('/srv/active/project/hosts', hostfile),
         os.path.join('/srv/active/project/hosts', '%s.py' % get_hostname()),
         do_unlink=True, silent=True)
Example #11
0
def make_active(tagname):
    """ Make a tag at /srv/<project>/<tagname>  active """
    link(os.path.join(fabric.api.env.conf['SRC_DIR'], tagname),
            '/srv/active', do_unlink=True, silent=True)
Example #12
0
def make_active(tagname):
    """ Make a tag at /srv/<project>/<tagname>  active """
    link(os.path.join(fabric.api.env.conf['SRC_DIR'], tagname),
         '/srv/active',
         do_unlink=True,
         silent=True)