#1  
Old 6th September 2011, 03:59
dclardy dclardy is offline
Senior Member
 
Join Date: Sep 2009
Location: Dallas, TX
Posts: 347
Thanks: 10
Thanked 47 Times in 28 Posts
Default Bash Script Help

I am updating my script that automatically installs ISPConfig 3 on Debian 6. I am asking the user some questions, and I need those options to be saved so that I can use that to pick the correct installation procedure. I have it all setup, but I can't get it to find the correct options that I have given. Do you have any ideas?

My script can be found here.

https://github.com/dclardy64/ISPConf...ter/install.sh
Reply With Quote
Sponsored Links
  #2  
Old 6th September 2011, 11:03
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

To what part of the script are you referring?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 6th September 2011, 17:28
dclardy dclardy is offline
Senior Member
 
Join Date: Sep 2009
Location: Dallas, TX
Posts: 347
Thanks: 10
Thanked 47 Times in 28 Posts
Default

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.
Reply With Quote
  #4  
Old 7th September 2011, 11:46
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

Shouldn't you use
Code:
installchoices=install_$mail_server$dns_server$quota$jailkit
instead of
Code:
$installchoices=install_$mail_server$dns_server$quota$jailkit
?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 7th September 2011, 16:17
dclardy dclardy is offline
Senior Member
 
Join Date: Sep 2009
Location: Dallas, TX
Posts: 347
Thanks: 10
Thanked 47 Times in 28 Posts
Default

That was part of the problem. There were some other things that I needed to iron out as well, but I have them taken care of now. Thanks for the suggestion.
Reply With Quote
  #6  
Old 8th September 2011, 12:16
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

So it's working now?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #7  
Old 8th September 2011, 18:48
dclardy dclardy is offline
Senior Member
 
Join Date: Sep 2009
Location: Dallas, TX
Posts: 347
Thanks: 10
Thanked 47 Times in 28 Posts
 
Default

Yes. It works. That is why I got you to sticky that Install Script for me!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot login to phpmyadmin penkku HOWTO-Related Questions 1 24th February 2011 09:26
freebsd 7, samba 3, domain controller alexdimarco Suggest HOWTO 6 5th November 2010 16:54
i am having some problem ? cobro Installation/Configuration 20 30th April 2008 16:26
Cannot log onto pop3 server Debian Etch Perfect Server docean Installation/Configuration 2 19th March 2008 00:23
https protocol stops page load tjd General 7 18th November 2007 18:06


All times are GMT +2. The time now is 07:24.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.