Beispiel #1
0
def install_nginx():
    """
    Install Nginx web-server
    """
    check_sudo()
    check_os()
    if not confirm('Do you want to install nginx?'):
        return
    print_green('INFO: Install nginx...')
    set_apt_repositories(NGINX_REPOSITORIES, NGINX_REPOS_INSTALL_KEYS_COMMANDS, subconf_name='nginx')
    apt_update()
    apt_install('nginx', noconfirm=True)
    user = prompt('Set user to nginx', default='www-data', validate='[\w\-]+')
    workers = prompt('Set worker_processes', default='1', validate='\d+')
    cmbs = prompt('Set client_max_body_size (MB)', default='32', validate='\d+')
    gzl = prompt('Set gzip_comp_level (set 0 to disable gzip)', default='1', validate='\d+')
    cfn = '/etc/nginx/nginx.conf'
    sed(cfn, r'user\s+nginx;', r'user  {};'.format(user), use_sudo=True)
    sed(cfn, r'worker_processes\s+[0-9]+;', r'worker_processes  {};'.format(workers), use_sudo=True, backup='')
    sed(cfn, r'http \{', (r'http \{\n\n'
                          r'    server_names_hash_bucket_size  64;\n'
                          r'    client_max_body_size           {cmbs}m;\n\n').replace('{cmbs}', cmbs),
        use_sudo=True, backup='')
    if gzl != '0':
        sed(cfn, r'\s+#\s*gzip  on;',
            (r'    gzip             on;\n'
             r'    gzip_proxied     any;\n'
             r'    gzip_comp_level  {gzl};\n'
             r'    gzip_min_length  1000;\n'
             r'    gzip_proxied     expired no-cache no-store private auth;\n'
             r'    gzip_types       text/plain text/javascript text/xml text/css application/x-javascript '
             r'application/javascript application/xml application/json image/svg+xml;\n'
             r'    gzip_disable     "msie6";\n'
             r'    gzip_vary        on;\n').format(gzl=gzl), use_sudo=True, backup='')
    print_green('INFO: Install nginx... OK')
Beispiel #2
0
def install_proftpd():
    """
    Install proftpd server
    """
    check_sudo()
    check_os()
    if not confirm('Do you want to install proftpd?'):
        return
    print_green('INFO: Install proftpd...')
    apt_install('proftpd', noconfirm=True)
    conf_fn = '/etc/proftpd/proftpd.conf'
    sudo('cp {fn} {fn}.bak'.format(fn=conf_fn), warn_only=True)
    sed(conf_fn, r'UseIPv6\s+on', r'UseIPv6\t\t\t\toff\nUseReverseDNS\t\t\toff', use_sudo=True, backup='')
    sn = prompt('Set ftp server name', default='MyFTPServer', validate=r'[\w\- ]+')
    sed(conf_fn, r'ServerName\s+".+"', r'ServerName\t\t\t"{}"'.format(sn), use_sudo=True, backup='')
    sed(conf_fn, r'TimeoutNoTransfer.+', r'TimeoutNoTransfer\t\t3600', use_sudo=True, backup='')
    sed(conf_fn, r'TimeoutStalled.+', r'TimeoutStalled\t\t\t3600', use_sudo=True, backup='')
    sed(conf_fn, r'TimeoutIdle.+', r'TimeoutIdle\t\t\t7200', use_sudo=True, backup='')
    uncomment(conf_fn, r'#\s*DefaultRoot', use_sudo=True, backup='')
    uncomment(conf_fn, r'#\s*RequireValidShell', use_sudo=True, backup='')  # todo uncomment only first value instead all
    uncomment(conf_fn, r'#\s*PassivePorts', use_sudo=True, backup='')
    t = (r'<Global>\n'
         r'    RootLogin off\n'
         r'</Global>\n'
         r'AuthUserFile /etc/proftpd/ftpd.passwd\n'
         r'<Directory ~/>\n'
         r'    HideFiles "(\\\\.ftpaccess)$"\n'
         r'</Directory>\n')
    sed(conf_fn, r'(# Include other custom configuration files)', r'{}\n\1'.format(t), use_sudo=True, backup='')
    print_green('INFO: Install proftpd... OK')
Beispiel #3
0
def install_supervisor():
    """
    Install supervisor daemon
    """
    check_sudo()
    check_os()
    if not confirm('Do you want to install supervisor?'):
        return
    print_green('INFO: Install supervisor...')
    apt_install('supervisor', noconfirm=True)
    print_green('INFO: Install supervisor... OK')
Beispiel #4
0
def install_postgresql(ver=None):
    """
    Install PostgreSQL server
    """
    # simple settings helper http://pgtune.leopard.in.ua/
    assert ver in SUPPORT_POSTGRESQL_VERSIONS or ver is None
    check_sudo()
    check_os()
    if not confirm('Do you want to install PostreSQL{}?'.format(
            ' {}'.format(ver) if ver else '')):
        return
    allow_versions = ', '.join(SUPPORT_POSTGRESQL_VERSIONS)
    while ver not in SUPPORT_POSTGRESQL_VERSIONS:
        ver = prompt(
            'Write PostgreSQL version you need ({}):'.format(allow_versions),
            default=SUPPORT_POSTGRESQL_VERSIONS[-1])
    print_green('INFO: Install PostreSQL {}...'.format(ver))
    set_apt_repositories(POSTGRESQL_REPOSITORIES,
                         POSTGRESQL_REPOS_INSTALL_KEYS_COMMANDS,
                         subconf_name='postgres')
    apt_update()
    apt_install(
        'postgresql-{ver} postgresql-server-dev-{ver} libpq-dev'.format(
            ver=ver),
        noconfirm=True)
    set_postgresql_user_password(
        'postgres', password_prompt('Set password to superuser postgres'))
    la = prompt(
        'Set listen_addresses (hostname or ip, comma separated; set * for all)',
        default='localhost',
        validate='[\w\.\-\*]+').strip()
    t = BytesIO()
    postgresql_conf = '/etc/postgresql/{}/main/postgresql.conf'.format(ver)
    get(postgresql_conf, local_path=t, use_sudo=True)
    t = BytesIO(
        re.sub(br"#listen_addresses = 'localhost'",
               r"listen_addresses = '{}'".format(la).encode(), t.getvalue()))
    put(t, postgresql_conf, use_sudo=True)
    sudo('chown postgres:postgres {}'.format(postgresql_conf))
    sudo('chmod 644 {}'.format(postgresql_conf))
    hba = '/etc/postgresql/{}/main/pg_hba.conf'.format(ver)
    sed(hba, r'(local\s+all\s+all\s+)peer', r'\1md5', use_sudo=True)
    if confirm('Do you want to allow connect to PostgreSQL from out?'):
        append(
            hba,
            'host     all             all             0.0.0.0/0               md5',
            use_sudo=True)
    install_postgis(postgres_ver=ver)
    if confirm('Do you want to restart PostgreSQL?'):
        service_restart('postgresql')
    print_green('INFO: Install PostreSQL {}... OK'.format(ver))
Beispiel #5
0
def install_nodejs(ver=None):
    """
    Install nodejs
    """
    assert ver in SUPPORT_NODEJS_VERSIONS or ver is None
    check_sudo()
    check_os()
    if not confirm('Do you want to install Node.js{}?'.format(' {}'.format(ver) if ver else '')):
        return
    allow_versions = ', '.join(SUPPORT_NODEJS_VERSIONS)
    while ver not in SUPPORT_NODEJS_VERSIONS:
        ver = prompt('Write Node.js version you need ({}):'.format(allow_versions),
                     default=SUPPORT_NODEJS_VERSIONS[0])
    print_green('INFO: Install Node.js {}...'.format(ver))
    sudo('wget -q -O - https://deb.nodesource.com/setup_{v}.x | bash -'.format(v=ver))
    apt_install('nodejs', noconfirm=True)
    print_green('INFO: Install Node.js {}... OK'.format(ver))
Beispiel #6
0
def install_ntp():
    """
    Install ntp daemon
    """
    check_sudo()
    check_os()
    if not confirm('Do you want install NTP client?'):
        return
    print_green('INFO: Install ntp...')
    apt_install('ntp ntpdate', noconfirm=True)
    print_red(
        "Go to http://www.pool.ntp.org/ and select servers in your server's country.\n"
        "For example (Ukraine):\n"
        "    0.ua.pool.ntp.org\n"
        "    1.ua.pool.ntp.org\n"
        "    2.ua.pool.ntp.org\n"
        "    3.ua.pool.ntp.org")

    def read_ntp_servers():
        ntp_server_list = []
        while True:
            t = prompt('Set NTP-server host. (Set empty string to continue)',
                       default='').strip()
            if not t:
                break
            ntp_server_list.append(t)
        return ntp_server_list

    while True:
        ntp_servers = read_ntp_servers()
        print_yellow('You wrote following NTP-server list:\n    {}'.format(
            '\n    '.join(ntp_servers or ('-empty-', ))))
        if confirm('Are you confirm this NTP-server list?'):
            break
    if ntp_servers:
        ntp_conf_fn = '/etc/ntp.conf'
        comment(ntp_conf_fn, r'^server\s', use_sudo=True)
        for ntp_server in ntp_servers:
            append(ntp_conf_fn,
                   'server {} iburst'.format(ntp_server),
                   use_sudo=True)
    print_green('INFO: Install ntp... OK')
Beispiel #7
0
def install_pngquant_jpegtran():
    """
    Install pngquant and jpegtran -- console utility for compress PNG- and JPEG-images
    """
    check_sudo()
    check_os()
    if not confirm('Do you want to install pngquant and jpegtran?'):
        return
    print_green('INFO: Install pngquant and jpegtran...')
    apt_install('libpng-dev liblcms2-dev libjpeg-progs', noconfirm=True)
    with cd('/tmp'):
        sudo('git clone --recursive https://github.com/pornel/pngquant.git')
    with cd('/tmp/pngquant'):
        sudo('./configure --with-lcms2 && make')
        sudo('make install')
        if confirm('Do you want make symlink /usr/local/bin/pngquant to /bin/pngquant?'):
            sudo('ln -sf /usr/local/bin/pngquant /bin/pngquant')
    with cd('/tmp'):
        sudo('rm -rf pngquant')
    print_green('INFO: Install pngquant and jpegtran...  OK')
Beispiel #8
0
def install_postgis(postgres_ver=None, postgis_ver=None):
    """
    Install PostGIS for PostgreSQL
    """
    assert postgres_ver in SUPPORT_POSTGRESQL_VERSIONS or postgres_ver is None
    assert postgis_ver in ('2.3', '2.4') or postgis_ver is None
    if postgres_ver and postgis_ver and postgis_ver not in SUPPORT_POSTGIS_VERSIONS[postgres_ver]:
        AssertionError('Invalid postgis_ver {} for postgres_ver {}'.format(postgres_ver, postgis_ver))
    check_sudo()
    os_name, os_ver = check_os()
    if not confirm('Do you want to install GEOS, GDAL, PROJ.4 and PostGIS?'):
        return
    allow_versions = ', '.join(SUPPORT_POSTGRESQL_VERSIONS)
    while postgres_ver not in SUPPORT_POSTGRESQL_VERSIONS:
        postgres_ver = prompt('Write PostgreSQL version you have ({}):'.format(allow_versions),
                              default=SUPPORT_POSTGRESQL_VERSIONS[-1])
    allow_versions = ', '.join(SUPPORT_POSTGIS_VERSIONS[postgres_ver])
    while postgis_ver not in SUPPORT_POSTGIS_VERSIONS[postgres_ver]:
        postgis_ver = prompt('Write PostGIS version you need ({}):'.format(allow_versions),
                             default=SUPPORT_POSTGIS_VERSIONS[postgres_ver][-1])
    print_green('INFO: Install GEOS, GDAL, PROJ.4 and PostGIS {} for PostgreSQL {}...'.format(postgis_ver,
                                                                                              postgres_ver))
    packages = ['libgeos-dev libgeos++-dev gdal-bin python-gdal libproj-dev']
    if os_name == 'Debian' and os_ver == '8':
        packages.extend(['libgeos-c1 libgeos-3.4.2 libgdal-dev libgdal1-dev libproj0'])
    if os_name == 'Debian' and os_ver == '9':
        packages.extend(['libgeos-c1v5 libgeos-3.5.1 libgdal-dev libproj12'])
    apt_install(' '.join(packages), noconfirm=True)
    apt_install('postgresql-{}-postgis-{}'.format(postgres_ver, postgis_ver), noconfirm=True)
    apt_install('libgeoip1 spatialite-bin', noconfirm=True)
    print_green('INFO: Install GEOS, GDAL, PROJ.4 and PostGIS {} for PostgreSQL {}... OK'.format(postgis_ver,
                                                                                                 postgres_ver))
Beispiel #9
0
def install_postgresql(ver=None):
    """
    Install PostgreSQL server
    """
    # simple settings helper http://pgtune.leopard.in.ua/
    assert ver in SUPPORT_POSTGRESQL_VERSIONS or ver is None
    check_sudo()
    check_os()
    if not confirm('Do you want to install PostreSQL{}?'.format(' {}'.format(ver) if ver else '')):
        return
    allow_versions = ', '.join(SUPPORT_POSTGRESQL_VERSIONS)
    while ver not in SUPPORT_POSTGRESQL_VERSIONS:
        ver = prompt('Write PostgreSQL version you need ({}):'.format(allow_versions),
                     default=SUPPORT_POSTGRESQL_VERSIONS[-1])
    print_green('INFO: Install PostreSQL {}...'.format(ver))
    set_apt_repositories(POSTGRESQL_REPOSITORIES, POSTGRESQL_REPOS_INSTALL_KEYS_COMMANDS, subconf_name='postgres')
    apt_update()
    apt_install('postgresql-{ver} postgresql-server-dev-{ver} libpq-dev'.format(ver=ver), noconfirm=True)
    set_postgresql_user_password('postgres', password_prompt('Set password to superuser postgres'))
    la = prompt('Set listen_addresses (hostname or ip, comma separated; set * for all)', default='localhost',
                validate='[\w\.\-\*]+').strip()
    t = BytesIO()
    postgresql_conf = '/etc/postgresql/{}/main/postgresql.conf'.format(ver)
    get(postgresql_conf, local_path=t, use_sudo=True)
    t = BytesIO(
        re.sub(br"#listen_addresses = 'localhost'", r"listen_addresses = '{}'".format(la).encode(), t.getvalue())
    )
    put(t, postgresql_conf, use_sudo=True)
    sudo('chown postgres:postgres {}'.format(postgresql_conf))
    sudo('chmod 644 {}'.format(postgresql_conf))
    hba = '/etc/postgresql/{}/main/pg_hba.conf'.format(ver)
    sed(hba, r'(local\s+all\s+all\s+)peer', r'\1md5', use_sudo=True)
    if confirm('Do you want to allow connect to PostgreSQL from out?'):
        append(hba, 'host     all             all             0.0.0.0/0               md5', use_sudo=True)
    install_postgis(postgres_ver=ver)
    if confirm('Do you want to restart PostgreSQL?'):
        service_restart('postgresql')
    print_green('INFO: Install PostreSQL {}... OK'.format(ver))
Beispiel #10
0
def install_postgis(postgres_ver=None, postgis_ver=None):
    """
    Install PostGIS for PostgreSQL
    """
    assert postgres_ver in SUPPORT_POSTGRESQL_VERSIONS or postgres_ver is None
    assert postgis_ver in ('2.3', '2.4') or postgis_ver is None
    if postgres_ver and postgis_ver and postgis_ver not in SUPPORT_POSTGIS_VERSIONS[
            postgres_ver]:
        AssertionError('Invalid postgis_ver {} for postgres_ver {}'.format(
            postgres_ver, postgis_ver))
    check_sudo()
    os_name, os_ver = check_os()
    if not confirm('Do you want to install GEOS, GDAL, PROJ.4 and PostGIS?'):
        return
    allow_versions = ', '.join(SUPPORT_POSTGRESQL_VERSIONS)
    while postgres_ver not in SUPPORT_POSTGRESQL_VERSIONS:
        postgres_ver = prompt(
            'Write PostgreSQL version you have ({}):'.format(allow_versions),
            default=SUPPORT_POSTGRESQL_VERSIONS[-1])
    allow_versions = ', '.join(SUPPORT_POSTGIS_VERSIONS[postgres_ver])
    while postgis_ver not in SUPPORT_POSTGIS_VERSIONS[postgres_ver]:
        postgis_ver = prompt(
            'Write PostGIS version you need ({}):'.format(allow_versions),
            default=SUPPORT_POSTGIS_VERSIONS[postgres_ver][-1])
    print_green(
        'INFO: Install GEOS, GDAL, PROJ.4 and PostGIS {} for PostgreSQL {}...'.
        format(postgis_ver, postgres_ver))
    packages = ['libgeos-dev libgeos++-dev gdal-bin python-gdal libproj-dev']
    if os_name == 'Debian' and os_ver == '8':
        packages.extend(
            ['libgeos-c1 libgeos-3.4.2 libgdal-dev libgdal1-dev libproj0'])
    if os_name == 'Debian' and os_ver == '9':
        packages.extend(['libgeos-c1v5 libgeos-3.5.1 libgdal-dev libproj12'])
    apt_install(' '.join(packages), noconfirm=True)
    apt_install('postgresql-{}-postgis-{}'.format(postgres_ver, postgis_ver),
                noconfirm=True)
    apt_install('libgeoip1 spatialite-bin', noconfirm=True)
    print_green(
        'INFO: Install GEOS, GDAL, PROJ.4 and PostGIS {} for PostgreSQL {}... OK'
        .format(postgis_ver, postgres_ver))
Beispiel #11
0
def prepare_server():
    """
    Prepare server before a project deploy
    """
    check_sudo()
    os_name, os_ver = check_os()
    set_apt_repositories(OS_REPOSITORIES, OS_REPOS_INSTALL_KEYS_COMMANDS)
    update_locale()
    configure_hostname()
    for_python = confirm(
        'Do you want to install all things for python projects?')
    install_python3 = confirm('Do you want to install Python3?')
    apt_update()
    apt_upgrade()
    apt_dist_upgrade()
    apt_install(
        'mc htop tmux pv gettext curl tcl-dev build-essential cmake git pigz libxml2-dev libxslt-dev '
        'lsb-release libcurl4-openssl-dev libffi-dev ca-certificates libssl-dev sysstat',
        noconfirm=True)
    apt_install('python2.7-dev python-dev libpcre3 libpcre3-dev',
                comment='For Python',
                noconfirm=for_python)
    if install_python3:
        apt_install('python3 python3-dev',
                    comment='For Python3',
                    noconfirm=for_python)
    apt_install(
        'tk-dev python-tk python-imaging libjpeg-dev zlib1g-dev libfreetype6-dev libpng-dev '
        'libtiff5-dev libwebp-dev tcl8.6-dev tk8.6-dev libturbojpeg-dev libtiff-tools',
        comment='For Python Pillow or other image libraries',
        noconfirm=for_python)
    addpacks = []
    if os_name == 'Debian' and os_ver == '8':
        addpacks.extend(
            ['liblcms1-dev libtiff-dev libopenjpeg-dev openjpeg-tools'])
    if os_name == 'Debian' and os_ver == '9':
        addpacks.extend(
            ['liblcms2-dev libtiff5-dev libopenjp2-7-dev libopenjp2-tools'])
    if addpacks:
        apt_install(
            ' '.join(addpacks),
            comment='For Python Pillow or other image libraries (additional).',
            noconfirm=for_python)
    if install_python3:
        apt_install('python3-tk',
                    comment='For Python3 Pillow or other image libraries',
                    noconfirm=for_python)
    apt_install('libmagickwand-dev',
                comment='For Python wand',
                noconfirm=for_python)
    apt_install('imagemagick', noconfirm=for_python)
    configure_timezone()
    install_ntp()
    setup_swap()
    if for_python or confirm(
            'Do you want to install python setuptools & pip?'):
        install_python_pkgs_managers()
        if install_python3:
            install_python_pkgs_managers(python_ver='3')
    if for_python or confirm(
            'Do you want to install python virtualenv & virtualenvwrapper?'):
        if install_python3:
            ver = ''
            while ver not in ('2', '3'):
                ver = prompt(
                    'Which Python version do you want to use? (2, 3):',
                    default='2')
        else:
            ver = '2'
        install_python_venv(python_ver=ver)
    install_nodejs()
    install_nginx()
    install_redis()
    install_postgresql()
    install_supervisor_latest()
    install_exim4()
    install_pngquant_jpegtran()
    install_proftpd()
    apt_cleanup()
    server_reboot()
Beispiel #12
0
def install_exim4():
    """
    Install email-server exim4, configure DKIM and generate DKIM-keys
    """
    check_sudo()
    check_os()
    if not confirm('Do you want install exim4?'):
        return
    print_green('INFO: Install exim4...')
    apt_install('exim4', noconfirm=True)
    dkim_keys_path = '/etc/exim4/dkim'
    print_red('You need run exim4 configure:\n'
              '    # dpkg-reconfigure exim4-config\n'
              'and set options:\n'
              '    General type of mail configuration: internet site; ...using SMTP\n'
              '    System mail name: your-real-domain.com\n'
              '    IP-address to listen on for incoming SMTP connectins: 127.0.0.1; ::1\n'
              '    Other destinations for which mail is accepted: <allow empty>\n'
              '    Domains to relay mail for: <allow empty>\n'
              '    Machines to relay mail for: <allow empty>\n'
              '    Keep number of DNS-queries minimal: No\n'
              '    Delivery method for local mail: mbox format\n'
              '    Split configuration into small files: No\n'
              '    Root and postmaster mail recipient: <allow empty>\n')
    if confirm('Do you want install opendkim and setup dkim in exim4?'):
        apt_install('opendkim opendkim-tools', noconfirm=True)
        sudo('mkdir {}'.format(dkim_keys_path), warn_only=True)
        sudo('chown Debian-exim:Debian-exim {dkp} && chmod 700 {dkp}'.format(dkp=dkim_keys_path))
        dkim_selector = prompt('Set DKIM selector name', default='mail', validate=r'[\w]+')
        sudo('cp /etc/exim4/exim4.conf.template /etc/exim4/exim4.conf.template.bak')
        t = BytesIO()
        get('/etc/exim4/exim4.conf.template', local_path=t, use_sudo=True)
        t = BytesIO(re.sub(
            br'(# This transport is used for delivering messages over SMTP connections\.\n).*?'
            br'(remote_smtp:.+?driver = smtp\n).+?(\.ifdef)',
            r'\1\n'
            r'DKIM_DOMAIN_NAME = ${{lc:${{domain:$h_from:}}}}\n'
            r'DKIM_FILE = {dkp}/${{lc:${{domain:$h_from:}}}}.key\n'
            r'DKIM_PRIV_KEY = ${{if exists{{DKIM_FILE}}{{DKIM_FILE}}{{0}}}}\n\n'
            r'\2\n'
            r'  dkim_domain = DKIM_DOMAIN_NAME\n'
            r'  dkim_selector = {dsn}\n'
            r'  dkim_private_key = DKIM_PRIV_KEY\n\n'
            r'\3'.format(dkp=dkim_keys_path, dsn=dkim_selector).encode(),
            t.getvalue(),
            flags=(re.M | re.S)
        ))
        put(t, '/etc/exim4/exim4.conf.template', use_sudo=True)
        sudo('chown root:root {cfn} && chmod 644 {cfn}'.format(cfn='/etc/exim4/exim4.conf.template'))
        print_red('You need to have DKIM keys.\n'
                  'You can generate their:\n'
                  '    # opendkim-genkey -D {dkp} -d your-real-domain.com -s {dsn}\n'
                  '    # mv {dkp}/{dsn}.private {dkp}/your-real-domain.com.key\n'
                  '    # mv {dkp}/{dsn}.txt {dkp}/your-real-domain.com.txt\n'
                  '    # chown Debian-exim:Debian-exim {dkp}/*\n'
                  '    # chmod 600 {dkp}/*\n'
                  'Set DNS record for your your-real-domain.com from {dkp}/your-real-domain.com.txt\n'
                  'And may set DNS ADSP record:\n'
                  '    _adsp._domainkey IN TXT "dkim=all"\n'
                  'For test sending mail run:\n'
                  '    # echo testmail | /usr/sbin/sendmail [email protected]\n'
                  ''.format(dkp=dkim_keys_path, dsn=dkim_selector))
        service_restart('exim4')
    print_green('INFO: Install exim4... OK')
Beispiel #13
0
def prepare_server():
    """
    Prepare server before a project deploy
    """
    check_sudo()
    os_name, os_ver = check_os()
    set_apt_repositories(OS_REPOSITORIES, OS_REPOS_INSTALL_KEYS_COMMANDS)
    update_locale()
    configure_hostname()
    for_python = confirm('Do you want to install all things for python projects?')
    install_python3 = confirm('Do you want to install Python3?')
    apt_update()
    apt_upgrade()
    apt_dist_upgrade()
    apt_install(
        'mc htop tmux pv gettext curl tcl-dev build-essential cmake git pigz libxml2-dev libxslt-dev '
        'lsb-release libcurl4-openssl-dev libffi-dev ca-certificates libssl-dev sysstat',
        noconfirm=True
    )
    apt_install('python2.7-dev python-dev libpcre3 libpcre3-dev', comment='For Python', noconfirm=for_python)
    if install_python3:
        apt_install('python3 python3-dev', comment='For Python3', noconfirm=for_python)
    apt_install(
        'tk-dev python-tk python-imaging libjpeg-dev zlib1g-dev libfreetype6-dev libpng-dev '
        'libtiff5-dev libwebp-dev tcl8.6-dev tk8.6-dev libturbojpeg-dev libtiff-tools',
        comment='For Python Pillow or other image libraries',
        noconfirm=for_python
    )
    addpacks = []
    if os_name == 'Debian' and os_ver == '8':
        addpacks.extend(['liblcms1-dev libtiff-dev libopenjpeg-dev openjpeg-tools'])
    if os_name == 'Debian' and os_ver == '9':
        addpacks.extend(['liblcms2-dev libtiff5-dev libopenjp2-7-dev libopenjp2-tools'])
    if addpacks:
        apt_install(' '.join(addpacks), comment='For Python Pillow or other image libraries (additional).',
                    noconfirm=for_python)
    if install_python3:
        apt_install(
            'python3-tk',
            comment='For Python3 Pillow or other image libraries',
            noconfirm=for_python
        )
    apt_install('libmagickwand-dev', comment='For Python wand', noconfirm=for_python)
    apt_install('imagemagick', noconfirm=for_python)
    configure_timezone()
    install_ntp()
    setup_swap()
    if for_python or confirm('Do you want to install python setuptools & pip?'):
        install_python_pkgs_managers()
        if install_python3:
            install_python_pkgs_managers(python_ver='3')
    if for_python or confirm('Do you want to install python virtualenv & virtualenvwrapper?'):
        if install_python3:
            ver = ''
            while ver not in ('2', '3'):
                ver = prompt('Which Python version do you want to use? (2, 3):', default='2')
        else:
            ver = '2'
        install_python_venv(python_ver=ver)
    install_nodejs()
    install_nginx()
    install_redis()
    install_postgresql()
    install_supervisor_latest()
    install_exim4()
    install_pngquant_jpegtran()
    install_proftpd()
    apt_cleanup()
    server_reboot()