DEBUG="n"
QUIET='n'
-VERSION="0.1"
+VERSION="0.2"
# console colors:
RED=""
REL_K8S_CFGDIR='.kube'
REL_K8S_CFGFILE='config.yaml'
+declare -A ENV_HOST=()
+declare -A ENV_PORT=()
+declare -A ENV_USER=()
+declare -A ENV_GROUP=()
+declare -A ENV_HOME=()
+
+ENV_HOST['live']='live-master01-k8s-spk.spk.pixelpark.net'
+ENV_HOST['stage']='stage-master01-k8s-spk.spk.pixelpark.net'
+
+ENV_PORT['live']=1080
+ENV_PORT['stage']=1080
+
+ENV_USER['live']='k8s-live'
+ENV_USER['stage']='k8s-stage'
+
+ENV_GROUP['live']='users'
+ENV_GROUP['stage']='users'
+
#-------------------------------------------------------------------
detect_color() {
exit 1
fi
+ if [[ "$( type -t curl || true )" != "file" ]] ; then
+ error "Command '${RED}curl${NORMAL}' not found, please install the appropriate package."
+ echo >&2
+ exit 5
+ fi
+
local cur_user_id=$( id -u )
if [[ "${cur_user_id}" != "0" ]] ; then
error "Wrong user '${RED}$( id -u -n )${NORMAL}'."
echo -e " ${RED}*${NORMAL} [$(my_date)] [${BASENAME}:${RED}ERROR${NORMAL}]: $@" >&2
}
+#------------------------------------------------------------------------------
+get_config() {
+
+ local env="$1"
+
+ info "Get current Kubernetes configuration for environment '${GREEN}${env}${NORMAL}'."
+
+ local host="${ENV_HOST[${env}]}"
+ local port="${ENV_PORT[${env}]}"
+ local user="${ENV_USER[${env}]}"
+ local group="${ENV_GROUP[${env}]}"
+
+ local url="http://${host}"
+ if [[ "${port}" != "80" ]] ; then
+ url+=":${port}"
+ fi
+ url+="/"
+ debug "URL to get the config: '${url}'."
+
+ local user_home=$( getent passwd "${user}" | head -n 1 | awk -F: '{print $6}' )
+ debug "Home diectory of user '${user}': '${user_home}'"
+
+
+}
+
################################################################################
##
## Main
main() {
get_options "$@"
+ get_config 'live'
+ get_config 'stage'
}