In the first part of the script, I ask the user for input. This inputs are saved as variables, and I need them to be used in selected the correct install function.
Code:
if [ "$1" != "--help" ]; then
#set mysql root password
MYSQL_ROOT_PASSWORD="root"
echo "Please input the root password of mysql:"
read -p "(Default password: root):" MYSQL_ROOT_PASSWORD
if [ "$MYSQL_ROOT_PASSWORD" = "" ]; then
MYSQL_ROOT_PASSWORD="root"
fi
echo "==========================="
echo "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD"
echo "==========================="
#set Hostname
HOSTNAME="server1"
echo "Please input the Hostname:"
read -p "(Default Hostname: server1):" HOSTNAME
if [ "$HOSTNAME" = "" ]; then
HOSTNAME="server1"
fi
echo "==========================="
echo "HOSTNAME=$HOSTNAME"
echo "==========================="
#set Fully Qualified Hostname
HOSTNAMEFQDN="server1.example.com"
echo "Please input the Full Hostname:"
read -p "(Default Full Hostname: server1.example.com):" HOSTNAMEFQDN
if [ "$HOSTNAMEFQDN" = "" ]; then
HOSTNAMEFQDN="server1"
fi
echo "==========================="
echo "HOSTNAMEFQDN=$HOSTNAMEFQDN"
echo "==========================="
#set Server IP
serverIP="123.156.78.9"
echo "Please input the Server IP:"
read -p "(Default Server IP: 123.456.78.9):" serverIP
if [ "$serverIP" = "" ]; then
serverIP="123.456.78.9"
fi
echo "==========================="
echo "serverIP=$serverIP"
echo "==========================="
#set SSH Port
sshd_port="22"
echo "Please input the SSH Port:"
read -p "(Default SSH Port: 22):" sshd_port
if [ "$sshd_port" = "" ]; then
sshd_port="22"
fi
echo "==========================="
echo "sshd_port=$sshd_port"
echo "==========================="
#set Mail Server
mail_server="Courier"
echo "Please select Mail Server (Courier or Dovecot:"
read -p "(Default Mail Server: Courier):" mail_server
if [ "$mail_server" = "" ]; then
mail_server="Courier"
fi
echo "==========================="
echo "mail_server=$mail_server"
echo "==========================="
#set DNS Server
dns_server="Bind"
echo "Please select DNS Server (Bind for now):"
read -p "(Default DNS Server: Bind):" dns_server
if [ "$dns_server" = "" ]; then
dns_server="Bind"
fi
echo "==========================="
echo "dns_server=$dns_server"
echo "==========================="
#set Quota
quota="Yes"
echo "Please select whether to install Quota or Not:"
read -p "(Default: Yes):" quota
if [ "$quota" = "" ]; then
quota="Yes"
fi
echo "==========================="
echo "quota=$quota"
echo "==========================="
#set Jailkit
jailkit="Yes"
echo "Please select whether to install Jailkit or Not:"
read -p "(Default: Yes):" jailkit
if [ "$jailkit" = "" ]; then
jailkit="Yes"
fi
echo "==========================="
echo "jailkit=$jailkit"
echo "==========================="
$installchoices=install_$mail_server$dns_server$quota$jailkit
The last section $installchoices returns exactly what I need it do, but when it comes to the install functions it is not found.
Code:
#Execute functions#
if [ "$installchoices" = "install_CourierBindNoNo" ]; then
basic_server_setup
install_DashNTP
install_MYSQLCourier
install_Virus
install_Apache
install_PureFTPD
install_Bind
install_Stats
install_fail2banCourier
install_SquirrelMail
install_ISPConfig
elif [ "$installchoices" = "install_CourierBindYesNo" ]; then
basic_server_setup
install_DashNTP
install_MYSQLCourier
install_Virus
install_Apache
install_PureFTPD
install_Quota
install_Bind
install_Stats
install_fail2banCourier
install_SquirrelMail
install_ISPConfig
elif [ "$installchoices" = "install_CourierBindYesYes" ]; then
basic_server_setup
install_DashNTP
install_MYSQLCourier
install_Virus
install_Apache
install_PureFTPD
install_Quota
install_Bind
install_Stats
install_Jailkit
install_fail2banCourier
install_SquirrelMail
install_ISPConfig
elif [ "$installchoices" = "install_CourierBindNoYes" ]; then
basic_server_setup
install_DashNTP
install_MYSQLCourier
install_Virus
install_Apache
install_PureFTPD
install_Bind
install_Stats
install_Jailkit
install_fail2banCourier
install_SquirrelMail
install_ISPConfig
elif [ "$installchoices" = "install_DovecotBindNoNo" ]; then
basic_server_setup
install_DashNTP
install_MYSQLDovecot
install_Virus
install_Apache
install_PureFTPD
install_Bind
install_Stats
install_fail2banDovecot
install_SquirrelMail
install_ISPConfig
elif [ "$installchoices" = "install_DovecotBindYesNo" ]; then
basic_server_setup
install_DashNTP
install_MYSQLDovecot
install_Virus
install_Apache
install_PureFTPD
install_Quota
install_Bind
install_Stats
install_fail2banDovecot
install_SquirrelMail
install_ISPConfig
elif [ "$installchoices" = "install_DovecotBindYesYes" ]; then
basic_server_setup
install_DashNTP
install_MYSQLDovecot
install_Virus
install_Apache
install_PureFTPD
install_Quota
install_Bind
install_Stats
install_Jailkit
install_fail2banDovecot
install_SquirrelMail
install_ISPConfig
elif [ "$installchoices" = "install_DovecotBindNoYes" ]; then
basic_server_setup
install_DashNTP
install_MYSQLDovecot
install_Virus
install_Apache
install_PureFTPD
install_Bind
install_Stats
install_Jailkit
install_fail2banDovecot
install_SquirrelMail
install_ISPConfig
fi
#End execute functions#
I am trying to figure out what I need to do to get the user inputs to allow me to select the correct install function.
Recent comments
19 hours 3 min ago
1 day 8 min ago
1 day 4 hours ago
1 day 6 hours ago
1 day 20 hours ago
1 day 20 hours ago
2 days 1 hour ago
2 days 8 hours ago
2 days 9 hours ago
2 days 10 hours ago