@@ -37,10 +37,10 @@ templateId=
3737hyper=
3838msKey=password
3939DISKSPACE=2120000 # free disk space required in kilobytes
40- dbHost=
41- dbUser=
40+ dbHost=" localhost "
41+ dbUser=" root "
4242dbPassword=
43- dbPort=
43+ dbPort=3306
4444jasypt=' /usr/share/cloudstack-common/lib/jasypt-1.9.2.jar'
4545while getopts ' m:h:f:u:Ft:e:s:o:r:d:p:' # OPTION
4646do
@@ -106,18 +106,19 @@ then
106106 failed 3
107107fi
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
151153fi
152154
0 commit comments