diff --git a/script/configure-web-proxy b/script/configure-web-proxy index 12785966dd3..e9297e5a557 100755 --- a/script/configure-web-proxy +++ b/script/configure-web-proxy @@ -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 diff --git a/script/openqa-bootstrap b/script/openqa-bootstrap index 562025e794a..1c04b894749 100755 --- a/script/openqa-bootstrap +++ b/script/openqa-bootstrap @@ -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 @@ -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 @@ -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