Apache

by linode
1 deployments · 1 still active · last rev. 1 year ago

Installs Apache on a Linode. Can also be used as a library for other StackScripts.

Compatible with: CentOS 7, Debian 7, Debian 8, Ubuntu 14.04 LTS
						#!/usr/bin/env python

"""
Apache Web Server (httpd) StackScript
	
	Author: Ricardo N Feliciano <rfeliciano@linode.com>
	Version: 1.0.0.0
	Requirements:
		- ss://linode/python-library <ssinclude StackScriptID="3">

This StackScript both deploys as well as provides a library of functions for
the Apache Web Server (httpd). The functions in this StackScript are designed
to be run across the Linode Core Distributions:
	- Ubuntu
	- CentOS
	- Debian
	- Fedora
"""

import os
import subprocess
import sys

try: # we need to rename the included StackScript before we can import it
	os.rename("/root/ssinclude-3", "/root/pythonlib.py")
except:
	pass

import pythonlib


def httpd_install(start=True):
	"""Install Apache Web Server (httpd)"""
	# add logging support

	package = {
		'debian': 'apache2',
		'redhat': 'httpd'
	}

	pythonlib.system_package_install(package[pythonlib.distro['family']])

	if(pythonlib.distro['family']=="redhat" and start):
		subprocess.call(["systemctl", "start", "httpd"])


def httpd_site_enable():
	"""Add a virtual host configuration to Apache httpd."""
	# add logging support

	# this doesn't do anything yet


#def httpd_mod_enable(mod):
#	"""Enable `mod` in Apache.
#	
#	Args:
#		mod String: module to enable. Name should be what you would give the
#		a2enmod command.
#	"""
#	# add logging support
#
#	if
#
#	This function has been delayed until a proper x-platform solution is made.


def main():
	"""Install Apache httpd."""
	# add logging support
	
	pythonlib.init()
	pythonlib.system_update()
	httpd_install()

	pythonlib.end()


if __name__ == "__main__":
	sys.exit(main())