#!/bin/bash
# Bash Menu Script Example
function webserver(){
echo "----------------"
echo "$variable"
variable="in de functie"
}

variable="buiten de functie"

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")
            echo "you chose choice 1"
            break
            ;;
        "Apache, Nginx reverse proxy")
            echo "you chose choice 2"
            break
            ;;
        "Nginx, PHP-FPM")
            echo "you chose choice $REPLY which is $opt"
            break
            ;;
        "Quit")
            exit
            ;;
        *) echo "invalid option $REPLY";;
    esac
done
echo "INSTALLATIE WORDT UITGEVOERD >>> "

while true; do
    read -p "Installeer *** kies yes/no?" yn
    case $yn in
        [Yy]* ) webserver $variable;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done
echo "$variable"
exit
