Skip to content

Commit 310ec8b

Browse files
authored
Merge branch 'master' into wvw/ignore-name
2 parents 3f1fb22 + fdc9aa2 commit 310ec8b

File tree

7 files changed

+122
-0
lines changed

7 files changed

+122
-0
lines changed

scripts/includes/common.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
function configure_proxy() {
2+
# Allow bypassing 'proxy' env vars via sudo
3+
local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path"'
4+
if ! sudo grep -s -q ^"${sudoers_proxy}" /etc/sudoers.d/st2; then
5+
sudo sh -c "echo '${sudoers_proxy}' >> /etc/sudoers.d/st2"
6+
fi
7+
8+
# Configure proxy env vars for 'st2api' and 'st2actionrunner' system configs
9+
# See: https://docs.stackstorm.com/packs.html#installing-packs-from-behind-a-proxy
10+
local service_config_path=$(hash apt-get >/dev/null 2>&1 && echo '/etc/default' || echo '/etc/sysconfig')
11+
for service in st2api st2actionrunner; do
12+
service_config="${service_config_path}/${service}"
13+
# create file if doesn't exist yet
14+
sudo test -e ${service_config} || sudo touch ${service_config}
15+
for env_var in http_proxy https_proxy no_proxy proxy_ca_bundle_path; do
16+
# delete line from file if specific proxy env var is unset
17+
if sudo test -z "${!env_var:-}"; then
18+
sudo sed -i "/^${env_var}=/d" ${service_config}
19+
# add proxy env var if it doesn't exist yet
20+
elif ! sudo grep -s -q ^"${env_var}=" ${service_config}; then
21+
sudo sh -c "echo '${env_var}=${!env_var}' >> ${service_config}"
22+
# modify existing proxy env var value
23+
elif ! sudo grep -s -q ^"${env_var}=${!env_var}$" ${service_config}; then
24+
sudo sed -i "s#^${env_var}=.*#${env_var}=${!env_var}#" ${service_config}
25+
fi
26+
done
27+
done
28+
}
29+
130
function get_package_url() {
231
# Retrieve direct package URL for the provided dev build, subtype and package name regex.
332
DEV_BUILD=$1 # Repo name and build number - <repo name>/<build_num> (e.g. st2/5646)

scripts/st2bootstrap-deb.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
118147
function 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
671700
STEP="Setup args" && setup_args $@
672701
STEP="Check TCP ports and MongoDB storage requirements" && check_st2_host_dependencies
673702
STEP="Generate random password" && generate_random_passwords
703+
STEP="Configure Proxy" && configure_proxy
674704
STEP="Install st2 dependencies" && install_st2_dependencies
675705
STEP="Install st2 dependencies (MongoDB)" && install_mongodb
676706
STEP="Install st2" && install_st2

scripts/st2bootstrap-deb.template.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ trap 'fail' EXIT
396396
STEP="Setup args" && setup_args $@
397397
STEP="Check TCP ports and MongoDB storage requirements" && check_st2_host_dependencies
398398
STEP="Generate random password" && generate_random_passwords
399+
STEP="Configure Proxy" && configure_proxy
399400
STEP="Install st2 dependencies" && install_st2_dependencies
400401
STEP="Install st2 dependencies (MongoDB)" && install_mongodb
401402
STEP="Install st2" && install_st2

scripts/st2bootstrap-el6.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,35 @@ setup_args() {
110110
}
111111

112112

113+
function configure_proxy() {
114+
# Allow bypassing 'proxy' env vars via sudo
115+
local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path"'
116+
if ! sudo grep -s -q ^"${sudoers_proxy}" /etc/sudoers.d/st2; then
117+
sudo sh -c "echo '${sudoers_proxy}' >> /etc/sudoers.d/st2"
118+
fi
119+
120+
# Configure proxy env vars for 'st2api' and 'st2actionrunner' system configs
121+
# See: https://docs.stackstorm.com/packs.html#installing-packs-from-behind-a-proxy
122+
local service_config_path=$(hash apt-get >/dev/null 2>&1 && echo '/etc/default' || echo '/etc/sysconfig')
123+
for service in st2api st2actionrunner; do
124+
service_config="${service_config_path}/${service}"
125+
# create file if doesn't exist yet
126+
sudo test -e ${service_config} || sudo touch ${service_config}
127+
for env_var in http_proxy https_proxy no_proxy proxy_ca_bundle_path; do
128+
# delete line from file if specific proxy env var is unset
129+
if sudo test -z "${!env_var:-}"; then
130+
sudo sed -i "/^${env_var}=/d" ${service_config}
131+
# add proxy env var if it doesn't exist yet
132+
elif ! sudo grep -s -q ^"${env_var}=" ${service_config}; then
133+
sudo sh -c "echo '${env_var}=${!env_var}' >> ${service_config}"
134+
# modify existing proxy env var value
135+
elif ! sudo grep -s -q ^"${env_var}=${!env_var}$" ${service_config}; then
136+
sudo sed -i "s#^${env_var}=.*#${env_var}=${!env_var}#" ${service_config}
137+
fi
138+
done
139+
done
140+
}
141+
113142
function get_package_url() {
114143
# Retrieve direct package URL for the provided dev build, subtype and package name regex.
115144
DEV_BUILD=$1 # Repo name and build number - <repo name>/<build_num> (e.g. st2/5646)
@@ -711,6 +740,7 @@ configure_st2chatops() {
711740

712741
trap 'fail' EXIT
713742
STEP='Parse arguments' && setup_args $@
743+
STEP="Configure Proxy" && configure_proxy
714744
STEP="Check TCP ports and MongoDB storage requirements" && check_st2_host_dependencies
715745
STEP='Check libffi-devel availability' && check_libffi_devel
716746
STEP='Adjust SELinux policies' && adjust_selinux_policies

scripts/st2bootstrap-el6.template.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ configure_st2chatops() {
384384

385385
trap 'fail' EXIT
386386
STEP='Parse arguments' && setup_args $@
387+
STEP="Configure Proxy" && configure_proxy
387388
STEP="Check TCP ports and MongoDB storage requirements" && check_st2_host_dependencies
388389
STEP='Check libffi-devel availability' && check_libffi_devel
389390
STEP='Adjust SELinux policies' && adjust_selinux_policies

scripts/st2bootstrap-el7.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,35 @@ setup_args() {
110110
}
111111

112112

113+
function configure_proxy() {
114+
# Allow bypassing 'proxy' env vars via sudo
115+
local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path"'
116+
if ! sudo grep -s -q ^"${sudoers_proxy}" /etc/sudoers.d/st2; then
117+
sudo sh -c "echo '${sudoers_proxy}' >> /etc/sudoers.d/st2"
118+
fi
119+
120+
# Configure proxy env vars for 'st2api' and 'st2actionrunner' system configs
121+
# See: https://docs.stackstorm.com/packs.html#installing-packs-from-behind-a-proxy
122+
local service_config_path=$(hash apt-get >/dev/null 2>&1 && echo '/etc/default' || echo '/etc/sysconfig')
123+
for service in st2api st2actionrunner; do
124+
service_config="${service_config_path}/${service}"
125+
# create file if doesn't exist yet
126+
sudo test -e ${service_config} || sudo touch ${service_config}
127+
for env_var in http_proxy https_proxy no_proxy proxy_ca_bundle_path; do
128+
# delete line from file if specific proxy env var is unset
129+
if sudo test -z "${!env_var:-}"; then
130+
sudo sed -i "/^${env_var}=/d" ${service_config}
131+
# add proxy env var if it doesn't exist yet
132+
elif ! sudo grep -s -q ^"${env_var}=" ${service_config}; then
133+
sudo sh -c "echo '${env_var}=${!env_var}' >> ${service_config}"
134+
# modify existing proxy env var value
135+
elif ! sudo grep -s -q ^"${env_var}=${!env_var}$" ${service_config}; then
136+
sudo sed -i "s#^${env_var}=.*#${env_var}=${!env_var}#" ${service_config}
137+
fi
138+
done
139+
done
140+
}
141+
113142
function get_package_url() {
114143
# Retrieve direct package URL for the provided dev build, subtype and package name regex.
115144
DEV_BUILD=$1 # Repo name and build number - <repo name>/<build_num> (e.g. st2/5646)
@@ -695,6 +724,7 @@ configure_st2chatops() {
695724

696725
trap 'fail' EXIT
697726
STEP='Parse arguments' && setup_args $@
727+
STEP="Configure Proxy" && configure_proxy
698728
STEP='Install net-tools' && install_net_tools
699729
STEP="Check TCP ports and MongoDB storage requirements" && check_st2_host_dependencies
700730
STEP='Adjust SELinux policies' && adjust_selinux_policies

scripts/st2bootstrap-el7.template.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ configure_st2chatops() {
368368

369369
trap 'fail' EXIT
370370
STEP='Parse arguments' && setup_args $@
371+
STEP="Configure Proxy" && configure_proxy
371372
STEP='Install net-tools' && install_net_tools
372373
STEP="Check TCP ports and MongoDB storage requirements" && check_st2_host_dependencies
373374
STEP='Adjust SELinux policies' && adjust_selinux_policies

0 commit comments

Comments
 (0)