Skip to content

Commit 1a3c082

Browse files
authored
Merge pull request #6546 from phil-hands/debian_configure_web_proxy
configure_web_proxy: deal with Debian configuration
2 parents 4db9ac5 + 19a3923 commit 1a3c082

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

script/configure-web-proxy

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,33 @@ done
3939

4040
echo -e "[openid]\nhttpsonly = 0" > /etc/openqa/openqa.ini.d/01-enable-http-auth.ini
4141

42+
etc_proxy=/etc/${web_proxy/apache/apache2}
43+
for v in vhosts.d sites-available; do
44+
if [[ -e "${etc_proxy}/${v}/openqa.conf.template" ]]; then
45+
vhosts_dir="${etc_proxy}/${v}"
46+
break
47+
fi
48+
done
49+
50+
if [[ -z $vhosts_dir ]]; then
51+
printf "%s: ERROR: template file not found under '%s'\n" "$0" "$etc_proxy"
52+
exit 1
53+
fi
54+
4255
if [[ $web_proxy == "nginx" ]]; then
4356
echo "Setting up nginx"
44-
sed "s/openqa.example.com/$(hostname)/" /etc/nginx/vhosts.d/openqa.conf.template > /etc/nginx/vhosts.d/openqa.conf
57+
sed "s/openqa.example.com/$(hostname)/" "${vhosts_dir}/openqa.conf.template" > "${vhosts_dir}/openqa.conf"
4558
# IPv6 uses [::]:80 syntax instead of just a port
4659
if [[ -n "$web_port" ]]; then
47-
sed -Ei "s@(.*listen.*)80@\1${web_port}@g" /etc/nginx/vhosts.d/openqa.conf /etc/nginx/nginx.conf
60+
sed -Ei "s@(.*listen.*)80@\1${web_port}@g" "${vhosts_dir}/openqa.conf" "${etc_proxy}/nginx.conf"
4861
fi
4962
sed -i -e 's/^\([^#]*server_name[[:space:]]\+localhost;\)/#\1/' /etc/nginx/nginx.conf
5063
elif [[ $web_proxy == "apache" || $web_proxy == "apache2" ]]; then
5164
echo "Setting up apache"
5265
for i in headers proxy proxy_http proxy_wstunnel rewrite; do a2enmod $i; done
53-
sed "s/#ServerName.*$/ServerName $(hostname)/" /etc/apache2/vhosts.d/openqa.conf.template > /etc/apache2/vhosts.d/openqa.conf
66+
sed "s/#ServerName.*$/ServerName $(hostname)/" "${vhosts_dir}/openqa.conf.template" > "${vhosts_dir}/openqa.conf"
5467
if [[ -n "$web_port" ]]; then
55-
sed -i "s/^Listen.*$/Listen $web_port/" /etc/apache2/listen.conf
68+
sed -i "s/^Listen.*$/Listen $web_port/" "${etc_proxy}/listen.conf"
5669
fi
5770
else
5871
echo "No supported proxy: $web_proxy"

0 commit comments

Comments
 (0)