Skip to content

Commit 8a1e79f

Browse files
committed
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.
1 parent e8ade2d commit 8a1e79f

1 file changed

Lines changed: 31 additions & 29 deletions

File tree

scripts/storage/secondary/cloud-install-sys-tmplt

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ templateId=
3737
hyper=
3838
msKey=password
3939
DISKSPACE=2120000 #free disk space required in kilobytes
40-
dbHost=
41-
dbUser=
40+
dbHost="localhost"
41+
dbUser="root"
4242
dbPassword=
43-
dbPort=
43+
dbPort=3306
4444
jasypt='/usr/share/cloudstack-common/lib/jasypt-1.9.2.jar'
4545
while getopts 'm:h:f:u:Ft:e:s:o:r:d:p:'# OPTION
4646
do
@@ -106,18 +106,19 @@ then
106106
failed 3
107107
fi
108108

109-
if [ "$pflag" != 1 ]; then
110-
dbPort=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.port' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
111-
fi
109+
if [ -f /etc/cloudstack/management/db.properties ]; then
110+
if [ "$pflag" != 1 ]; then
111+
dbPort=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.port' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
112+
fi
112113

113-
if [ "$oflag" != 1 ]; then
114-
dbHost=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
115-
fi
116-
if [ "$rflag" != 1 ]; then
117-
dbUser=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
118-
fi
114+
if [ "$oflag" != 1 ]; then
115+
dbHost=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
116+
fi
117+
118+
if [ "$rflag" != 1 ]; then
119+
dbUser=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
120+
fi
119121

120-
if [ -f /etc/cloudstack/management/db.properties ]; then
121122
encType=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.encryption.type' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
122123
if [ "$encType" == "file" ]
123124
then
@@ -130,23 +131,24 @@ if [ -f /etc/cloudstack/management/db.properties ]; then
130131
failed 9
131132
fi
132133
fi
133-
fi
134134

135-
if [[ "$encType" == "file" || "$encType" == "web" ]]
136-
then
137-
encPassword=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i | sed 's/^ENC(\(.*\))/\1/')
138-
if [ ! $encPassword == "" ]
139-
then
140-
dbPassword=(`java -classpath $jasypt org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI decrypt.sh input=$encPassword password=$msKey verbose=false`)
141-
if [ ! $dbPassword ]
142-
then
143-
echo "Failed to decrypt DB password from db.properties"
144-
failed 9
145-
fi
146-
fi
147-
else
148-
if [ "$dflag" != 1 ]; then
149-
dbPassword=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i )
135+
if [[ "$encType" == "file" || "$encType" == "web" ]]
136+
then
137+
encPassword=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i | sed 's/^ENC(\(.*\))/\1/')
138+
if [ ! $encPassword == "" ]
139+
then
140+
dbPassword=(`java -classpath $jasypt org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI decrypt.sh input=$encPassword password=$msKey verbose=false`)
141+
if [ ! $dbPassword ]
142+
then
143+
echo "Failed to decrypt DB password from db.properties"
144+
failed 9
145+
fi
146+
fi
147+
else
148+
if [ "$dflag" != 1 ]
149+
then
150+
dbPassword=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i )
151+
fi
150152
fi
151153
fi
152154

0 commit comments

Comments
 (0)