@@ -115,6 +115,35 @@ setup_args() {
115115}
116116
117117
118+ function configure_proxy() {
119+ # Allow bypassing 'proxy' env vars via sudo
120+ local sudoers_proxy=' Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path"'
121+ if ! sudo grep -s -q ^" ${sudoers_proxy} " /etc/sudoers.d/st2; then
122+ sudo sh -c " echo '${sudoers_proxy} ' >> /etc/sudoers.d/st2"
123+ fi
124+
125+ # Configure proxy env vars for 'st2api' and 'st2actionrunner' system configs
126+ # See: https://docs.stackstorm.com/packs.html#installing-packs-from-behind-a-proxy
127+ local service_config_path=$( hash apt-get > /dev/null 2>&1 && echo ' /etc/default' || echo ' /etc/sysconfig' )
128+ for service in st2api st2actionrunner; do
129+ service_config=" ${service_config_path} /${service} "
130+ # create file if doesn't exist yet
131+ sudo test -e ${service_config} || sudo touch ${service_config}
132+ for env_var in http_proxy https_proxy no_proxy proxy_ca_bundle_path; do
133+ # delete line from file if specific proxy env var is unset
134+ if sudo test -z " ${! env_var:- } " ; then
135+ sudo sed -i " /^${env_var} =/d" ${service_config}
136+ # add proxy env var if it doesn't exist yet
137+ elif ! sudo grep -s -q ^" ${env_var} =" ${service_config} ; then
138+ sudo sh -c " echo '${env_var} =${! env_var} ' >> ${service_config} "
139+ # modify existing proxy env var value
140+ elif ! sudo grep -s -q ^" ${env_var} =${! env_var} $" ${service_config} ; then
141+ sudo sed -i " s#^${env_var} =.*#${env_var} =${! env_var} #" ${service_config}
142+ fi
143+ done
144+ done
145+ }
146+
118147function get_package_url() {
119148 # Retrieve direct package URL for the provided dev build, subtype and package name regex.
120149 DEV_BUILD=$1 # Repo name and build number - <repo name>/<build_num> (e.g. st2/5646)
@@ -671,6 +700,7 @@ trap 'fail' EXIT
671700STEP=" Setup args" && setup_args $@
672701STEP=" Check TCP ports and MongoDB storage requirements" && check_st2_host_dependencies
673702STEP=" Generate random password" && generate_random_passwords
703+ STEP=" Configure Proxy" && configure_proxy
674704STEP=" Install st2 dependencies" && install_st2_dependencies
675705STEP=" Install st2 dependencies (MongoDB)" && install_mongodb
676706STEP=" Install st2" && install_st2
0 commit comments