Skip to content

Commit 2e03536

Browse files
author
Sven Vogel
committed
add comments to the failed and get options block / rename vars in failed block / typo Fix
1 parent 7e19ac7 commit 2e03536

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,22 @@ usage() {
2424
printf "\nUsage: %s:\n\t-m secondary storage mount point\n\t-u http url for system vm template\n\t-h hypervisor name: kvm|vmware|xenserver|hyperv|ovm3\n\t-s mgmt server secret key\n\n" $(basename $0) >&2
2525
}
2626

27+
# Usage: e.g. failed $? "this is an error"
2728
failed() {
28-
if [[ -z $2 ]]; then
29+
local returnval=$1
30+
local returnmsg=$2
31+
32+
# check for an message, if there is no one dont print anything
33+
if [[ -z $returnmsg ]]; then
2934
:
3035
else
31-
echo -e $2
36+
echo -e $returnmsg
3237
fi
33-
if [[ $1 -eq 0 ]]; then
38+
if [[ $returnval -eq 0 ]]; then
3439
return 0
3540
else
3641
echo "Installation failed"
37-
exit $1
42+
exit $returnval
3843
fi
3944
}
4045

@@ -54,8 +59,8 @@ dbPort=3306
5459
jasypt='/usr/share/cloudstack-common/lib/jasypt-1.9.2.jar'
5560
tmpldescr='SystemVM Template'
5661

57-
if [[ ! $@ =~ ^\-.+ ]]
58-
then
62+
# check if first parameter is not a dash (-) then print the usage block
63+
if [[ ! $@ =~ ^\-.+ ]]; then
5964
usage
6065
exit 0
6166
fi

0 commit comments

Comments
 (0)