make sane defaults for MySQL settings

In dev environments, there is no /etc/cloudstack/management/db.properties file
That forces you to specify all parameters on the command line. This commit
sets some defaults, like port 3306, user root and localhost.

When available, it will still get settings from the config file and it will
also allow you to override it on the command line. So it is fully backwards
compatible.
This commit is contained in:
Remi Bergsma 2015-08-11 13:37:24 +02:00
parent e8ade2dd9e
commit 8a1e79f518

View File

@ -37,10 +37,10 @@ templateId=
hyper= hyper=
msKey=password msKey=password
DISKSPACE=2120000 #free disk space required in kilobytes DISKSPACE=2120000 #free disk space required in kilobytes
dbHost= dbHost="localhost"
dbUser= dbUser="root"
dbPassword= dbPassword=
dbPort= dbPort=3306
jasypt='/usr/share/cloudstack-common/lib/jasypt-1.9.2.jar' jasypt='/usr/share/cloudstack-common/lib/jasypt-1.9.2.jar'
while getopts 'm:h:f:u:Ft:e:s:o:r:d:p:'# OPTION while getopts 'm:h:f:u:Ft:e:s:o:r:d:p:'# OPTION
do do
@ -106,6 +106,7 @@ then
failed 3 failed 3
fi fi
if [ -f /etc/cloudstack/management/db.properties ]; then
if [ "$pflag" != 1 ]; then if [ "$pflag" != 1 ]; then
dbPort=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.port' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') dbPort=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.port' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
fi fi
@ -113,11 +114,11 @@ fi
if [ "$oflag" != 1 ]; then if [ "$oflag" != 1 ]; then
dbHost=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') dbHost=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
fi fi
if [ "$rflag" != 1 ]; then if [ "$rflag" != 1 ]; then
dbUser=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') dbUser=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
fi fi
if [ -f /etc/cloudstack/management/db.properties ]; then
encType=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.encryption.type' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') encType=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.encryption.type' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if [ "$encType" == "file" ] if [ "$encType" == "file" ]
then then
@ -130,7 +131,6 @@ if [ -f /etc/cloudstack/management/db.properties ]; then
failed 9 failed 9
fi fi
fi fi
fi
if [[ "$encType" == "file" || "$encType" == "web" ]] if [[ "$encType" == "file" || "$encType" == "web" ]]
then then
@ -145,10 +145,12 @@ then
fi fi
fi fi
else else
if [ "$dflag" != 1 ]; then if [ "$dflag" != 1 ]
then
dbPassword=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i ) dbPassword=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i )
fi fi
fi fi
fi
if [ "$templateId" == "" ] if [ "$templateId" == "" ]
then then