#!/usr/bin/env bash PATH=/opt/puppet/bin:$PATH function parse_config_file() { VALUE=$(puppet config print --section user $1) if [ "$VALUE" == "none" ] ; then # remove any 'none' values VALUE="" fi echo $VALUE } function parse_env() { echo $http_proxy| awk "$1" } if [ -n "$http_proxy" ] ; then HTTP_PROXY_HOST=$(parse_env 'BEGIN{FS=".*//(.+@)?"} {split($2,a,":"); print a[1]}') HTTP_PROXY_PORT=$(parse_env 'BEGIN{FS=".*//(.+@)?"} {split($2,a,":"); print a[2]}') HTTP_PROXY_USER=$(parse_env 'BEGIN{FS="//|@"} /@/ {split($2,a,":"); print a[1]}') HTTP_PROXY_PASSWORD=$(parse_env 'BEGIN{FS="//|@"} /@/ {split($2,a,":"); print a[2]}') SOURCE="http_proxy environment variable" else HTTP_PROXY_HOST=$(parse_config_file http_proxy_host) HTTP_PROXY_PORT=$(parse_config_file http_proxy_port) HTTP_PROXY_USER=$(parse_config_file http_proxy_user) HTTP_PROXY_PASSWORD=$(parse_config_file http_proxy_password) SOURCE="$(puppet config print confdir)/puppet.conf" fi JVM_EXTRA="" if [ -n "$HTTP_PROXY_USER" ] || [ "$HTTP_PROXY_PASSWORD" ] ; then echo "This tool does not yet support proxies requiring authentication" exit 1 fi if [ -n "$HTTP_PROXY_HOST" ] && [ -n "$HTTP_PROXY_PORT" ] ; then echo "Using proxy server specified in ${SOURCE}" JVM_EXTRA+="-Dhttp.proxyHost=${HTTP_PROXY_HOST} " JVM_EXTRA+="-Dhttps.proxyHost=${HTTP_PROXY_HOST} " JVM_EXTRA+="-Dhttp.proxyPort=${HTTP_PROXY_PORT} " JVM_EXTRA+="-Dhttps.proxyPort=${HTTP_PROXY_PORT} " fi "${JAVA_BIN}" ${JVM_EXTRA} \ -cp "${INSTALL_DIR}/puppet-server-release.jar" \ clojure.main -m puppetlabs.puppetserver.cli.gem \ --config "${CONFIG}" -- "$@"