forked from Osthanes/saucelabs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_init.sh
147 lines (135 loc) · 4.3 KB
/
_init.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
#********************************************************************************
# Copyright 2014 IBM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
#********************************************************************************
#############
# Colors #
#############
export green='\e[0;32m'
export red='\e[0;31m'
export label_color='\e[0;33m'
export no_color='\e[0m' # No Color
##################################################
# Simple function to only run command if DEBUG=1 #
### ###############################################
debugme() {
[[ $DEBUG = 1 ]] && "$@" || :
}
set +e
set +x
##################################################
# capture packages that on the originial container
##################################################
if [[ $DEBUG -eq 1 ]]; then
dpkg -l | grep '^ii' > $EXT_DIR/pkglist
fi
###############################
# Configure extension PATH #
###############################
if [ -n $EXT_DIR ]; then
export PATH=$EXT_DIR:$PATH
fi
##############################
# Configure extension LIB #
##############################
if [ -z $GAAS_LIB ]; then
export GAAS_LIB="${EXT_DIR}/lib"
fi
################################
# Setup archive information #
################################
if [ -z $WORKSPACE ]; then
echo -e "${red}Please set WORKSPACE in the environment${no_color}"
${EXT_DIR}/print_help.sh
exit 1
fi
if [ -z $ARCHIVE_DIR ]; then
echo "${label_color}ARCHIVE_DIR was not set, setting to WORKSPACE/archive ${no_color}"
export ARCHIVE_DIR="${WORKSPACE}"
fi
if [ -d $ARCHIVE_DIR ]; then
echo "Archiving to $ARCHIVE_DIR"
else
echo "Creating archive directory $ARCHIVE_DIR"
mkdir $ARCHIVE_DIR
fi
export LOG_DIR=$ARCHIVE_DIR
#############################
# Install Cloud Foundry CLI #
#############################
#pushd .
#echo "Installing Cloud Foundry CLI"
#cd $EXT_DIR
#mkdir bin
#cd bin
#curl --silent -o cf-linux-amd64.tgz -v -L https://cli.run.pivotal.io/stable?release=linux64-binary &>/dev/null
#gunzip cf-linux-amd64.tgz &> /dev/null
#tar -xvf cf-linux-amd64.tar &> /dev/null
#
#cf help &> /dev/null
#RESULT=$?
#if [ $RESULT -ne 0 ]; then
# echo "Cloud Foundry CLI not already installed, adding CF to PATH"
# export PATH=$PATH:$EXT_DIR/bin
#else
# echo 'Cloud Foundry CLI already available in container. Latest CLI version available in ${EXT_DIR}/bin'
#fi
#
## check that we are logged into cloud foundry correctly
#cf spaces
#RESULT=$?
#if [ $RESULT -ne 0 ]; then
# echo -e "${red}Failed to check cf spaces to confirm login${no_color}"
# exit $RESULT
#else
# echo -e "${green}Successfully logged into IBM Bluemix${no_color}"
#fi
#popd
#
#export container_cf_version=$(cf --version)
#export latest_cf_version=$(${EXT_DIR}/bin/cf --version)
#echo "Container Cloud Foundry CLI Version: ${container_cf_version}"
#echo "Latest Cloud Foundry CLI Version: ${latest_cf_version}"
################################
# get the extensions utilities #
################################
pushd . >/dev/null
cd $EXT_DIR
git clone https://github.com/Osthanes/utilities.git utilities
popd >/dev/null
#############################################
# Capture packages installed on the container
#############################################
if [[ $DEBUG -eq 1 ]]; then
dpkg -l | grep '^ii' > $EXT_DIR/pkglist2
diff $EXT_DIR/pkglist $EXT_DIR/pkglist2
fi
#############################################
# Set app name and test url
#############################################
echo $CF_APP_NAME
if [ -z "$APP_URL" ] || [ "$APP_URL" == "undefined" ]; then
URL=$(cf app $CF_APP_NAME | grep 'urls:' | awk '{print $2}' | cut -d '*' -f 2)
if [[ "$URL" =~ ','$ ]]; then
URL="${URL%?}"
fi
if [ -z "$URL" ]; then
#do nothing
echo "No app name to pull..."
#exit 0
else
APP_URL="https://$URL"
export APP_URL
fi
fi