-
Notifications
You must be signed in to change notification settings - Fork 17
/
nuage-unzip.sh
executable file
·75 lines (67 loc) · 1.64 KB
/
nuage-unzip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
# set -ex
#
# Unzips the Nuage Networks software
#
CURRENT_DIR=`pwd`
PLAYBOOK_DIR=$CURRENT_DIR/src/playbooks
function usage {
echo ""
echo "Unzips the Nuage Networks software"
echo ""
echo "Usage:"
echo " " $0 "<zipped_directory>" "<unzip_directory>" "[options]"
echo ""
echo " <zipped_directory>: Directory containing the downloaded zipped Nuage Networks software"
echo " <unzip_directory>: Directory to write unzipped software"
echo ""
echo "Options:"
echo " -h, --help: Displays this help."
echo " --user: Unzip as a specific user (by default root)"
echo " --yum-proxy: Sets a proxy address for reaching yum"
echo ""
}
#
# Parse arguments
#
EXTRA_VARS=()
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
usage
exit 1
;;
--user)
EXTRA_VARS+=("-e")
EXTRA_VARS+=("unzip_user=$2")
shift # past argument
shift # past value
;;
--yum-proxy)
EXTRA_VARS+=("-e")
EXTRA_VARS+=("yum_proxy=$2")
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# Missing required arguments, show usage
if [[ $# -lt 2 ]]; then
usage
exit 1
fi
# <zipped_directory> argument
ZIPPED_DIR=$CURRENT_DIR/$1
shift
# <unzip_directory> argument
UNZIP_DIR=$CURRENT_DIR/$1
shift
$(which ansible-playbook) $PLAYBOOK_DIR/nuage_unzip.yml -e nuage_zipped_files_dir=$ZIPPED_DIR -e nuage_unzipped_files_dir=$UNZIP_DIR "${EXTRA_VARS[@]}"