Ejemplo n.º 1
0
def create_www_user():
    global domain, homeRoot
    if (basics.command("grep --quiet \"" + domain + "\" /etc/passwd")):
        basics.command(
            "adduser --force-badname --disabled-password --gecos \"\" --home \""
            + homeRoot + "/" + domain + "\" --shell /bin/bash \"" + domain +
            "\"")
        #basics.command("usermod --append --groups  www-data")
        basics.command("usermod --append --groups www-data \"" + domain + "\"")
Ejemplo n.º 2
0
def create_www_home():
	global domain, homeRoot
	print  colored("create www home", 'red')
	path = homeRoot + "/" + domain
	basics.make_ordner(path + "/htdocs")
	basics.make_ordner(path + "/tmp")
	basics.make_ordner(path + "/config")
	basics.make_ordner(path + "/logs")
	basics.command("chown --recursive \""+domain+":"+domain+"\" \""+homeRoot+"/"+domain+"\"")
	basics.command("chmod 755 --recursive \""+homeRoot+"/"+domain+"\"")
Ejemplo n.º 3
0
def create_www_home():
    global domain, homeRoot
    print colored("create www home", 'red')
    path = homeRoot + "/" + domain
    basics.make_ordner(path + "/htdocs")
    basics.make_ordner(path + "/tmp")
    basics.make_ordner(path + "/config")
    basics.make_ordner(path + "/logs")
    basics.command("chown --recursive \"" + domain + ":" + domain + "\" \"" +
                   homeRoot + "/" + domain + "\"")
    basics.command("chmod 755 --recursive \"" + homeRoot + "/" + domain + "\"")
Ejemplo n.º 4
0
def add_phpfpm_conf():
	global domain, homeRoot, fpmPort
	print  colored("add php fpm conf", 'red')
	if not(basics.check_file("/etc/php5/fpm/pool.d/",domain + ".conf")):
		templateFile = open("templates/php-fpm_conf.txt", "r")
		template = templateFile.read();
		templateFile.close();
		template = template.replace("[root_path]",homeRoot);
		template = template.replace("[domain]",domain);
		template = template.replace("[port]",str(fpmPort));
		configFile = open("/etc/php5/fpm/pool.d/" + domain + ".conf", "w")
		configFile.write(template)
		configFile.close();
	basics.command("service php5-fpm force-reload")
Ejemplo n.º 5
0
def add_phpfpm_conf():
    global domain, homeRoot, fpmPort
    print colored("add php fpm conf", 'red')
    if not (basics.check_file("/etc/php5/fpm/pool.d/", domain + ".conf")):
        templateFile = open("templates/php-fpm_conf.txt", "r")
        template = templateFile.read()
        templateFile.close()
        template = template.replace("[root_path]", homeRoot)
        template = template.replace("[domain]", domain)
        template = template.replace("[port]", str(fpmPort))
        configFile = open("/etc/php5/fpm/pool.d/" + domain + ".conf", "w")
        configFile.write(template)
        configFile.close()
    basics.command("service php5-fpm force-reload")
Ejemplo n.º 6
0
def move_folder(domain, homeRoot):
    basics.make_ordner("/home/removed")
    basics.command("mv \"" + homeRoot + "/" + domain + "\" \"" + homeRoot +
                   "/removed/" + domain + "_" + str(time.time()) + "\"")
Ejemplo n.º 7
0
# argumente auswerten

parser = argparse.ArgumentParser(description='Anlegen einer neuen Domain')
#parser.add_argument("-h", help="print this help")
parser.add_argument("-n",
                    "--home",
                    help="home root path. default: \"/home\"",
                    default="/home")
parser.add_argument("-d", "--domain", help="domain name", required=True)
#parser.add_argument("-o", "--overwrite", help="overwrite existent files", action="store_true", default=False)
args = vars(parser.parse_args())

domain = args["domain"]
homeRoot = args["home"]
#verwrite = args["overwrite"]

if check_if_vhost(domain):
    deactivate_vhost(domain)
    print("deaktivate vhost")
    basics.command("service apache2 reload")
    print("service apache2 reload")
    remove_configs(domain)
    print("remove configs")
    basics.command("service php5-fpm reload")
    print("service php5-fpm reload")
    move_folder(domain, homeRoot)
    print("move folder")
    delete_user(domain)  # delete user with home dir
    print("delete user")
else:
    print("value is no valid vhost")
Ejemplo n.º 8
0
def lets_encrypt():
    global domain, homeRoot
    basics.command("certbot --apache certonly --webroot -w " + homeRoot +
                   " -d " + domain)
Ejemplo n.º 9
0
def remove_configs(domain):
	if (basics.check_file("/etc/php5/fpm/pool.d/",domain + ".conf")):
		basics.command("rm " + "/etc/php5/fpm/pool.d/" + domain + ".conf")
	if (basics.check_file("/etc/apache2/sites-available/",domain + ".conf")):
		basics.command("/etc/apache2/sites-available/" + domain + ".conf")
Ejemplo n.º 10
0
def move_folder(domain, homeRoot):
	basics.make_ordner("/home/removed")
	basics.command("mv \""+homeRoot+"/"+domain+"\" \""+homeRoot+"/removed/"+domain+"_"+ str(time.time()) +"\"")
Ejemplo n.º 11
0
def delete_user(domain):
    basics.command("userdel -r -f " + domain)
Ejemplo n.º 12
0
def verbose_command(cmd):
	print  colored("command:", 'cyan'), colored(cmd, 'magenta')
	basics.command(cmd)
Ejemplo n.º 13
0
#!/usr/bin/python3.4
#
# written by David Bauer, initial start 17.09.2014
# 
import helper.basic as basics
import sys

# erstma updaten
print("sourcen updaten")
basics.command("aptitude -y update 1>/dev/null")
print("sourcen geupdatet")

# add more cool tools
basics.command("aptitude install apache2-mpm-worker")
basics.command("aptitude install apache2-utils libapache2-mod-fastcgi")
basics.command("aptitude install php5-fpm")
basics.command("a2enmod actions ssl rewrite auth_digest proxy")
basics.command("service apache2 restart")

#basics.command('echo "apache2-mpm-worker 2.4 (sid), php5-fpm 5.6 (sid) and fastcgi setup" >> /etc/motd')
#basics.command('echo "apache2-mpm-worker, php5-fpm and fastcgi setup" >> /etc/motd')
#basics.command('echo "by david bauer aka debauer - [email protected]" >> /etc/motd')
#basics.command('echo "" >> /etc/motd')
#basics.command('echo "USAGE:" >> /etc/motd')
#basics.command('echo "- do not install change anything relatet to this packages!" >> /etc/motd')
#basics.command('echo "- use setup_domain.py script to add new vHosts. location: /root/scripts" >> /etc/motd')
Ejemplo n.º 14
0
def restart_services():
    basics.command("service apache2 reload")
    basics.command("service php5-fpm force-reload")
Ejemplo n.º 15
0
def enable_apache_site():
    global domain
    basics.command("/usr/sbin/a2ensite " + domain)
    basics.command("service apache2 reload")
Ejemplo n.º 16
0
def deactivate_vhost(domain):
    basics.command("/usr/sbin/a2dissite " + domain)
Ejemplo n.º 17
0
def remove_configs(domain):
    if (basics.check_file("/etc/php5/fpm/pool.d/", domain + ".conf")):
        basics.command("rm " + "/etc/php5/fpm/pool.d/" + domain + ".conf")
    if (basics.check_file("/etc/apache2/sites-available/", domain + ".conf")):
        basics.command("/etc/apache2/sites-available/" + domain + ".conf")
Ejemplo n.º 18
0
def lets_encrypt():
	global domain, homeRoot
	basics.command("certbot --apache certonly --webroot -w " + homeRoot + " -d " + domain )
Ejemplo n.º 19
0
	else:
		return False

# argumente auswerten

parser = argparse.ArgumentParser(description='Anlegen einer neuen Domain')
#parser.add_argument("-h", help="print this help")
parser.add_argument("-n", "--home", help="home root path. default: \"/home\"", default="/home")
parser.add_argument("-d", "--domain", help="domain name", required=True)
#parser.add_argument("-o", "--overwrite", help="overwrite existent files", action="store_true", default=False)
args = vars(parser.parse_args())

domain = args["domain"]
homeRoot = args["home"]
#verwrite = args["overwrite"]

if check_if_vhost(domain):
	deactivate_vhost(domain)
	print("deaktivate vhost")
	basics.command("service apache2 reload")
	print("service apache2 reload")
	remove_configs(domain)
	print("remove configs")
	basics.command("service php5-fpm reload")
	print("service php5-fpm reload")
	move_folder(domain, homeRoot)
	print("move folder")
	delete_user(domain) # delete user with home dir
	print("delete user")
else:
	print("value is no valid vhost")
Ejemplo n.º 20
0
def enable_apache_site():
	global domain
	basics.command("/usr/sbin/a2ensite " + domain)
	basics.command("service apache2 reload")
Ejemplo n.º 21
0
def deactivate_vhost(domain):
	basics.command("/usr/sbin/a2dissite " + domain)
Ejemplo n.º 22
0
def restart_services():
	basics.command("service apache2 reload")
	basics.command("service php5-fpm force-reload")
Ejemplo n.º 23
0
def delete_user(domain):
	basics.command("userdel -r -f " + domain)
Ejemplo n.º 24
0
def create_www_user():
	global domain, homeRoot
	if(basics.command("grep --quiet \"" + domain + "\" /etc/passwd")):
		basics.command("adduser --force-badname --disabled-password --gecos \"\" --home \""+ homeRoot + "/" + domain +"\" --shell /bin/bash \"" + domain + "\"")
		#basics.command("usermod --append --groups  www-data")
		basics.command("usermod --append --groups www-data \""+ domain +"\"")