Beispiel #1
0
def hostname():
    hostname = ''
    while (hostname == ''):
        hostname = (click.prompt(message.info('Input hostname', True), type=str)).strip(' \t\n\r')

        if hostname == '':
            message.error('Hostname required! try again')
            continue
        else:
            return hostname
Beispiel #2
0
def project_type():
    try:
        print('1 : MVC')
        print('2 : NORMAL')
        project_type = click.prompt(message.info(
            'Input project type', True), type=int, default=2)
    except ValueError:
        project_type = 2

    if project_type == 1:
        return 'try_files $uri $uri/ /index.php?$query_string;'
    return 'try_files $uri $uri/ =404;'
Beispiel #3
0
def root_dir():
    while True:
        root = click.prompt(message.info(
            'Input site Root Folder', True), type=str, default='/var/www/html/')

        if root[-1:] == '/':
            root = root[:-1]

        if not os.path.isdir(root):
            print('%s folder not found\n'%root)
            continue
        else:
            return root.strip()
Beispiel #4
0
from modules.constants import (BASE_PATH, NGINX_CONF_FILE,
                               NGINX_SITES_CONF_FILE, NGINX_SITES_ENABLED,
                               HOSTS_FILE)

# if __name__ == "__main__":
#     if os.getenv("SUDO_USER") == None:
#         message.error('Please start the script as root!', False, True)
# else:
#     message.error('Script exit!', False, True)

if len(sys.argv) == 3:
    args = sys.argv
    if args[1].lower() == '--delete':
        hostname = args[2]
        answer = str(
            input(message.info('Remove virtual host?', True) + '[y/N]:'))
        if answer.lower() == 'y':
            if os.path.exists(NGINX_SITES_CONF_FILE % (hostname)):
                os.system('sudo rm /etc/nginx/sites-*/' + hostname + '.conf')
            host.delete(HOSTS_FILE, hostname)
            host.restart()
            message.success('Virtual host successfully removed', False, True)
        else:
            message.info('bye', False, True)
    else:
        message.error('Parameters are missing')
        message.info('What do you mean?')
        message.success('\t --delete %s' % (args[2]), False, True)

if os.path.exists(NGINX_CONF_FILE):
    with open(NGINX_CONF_FILE, 'r') as file:
Beispiel #5
0
def phpfpm_version():
    version = (click.prompt(message.info(
            'Input php-fpm:', True), type=str, default=DEFAULT_PHP_FPM_VERSION)).strip(' \t\n\r')
    return version