#!/bin/bash
# init
function pause()
{
   read -p “$*”
}

apt-get install openssh-server -y
cp -R -f vsftpd /usr/local/src



cp /etc/ssl/certs/certificate_and_key.crt /etc/ssl/certs/certificate_and_key.pem
cp /etc/ssl/private/mail.guysjoint.com.key /etc/ssl/private/mail.netkwik.com.pem

echo ""
echo "-------------------------------------------------------------------"
echo "   This script will give you the option to install VSFTPD from     "
echo " either a DEB file or via APT - choose DEB for Mint 17/2, ONLY!!   "
echo "-------------------------------------------------------------------"
echo ""
read -p "Continue......"


## array of menu entries
entries=( "for DEB"
          "for APT" )

## set prompt for select menu
PS3='Selection: '

while [ "$menu" != 1 ]; do                ## outer loop redraws menu each time
    printf "\nMain Menu:\n\n"             ## heading for menu
    select choice in "${entries[@]}"; do  ## select displays choices in array
        case "$choice" in                 ## case responds to choice
            "for DEB" )

 
sudo dpkg -i vsftpd*deb
cp *jitterb* /usr/local/src
mkdir -p /var/run/vsftpd/empty
mkdir -p /var/ftp
mkdir /etc/vsftpd

cp ftp.msg /etc/vsftpd
cp *jitterb* /etc/vsftpd.conf
echo ""
echo "------------------------------------------------------------------"
echo " Okay - we've added a ridiculous login message which says this    "
echo " computer is owned by the US government - edit this to whatever.  "
echo "        We need to create a certifcate, now.........              "
echo "------------------------------------------------------------------"
cp SSL.script /etc/vsftpd/SSL.script
chmod 755 /etc/vsftpd/SSL.script
sudo /etc/vsftpd/SSL.script
cp /usr/local/src/*jitterb* /etc/vsftpd.conf
cp /usr/local/src/*jitterb* /etc/vsftpd/vsftpd.conf
service vsftpd restart
echo ""
echo "------------------------------------------------------------------"
echo " NOTE: Vsftpd will not read the edited configuration file until   "
echo " the computer is restarted.  Vstpd can be started with:           "
echo " /usr/sbin/vsftpd & - to stop it simply issue 'killall vsfptd'    "
echo "   Vsftpd should be listening when the computer is started.       " 
echo "------------------------------------------------------------------"
echo ""




exit






break                     ## break returns control to outer loop
                ;;
            "for APT" )  
            
            

echo ""
 
sudo apt-get install vsftpd -y
cp *jitterb* /usr/local/src
mkdir -p /var/run/vsftpd/empty
mkdir -p /var/ftp
mkdir /etc/vsftpd

cp ftp.msg /etc/vsftpd
cp *jitterb* /etc/vsftpd.conf
echo ""
echo "------------------------------------------------------------------"
echo " Okay - we've added a ridiculous login message which says this    "
echo " computer is owned by the US government - edit this to whatever.  "
echo "        We need to create a certifcate, now.........              "
echo "------------------------------------------------------------------"

#cp /usr/local/src/*jitterb* /etc/vsftpd.conf
#cp /usr/local/src/*jitterb* /etc/vsftpd/vsftpd.conf

cd /etc
rm -rf vsftpd
cd /usr/local/src/
cp -R -f vsftpd /etc
chmod -R 777 /etc/vsftpd

cp SSL.script /etc/vsftpd/SSL.script
chmod 755 /etc/vsftpd/SSL.script
sudo /etc/vsftpd/SSL.script


service vsftpd restart
echo ""
echo "------------------------------------------------------------------"
echo " NOTE: Vsftpd will not read the edited configuration file until   "
echo " the computer is restarted.  Vstpd can be started with:           "
echo " /usr/sbin/vsftpd & - to stop it simply issue 'killall vsfptd'    "
echo "   Vsftpd should be listening when the computer is started.       " 
echo "------------------------------------------------------------------"

exit



 
     break                     ## break returns control to outer loop
                ;;
            "for RESTORE" )         
                echo "Haiiii, exiting"
                menu=1                    ## variable setting exit condition
                break
                ;;
            * )
                echo "ssss"
                break
                ;;
        esac
    done
done



