Skip to content

Commit d64747a

Browse files
author
kishan
committed
bug 12262: Added "-s" option. When encryption is used provide mgmt secret key using "-s" option.
status 12262 : resolved fixed reviewed-by: Prasanna
1 parent c7766ea commit d64747a

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
# $Id: installrtng.sh 11251 2010-07-23 23:40:44Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/installrtng.sh $
33
usage() {
4-
printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver>]\n" $(basename $0) >&2
4+
printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver> -s <mgmt server secret key>]\n" $(basename $0) >&2
55
printf "or\n" >&2
6-
printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-h <hypervisor name: kvm|vmware|xenserver>]\n" $(basename $0) >&2
6+
printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-h <hypervisor name: kvm|vmware|xenserver> -s <mgmt server secret key>]\n" $(basename $0) >&2
77
}
88

99
failed() {
@@ -16,8 +16,9 @@ fflag=
1616
ext="vhd"
1717
templateId=1
1818
hyper=
19+
msKey=password
1920
DISKSPACE=5120000 #free disk space required in kilobytes
20-
while getopts 'm:h:f:u:Ft:e:' OPTION
21+
while getopts 'm:h:f:u:Ft:e:s:' OPTION
2122
do
2223
case $OPTION in
2324
m) mflag=1
@@ -36,6 +37,9 @@ do
3637
;;
3738
h) hyper="$OPTARG"
3839
;;
40+
s) sflag=1
41+
msKey="$OPTARG"
42+
;;
3943
?) usage
4044
failed 2
4145
;;
@@ -68,7 +72,15 @@ fi
6872

6973
dbHost=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
7074
dbUser=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
71-
dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
75+
if [ "$sflag" == "1" ]
76+
then
77+
encryptionJarPath="@JAVADIR@/cloud-jasypt-1.8.jar"
78+
echo $encryptionJarPath;
79+
encPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i | sed 's/^ENC(\(.*\))/\1/')
80+
dbPassword=(`java -classpath "$encryptionJarPath" org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI decrypt.sh input=$encPassword password=$msKey verbose=false`)
81+
else
82+
dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i )
83+
fi
7284

7385
if [ "$hyper" == "kvm" ]
7486
then
@@ -87,6 +99,12 @@ else
8799
failed 2
88100
fi
89101

102+
if [ ! $templateId ]
103+
then
104+
echo "Unable to get template Id from database"
105+
failed 8
106+
fi
107+
90108
localfile=$(uuidgen).$ext
91109

92110
mntpoint=`echo "$mntpoint" | sed 's|/*$||'`

0 commit comments

Comments
 (0)