Initial import

by webvouchercodes
2 deployments · 0 still active · last rev. 5 months ago

performs the commen actions I link to take on a new deployment

Compatible with: Arch 2017.04.01, CentOS 7, Debian 8, Gentoo 2017-01-05, openSUSE Leap 42.2, Slackware 14.2, Ubuntu 16.04 LTS, Ubuntu 16.10, CentOS 6.8, Debian 7, Fedora 24, openSUSE Leap 42.1, Slackware 13.37, Slackware 14.1, Ubuntu 12.04 LTS, Ubuntu 14.04 LTS, Slackware 13.37 32bit
						#!/usr/bin/env python

"""
LAMP StackScript
    
    Author: Ricardo N Feliciano <rfeliciano@linode.com>
    Version: 1.0.0.0
    Requirements:
        - ss://linode/python-library <ssinclude StackScriptID="3">
        - ss://linode/apache <ssinclude StackScriptID="5">
        - ss://linode/mysql <ssinclude StackScriptID="7">
        - ss://linode/php <ssinclude StackScriptID="8">

This StackScript both deploys and provides a library of functions for
creating a LAMP stack. The functions in this StackScript are designed to be 
run across Linode's core distributions:
    - Ubuntu
    - CentOS
    - Debian
    - Fedora

StackScript User-Defined Variables (UDF): 

<UDF name="db_root_password" label="MySQL/MariaDB root password" />
<UDF name="db_name" label="Create Database" default="" example="create this empty database" />
"""

import os
import sys

try: # we'll need to rename included StackScripts before we can import them
    os.rename("/root/ssinclude-3", "/root/pythonlib.py")
    os.rename("/root/ssinclude-5", "/root/apache.py")
    os.rename("/root/ssinclude-7", "/root/mysql.py")
    os.rename("/root/ssinclude-8", "/root/php.py")
except:
    pass

import pythonlib
import apache
import mysql
import php


def main():
    """Install Apache, MySQL/MariaDB, and PHP."""
    # add logging support
    pythonlib.init()
    
    if os.environ['DB_ROOT_PASSWORD'] != "":
        db_root_password = os.environ['DB_ROOT_PASSWORD']
    else:
        db_root_password = False
    
    if os.environ['DB_NAME'] != "":
        db_name = os.environ['DB_NAME']
    else:
        db_name = False

    pythonlib.system_update()
    apache.httpd_install()
    mysql.mysql_install(db_root_password, db_name)
    php.php_install()
    php.php_install_module_common()

    pythonlib.end()


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