Skip to content

Commit

Permalink
Allow nginx setup via configure-web-proxy and openqa-bootstrap script
Browse files Browse the repository at this point in the history
  • Loading branch information
asdil12 committed Jul 6, 2023
1 parent 816add8 commit 4fd97ce
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
25 changes: 20 additions & 5 deletions script/configure-web-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,39 @@
usage() {
cat << EOF
Usage: configure-web-proxy
Configure a local web proxy using apache for openQA.
Configure a local web proxy for openQA.
Options:
-h, --help display this help
-p, --proxy=PROXY web proxy to configure (default: apache)
choose from: nginx, apache
EOF
exit "$1"
}

opts=$(getopt -o h --long help -n "$0" -- "$@") || usage 1
opts=$(getopt -o hp: -l help -l proxy: -n "$0" -- "$@") || usage 1
eval set -- "$opts"
web_proxy="apache"
while true; do
case "$1" in
-h | --help ) usage 0; shift ;;
-h | --help ) usage 0; shift ;;
-p | --proxy ) web_proxy=${2#*=}; shift ;;
-- ) shift; break ;;
* ) break ;;
esac
done

for i in headers proxy proxy_http proxy_wstunnel rewrite ; do a2enmod $i ; done
sed -i -e 's/^.*httpsonly.*$/httpsonly = 0/g' /etc/openqa/openqa.ini
sed "s/#ServerName.*$/ServerName $(hostname)/" /etc/apache2/vhosts.d/openqa.conf.template > /etc/apache2/vhosts.d/openqa.conf

if [ "$web_proxy" = "nginx" ] ; then
echo "Setting up nginx"
sed "s/openqa.example.com/$(hostname)/" /etc/nginx/vhosts.d/openqa.conf.template > /etc/nginx/vhosts.d/openqa.conf
sed -i -e "s/\(^[^#]*server_name localhost;\)/#\1/" /etc/nginx/nginx.conf
elif [ "$web_proxy" = "apache" ] || [ "$web_proxy" = "apache2" ] ; then
echo "Setting up apache"
for i in headers proxy proxy_http proxy_wstunnel rewrite ; do a2enmod $i ; done
sed "s/#ServerName.*$/ServerName $(hostname)/" /etc/apache2/vhosts.d/openqa.conf.template > /etc/apache2/vhosts.d/openqa.conf
else
echo "No supported proxy: $web_proxy"
exit 1
fi
26 changes: 18 additions & 8 deletions script/openqa-bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dbuser="${dbuser:="geekotest"}"
running_systemd=
skip_suse_specifics="${skip_suse_specifics:=""}"
skip_suse_tests="${skip_suse_tests:=""}"
setup_web_proxy="${setup_web_proxy:=""}"

if [ "$(ps --no-headers -o comm 1)" = 'systemd' ]; then
running_systemd=1
Expand Down Expand Up @@ -48,8 +49,9 @@ fi
su postgres -c "/usr/share/openqa/script/setup-db" $dbuser $dbname

# setup webserver and fake-auth
[[ -n "$setup_web_proxy" ]] && proxy_args="--proxy=$setup_web_proxy"
setup=/usr/share/openqa/script/configure-web-proxy
(command -v $setup && sh -ex $setup) || (curl -s https://raw.githubusercontent.com/os-autoinst/openQA/master/script/configure-web-proxy | bash -ex)
(command -v $setup && sh -ex $setup "$proxy_args") || (curl -s https://raw.githubusercontent.com/os-autoinst/openQA/master/script/configure-web-proxy | bash -ex -s "$proxy_args")
sed -i -e 's/#*.*method.*=.*$/method = Fake/' /etc/openqa/openqa.ini


Expand Down Expand Up @@ -101,14 +103,22 @@ grep -q "$(hostname)" /etc/hosts || echo "127.0.0.1 $(hostname)" >> /etc/hosts

# start daemons
if [ -z "$running_systemd" ]; then
pgrep -f openqa-scheduler-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-scheduler-daemon &
pgrep -f openqa-websockets-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-websockets-daemon &
pgrep -f openqa-gru >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-gru &
pgrep -f openqa-livehandler-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon &
/usr/sbin/start_apache2 -k start
pgrep -f openqa-webui-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-webui-daemon &
pgrep -f openqa-scheduler-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-scheduler-daemon &
pgrep -f openqa-websockets-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-websockets-daemon &
pgrep -f openqa-gru >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-gru &
pgrep -f openqa-livehandler-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-livehandler-daemon &
if [[ $setup_web_proxy == "nginx" ]] ; then
nginx
else
/usr/sbin/start_apache2 -k start
fi
pgrep -f openqa-webui-daemon >/dev/null || su geekotest -c /usr/share/openqa/script/openqa-webui-daemon &
else
systemctl enable --now apache2
if [[ $setup_web_proxy == "nginx" ]] ; then
systemctl enable --now nginx
else
systemctl enable --now apache2
fi
systemctl enable --now openqa-webui
systemctl enable --now openqa-scheduler
fi
Expand Down

0 comments on commit 4fd97ce

Please sign in to comment.