debian-koji-osbuild/test/container/hub/run-hub.sh
Lars Karlitski 16f762c2ed test: move to koji-osbuild-tests package
This is similar to how other osbuild packages are testing: everything
that's needed for testing is included in the tests package or a
dependency of it. The test runner then runs every executable in
/usr/libexec/tests/<packagename>. This gives a simple test API to
projects depending on this package (notably osbuild-composer).

The local development workflow described in HACKING.md is meant to
continue to work. To ensure this, all relevant scripts gained a
TEST_DATA variable, which defaults to `./test`, but is set from $1 to
the installed path from integration.sh.
2020-11-19 09:28:28 +01:00

63 lines
1.9 KiB
Bash
Executable file

#!/bin/bash
set -eux
if ls /share/rpms/*.rpm 1> /dev/null 2>&1; then
echo "Using RPMs"
rpm -i /share/rpms/koji-osbuild-?-0.*.rpm \
/share/rpms/koji-osbuild-hub-*.rpm
else
echo "Using local plugin"
cp /share/plugins/hub/osbuild.py /usr/lib/koji-hub-plugins/
fi
# Set DB credentials
sed -i -e "s/.*DBHost =.*/DBHost = ${POSTGRES_HOST}/" \
-e "s/.*DBUser =.*/DBUser = ${POSTGRES_USER}/" \
-e "s/.*DBPass =.*/DBPass = ${POSTGRES_PASSWORD}/" \
-e "s/.*DBName =.*/DBName = ${POSTGRES_DB}/" \
-e "s|.*AuthPrincipal =.*|AuthPrincipal = host/kojihub@LOCAL|" \
-e "s|.*AuthKeytab =.*|AuthKeytab = /share/koji.keytab|" \
-e "s|.*KojiDebug =.*|KojiDebug = On|" \
-e "s|.*LogLevel =.*|LogLevel = DEBUG|" \
/etc/koji-hub/hub.conf
sed -i -e "s|LogLevel warn|LogLevel debug|" /etc/httpd/conf/httpd.conf
tee -a /etc/httpd/conf.d/kojihub.conf <<END
<Location /kojihub/ssllogin>
AuthType GSSAPI
GssapiSSLonly Off
GssapiLocalName Off
AuthName "GSSAPI Single Sign On Login"
GssapiCredStore keytab:/share/koji.keytab
Require valid-user
</Location>
END
sed -i -e "s|^#ServerName.*|ServerName localhost|" \
/etc/httpd/conf/httpd.conf
# wait for postgres to come on-line
timeout 10 bash -c "until printf '' 2>/dev/null >/dev/tcp/${POSTGRES_HOST}/5432; do sleep 0.1; done"
# psql uses PGPASSWORD env variable
export PGPASSWORD="${POSTGRES_PASSWORD}"
# create an "alias" for the long psql command
psql_cmd() {
psql -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" "$@"
}
# initialize the database if it isn't initialized already
if ! psql_cmd -c "select * from users" &>/dev/null; then
psql_cmd -f /usr/share/doc/koji/docs/schema.sql >/dev/null
fi
# ensure /mnt/koji is owned by apache
chown -R apache:apache /mnt/koji
# signal we are ready via a file
touch /share/hub.init
# run apache
httpd -DFOREGROUND