#!/bin/bash
# Bash Menu Script Example
#==============================================================================
#   UBUNTU 18.04 BASH SCRIPT
#==============================================================================
##R1 V1##
#===Chanches For V1===#
#Added VestaCP#
#==============================================================================
# UNDER DEVELOPMENT
#==============================================================================
# Mailserver            -->>    EXIM, DOVECOT, SPAMASSASSIN, CLAMAV
# FTP backups           -->>    VSFTPD
# Secure WP             -->>    NGINX RULES
# WP backup & restore   -->>    SHELL or PHP
# LAMP SETUP
# APACHE, NGINX REVERSE PROXY
#==============================================================================
# CHECKEN!
# > Postfix
#==============================================================================

#-------------------#
# Preconfiguration  #
#-------------------#



echo "UBUNTU 18.04 INSTALLATIE SCRIPT"
echo "Webserver:"
PS3='Keuze:'
options=("Apache" "Apache, Nginx reverse proxy" "Nginx, PHP-FPM" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "Apache")
            webserver=apache
            certbot_server=apache
            vesta_apache=yes
            vesta_nginx=no
            vesta_fpm=no
            break
            ;;
        "Apache, Nginx reverse proxy")
            webserver=apache_nginx
            certbot_server=nginx
            vesta_apache=yes
            vesta_nginx=yes
            vesta_fpm=no
            break
            ;;
        "Nginx, PHP-FPM")
            webserver=nginx
            certbot_server=nginx
            vesta_apache=no
            vesta_nginx=yes
            vesta_fpm=yes
            break
            ;;
        "Quit")
            exit
            ;;
        *) echo "Fout antwoord $REPLY";;
    esac
done
echo Welk domein mag gekoppeld worden? Typ domein zonder www
read domain
echo Standaard wachtwoord
read passwd
echo administrator email
read email
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get clean
apt-get autoremove -y
hostnamectl set-hostname $domain
sed -i 's/;preserve_hostname: false/preserve_hostname: true/g' /etc/cloud/cloud.cfg
timedatectl set-timezone Europe/Amsterdam
    echo "install vesta CP"
    
    while true; do
    read -p "Installeer DNS-> yes/no?" yn
    case $yn in
        [Yy]* ) DNS=yes
        break;;
        [Nn]* ) DNS=no
        break;;
        * ) echo "Kies yes of no.";;
    esac
done

    while true; do
    read -p "Installeer Email client-> yes/no?" yn
    case $yn in
        [Yy]* ) mailserver=yes
        break;;
        [Nn]* ) mailserver=no
        break;;
        * ) echo "Kies yes of no.";;
    esac
done
   
#-------------------#
#   Vesta-install   #
#-------------------#
   
   
    curl -O http://vestacp.com/pub/vst-install.sh
    bash "vst-install.sh" --nginx $vesta_nginx --apache $vesta_apache --phpfpm $vesta_fpm --named $DNS --remi yes --vsftpd yes --proftpd no --iptables yes --fail2ban yes --quota no --exim yes --dovecot $mailserver --spamassassin $mailserver --clamav no --softaculous no --mysql yes --postgresql no --hostname $domain --email $email --password $passwd --force
    chown -R admin:admin /home/admin/web/"$domain"/public_html/
    apt install php-fpm php-mysql php-cgi php-common php-pear php-mbstring php-curl php-gd php-intl php-soap php-xml php-xmlrpc php-zip -y
    
exit
