Updated Branches: refs/heads/master a2d49bef6 -> 27265597b
make cloud-install-sys-tmplt work without db.properties file this allows developer setup secondary storage from their development environment Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/27265597 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/27265597 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/27265597 Branch: refs/heads/master Commit: 27265597bfee2cc055c5591d689ff6980f412c42 Parents: a2d49be Author: frank <[email protected]> Authored: Wed Jun 20 11:08:33 2012 -0700 Committer: frank <[email protected]> Committed: Wed Jun 20 11:08:33 2012 -0700 ---------------------------------------------------------------------- scripts/storage/secondary/cloud-install-sys-tmplt | 54 +++++++++++----- 1 files changed, 38 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/27265597/scripts/storage/secondary/cloud-install-sys-tmplt ---------------------------------------------------------------------- diff --git a/scripts/storage/secondary/cloud-install-sys-tmplt b/scripts/storage/secondary/cloud-install-sys-tmplt index 2f28299..96f0be6 100755 --- a/scripts/storage/secondary/cloud-install-sys-tmplt +++ b/scripts/storage/secondary/cloud-install-sys-tmplt @@ -1,7 +1,7 @@ #!/bin/bash # $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 $ usage() { - printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver> ] [ -s <mgmt server secret key, if you specified any when running cloud-setup-database, default is password>][-u <Url to system vm template>] [-F <clean up system templates of specified hypervisor>] [-e <Template suffix, e.g vhd, ova, qcow2>]\n" $(basename $0) >&2 + printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver> ] [ -s <mgmt server secret key, if you specified any when running cloud-setup-database, default is password>][-u <Url to system vm template>] [-F <clean up system templates of specified hypervisor>] [-e <Template suffix, e.g vhd, ova, qcow2>] [-o <Database server hostname or ip, e.g localhost>] [-r <Database user name, e.g root>] [-d <Database password. Fllowed by nothing if the password is empty>]\n" $(basename $0) >&2 printf "or\n" >&2 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 } @@ -18,7 +18,10 @@ templateId=1 hyper= msKey=password DISKSPACE=5120000 #free disk space required in kilobytes -while getopts 'm:h:f:u:Ft:e:s:' OPTION +dbHost= +dbUser= +dbPassword= +while getopts 'm:h:f:u:Ft:e:s:o:r:d' OPTION do case $OPTION in m) mflag=1 @@ -40,6 +43,15 @@ do s) sflag=1 msKey="$OPTARG" ;; + o) oflag=1 + dbHost="$OPTARG" + ;; + r) rflag=1 + dbUser="$OPTARG" + ;; + d) dflag=1 + dbPassword="$OPTARG" + ;; ?) usage failed 2 ;; @@ -70,19 +82,27 @@ then failed 3 fi -dbHost=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') -dbUser=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') -encType=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.encryption.type' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') -if [ "$encType" == "file" ] -then - msKey=$(cat /etc/cloud/management/key) -elif [ "$encType" == "web" ] -then - if [ ! "$sflag" == "1" ] - then - echo "Encryption type web requires mgmt secret key using -s option" - failed 9 - fi + +if [ "$oflag" != 1 ]; then + dbHost=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') +fi +if [ "$rflag" != 1]; then + dbUser=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') +fi + +if [ -f /etc/cloud/management/db.properties ]; then + encType=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.encryption.type' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + if [ "$encType" == "file" ] + then + msKey=$(cat /etc/cloud/management/key) + elif [ "$encType" == "web" ] + then + if [ ! "$sflag" == "1" ] + then + echo "Encryption type web requires mgmt secret key using -s option" + failed 9 + fi + fi fi if [[ "$encType" == "file" || "$encType" == "web" ]] @@ -98,7 +118,9 @@ then fi fi else - dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i ) + if [ "$dflag" != 1]; then + dbPassword=$(sed '/^\#/d' /etc/cloud/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i ) + fi fi if [ "$hyper" == "kvm" ]
