Skip to content

Commit

Permalink
fix log-* tools with uaa/ldap on bosh directors
Browse files Browse the repository at this point in the history
  • Loading branch information
ogrand committed May 16, 2018
1 parent 1bdb55f commit 482b226
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 46 deletions.
35 changes: 11 additions & 24 deletions scripts/log-bosh
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,23 @@ else
printf "%b7%b : expe\n" "${GREEN}${BOLD}" "${STD}"
printf "\n%bYour choice :%b " "${GREEN}${BOLD}" "${STD}" ; read choice
case "${choice}" in
1) BOSH_TARGET="micro" ; BOSH_CLIENT="admin" ;;
2) BOSH_TARGET="master" ; BOSH_CLIENT="${MY_BOSH_USER}" ;;
3) BOSH_TARGET="ops" ; BOSH_CLIENT="${MY_BOSH_USER}" ;;
4) BOSH_TARGET="kubo" ; BOSH_CLIENT="admin" ;;
5) BOSH_TARGET="coab" ; BOSH_CLIENT="${MY_BOSH_USER}" ;;
6) BOSH_TARGET="ondemand" ; BOSH_CLIENT="${MY_BOSH_USER}" ;;
7) BOSH_TARGET="expe" ; BOSH_CLIENT="${MY_BOSH_USER}" ;;
1) BOSH_TARGET="micro" ;;
2) BOSH_TARGET="master" ;;
3) BOSH_TARGET="ops" ;;
4) BOSH_TARGET="kubo" ;;
5) BOSH_TARGET="coab" ;;
6) BOSH_TARGET="ondemand" ;;
7) BOSH_TARGET="expe" ;;
*) flag=0 ;;
esac
done

flag=0
while [ ${flag} = 0 ] ; do
clear
printf "%bEnter \"${BOSH_CLIENT}\" Password on \"${BOSH_TARGET}\" :%b " "${REVERSE}${YELLOW}" "${STD}" ; read -s BOSH_CLIENT_SECRET
if [ "${BOSH_CLIENT_SECRET}" != "" ] ; then
flag=1
fi
done

#--- BOSH variables (used by bosh cli V2)
export BOSH_ENVIRONMENT=`host bosh-${BOSH_TARGET}.internal.paas | awk '{print $4}'`
export BOSH_CLIENT
export BOSH_CLIENT_SECRET
export BOSH_CA_CERT

#--- Login to the director and list active deployments
export BOSH_ENVIRONMENT=`host bosh-${BOSH_TARGET}.internal.paas | awk '{print $4}'`
bosh alias-env ${BOSH_TARGET} > /dev/null 2>&1
bosh log-in > /dev/null 2>&1
if [ $? = 1 ] ; then
printf "%bEnter CF LDAP user and password :%b\n" "${REVERSE}${YELLOW}" "${STD}"
bosh log-in
if [ $? != 0 ] ; then
printf "\n\n%bERROR : Log to bosh director \"${BOSH_TARGET}\" failed whith user \"${BOSH_CLIENT}\".%b\n\n" "${RED}" "${STD}"
else
#--- Select specific deployment (BOSH_DEPLOYMENT variable)
Expand Down
7 changes: 3 additions & 4 deletions scripts/log-cf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ getCredhub() {
#--- Test if parameter exist with non empty value, else get it from credhub
if [ "${!1}" = "" ] ; then
credhubGet=`credhub g -n $2 2>&1`
result=`echo "${credhubGet}" | grep "Credential not found"`
if [ "${result}" = "" ] ; then
if [ $? = 0 ] ; then
credhubValue=`echo "${credhubGet}" | grep "value: " | awk '{print $2}'`
eval $1=`echo "${credhubGet}" | grep "value: " | awk '{print $2}'`
else
Expand All @@ -34,7 +33,7 @@ if [ $? != 0 ] ; then
credhub api --server=https://credhub.internal.paas:8844 > /dev/null 2>&1
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
printf "\n%bERROR : Bad LDAP authentication.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand All @@ -53,7 +52,7 @@ if [ "${flagError}" = "0" ] ; then
getCredhub "SYSTEM_DOMAIN" "/secrets/cloudfoundry_system_domain"
if [ ${flagError} = 0 ] ; then
cf login -a https://api.${SYSTEM_DOMAIN} -u ${CF_USER}
if [ $? = 1 ] ; then
if [ $? != 0 ] ; then
printf "\n%bERROR : Connexion failed.%b\n\n" "${RED}" "${STD}"
else
printf "\n\n"
Expand Down
2 changes: 1 addition & 1 deletion scripts/log-credhub
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [ $? != 0 ] ; then
credhub api --server=https://credhub.internal.paas:8844 > /dev/null 2>&1
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
printf "\n%bERROR : Bad LDAP authentication.%b\n\n" "${RED}" "${STD}"
else
printf "\n\n"
fi
Expand Down
9 changes: 3 additions & 6 deletions scripts/log-fly
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ export STD='\033[0m'
export BOLD='\033[1m'
export REVERSE='\033[7m'

flagError=0

getCredhub() {
#--- Test if parameter exist with non empty value, else get it from credhub
if [ "${!1}" = "" ] ; then
credhubGet=`credhub g -n $2 2>&1`
result=`echo "${credhubGet}" | grep "Credential not found"`
if [ "${result}" = "" ] ; then
if [ $? = 0 ] ; then
credhubValue=`echo "${credhubGet}" | grep "value: " | awk '{print $2}'`
eval $1=`echo "${credhubGet}" | grep "value: " | awk '{print $2}'`
else
Expand All @@ -36,7 +33,7 @@ if [ $? != 0 ] ; then
credhub api --server=https://credhub.internal.paas:8844 > /dev/null 2>&1
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
printf "\n%bERROR : Bad LDAP authentication.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand All @@ -56,7 +53,7 @@ if [ ${flagError} = 0 ] ; then
done
fi
fly login -c https://elpaaso-concourse-micro.${OPS_DOMAIN} -k -u atc -p ${FLY_PASSWORD}
if [ $? = 1 ] ; then
if [ $? != 0 ] ; then
FLY_PASSWORD=""
printf "\n\n%bERROR : Connexion failed.%b\n\n" "${RED}" "${STD}"
else
Expand Down
5 changes: 2 additions & 3 deletions scripts/log-mc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ getCredhub() {
#--- Test if parameter exist with non empty value, else get it from credhub
if [ "${!1}" = "" ] ; then
credhubGet=`credhub g -n $2 2>&1`
result=`echo "${credhubGet}" | grep "Credential not found"`
if [ "${result}" = "" ] ; then
if [ $? = 0 ] ; then
credhubValue=`echo "${credhubGet}" | grep "value: " | awk '{print $2}'`
eval $1=`echo "${credhubGet}" | grep "value: " | awk '{print $2}'`
else
Expand All @@ -34,7 +33,7 @@ if [ $? != 0 ] ; then
credhub api --server=https://credhub.internal.paas:8844 > /dev/null 2>&1
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
printf "\n%bERROR : Bad LDAP authentication.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand Down
11 changes: 3 additions & 8 deletions scripts/log-openstack
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,15 @@ export STD='\033[0m'
export BOLD='\033[1m'
export REVERSE='\033[7m'

flagError=0

getCredhub() {
#--- Test if parameter exist with non empty value, else get it from credhub
if [ "${!1}" = "" ] ; then
credhubGet=`credhub g -n $2 2>&1`
result=`echo "${credhubGet}" | grep "Credential not found"`
if [ "${result}" = "" ] ; then
if [ $? = 0 ] ; then
credhubValue=`echo "${credhubGet}" | grep "value: " | awk '{print $2}'`
eval $1=`echo "${credhubGet}" | grep "value: " | awk '{print $2}'`
else
if [ "$3" != "test" ] ; then
printf "\n\n%bERROR : \"$2\" credhub value unknown.%b\n\n" "${RED}" "${STD}"
fi
printf "\n\n%bERROR : \"$2\" credhub value unknown.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand All @@ -38,7 +33,7 @@ if [ $? != 0 ] ; then
credhub api --server=https://credhub.internal.paas:8844 > /dev/null 2>&1
credhub login
if [ $? != 0 ] ; then
printf "\n%bERROR : Bad LDAP authentication.\nConnexion failed.%b\n\n" "${RED}" "${STD}"
printf "\n%bERROR : Bad LDAP authentication.%b\n\n" "${RED}" "${STD}"
flagError=1
fi
fi
Expand Down

0 comments on commit 482b226

Please sign in to comment.