diff --git a/test/fmf/tests/onboarding/run-onboarding.sh b/test/fmf/tests/onboarding/run-onboarding.sh index 3a3463bed..5351fa3dc 100755 --- a/test/fmf/tests/onboarding/run-onboarding.sh +++ b/test/fmf/tests/onboarding/run-onboarding.sh @@ -8,7 +8,7 @@ STORES_DIR="${CONF_DIR}/stores" MIGRATIONS_BASE_DIR=/usr/share/doc/fdo/migrations/ PRIMARY_IP=$(hostname -I | cut -f 1 -d ' ') DEVICE_CREDENTIAL=/etc/device-credentials -ONBOARDIG_PERFORMED=/etc/device_onboarding_performed +ONBOARDING_PERFORMED=/etc/device_onboarding_performed OWNER_DATABASE="owner_onboarding" MANUFACTURER_DATABASE="manufacturing" @@ -25,6 +25,9 @@ DATABASE_DIR=/var/lib/fdo DATABASE_USER="fdo" DATABASE_PASSWORD="redhat" +[ "$DATABASE_DRIVER" != "postgresql" ] || DATABASE_URL="${DATABASE_DRIVER}://${DATABASE_USER}:${DATABASE_PASSWORD}@127.0.0.1/fdo" +[ "$DATABASE_DRIVER" != "sqlite" ] || DATABASE_URL="${DATABASE_DRIVER}://${DATABASE_DIR}/fido-device-onboard.db" + generate_keys() { ORGANIZATION="Red Hat" COUNTRY="US" @@ -47,43 +50,25 @@ setup_postgresql() { su - postgres -c "dropuser -e --if-exists ${DATABASE_USER}" su - postgres -c "createuser -e ${DATABASE_USER}" su - postgres -c "psql -e -c \"ALTER USER ${DATABASE_USER} WITH PASSWORD '${DATABASE_PASSWORD}'\"" + su - postgres -c "dropdb -e --if-exists fdo" + su - postgres -c "createdb -e -O ${DATABASE_USER} fdo" for DATABASE in ${DATABASES}; do - su - postgres -c "dropdb -e --if-exists ${DATABASE}" - su - postgres -c "createdb -e -O ${DATABASE_USER} ${DATABASE}" - su - postgres -c "PGPASSWORD=${DATABASE_PASSWORD} psql --host 127.0.0.1 --username ${DATABASE_USER} --echo-queries $DATABASE < ${MIGRATIONS_BASE_DIR}/migrations_${DATABASE}_server_postgres/up.sql" + su - postgres -c "PGPASSWORD=${DATABASE_PASSWORD} psql --host 127.0.0.1 --username ${DATABASE_USER} --echo-queries fdo < ${MIGRATIONS_BASE_DIR}/migrations_${DATABASE}_server_postgres/up.sql" done } setup_sqlite() { mkdir -p ${DATABASE_DIR} + DATABASE_FILE="${DATABASE_DIR}/fido-device-onboard.db" + > ${DATABASE_FILE} for DATABASE in ${DATABASES}; do - DATABASE_FILE="${DATABASE_DIR}/${DATABASE}.db" - > ${DATABASE_FILE} sqlite3 ${DATABASE_FILE} < "${MIGRATIONS_BASE_DIR}/migrations_${DATABASE}_server_sqlite/up.sql" done } -setup_systemd() { - for DATABASE in ${DATABASES}; do - SYSTEMD_OVERWRITE_DIR=/etc/systemd/system/fdo-${DATABASE/_/-}-server.service.d/ - rm -rf "$SYSTEMD_OVERWRITE_DIR}" - if [ "${OV_STORE_DRIVER}" != "Directory" ]; then - mkdir -p "${SYSTEMD_OVERWRITE_DIR}" - DATABASE_ENV_VAR="$(tr [:lower:] [:upper:] <<<${OV_STORE_DRIVER})_$(tr [:lower:] [:upper:] <<<$DATABASE |sed -e 's|MANUFACTURING|MANUFACTURER|' -e 's|OWNER_ONBOARDING|OWNER|')_DATABASE_URL" - [ "$DATABASE_DRIVER" != "postgresql" ] || DATABASE_URL="${DATABASE_DRIVER}://${DATABASE_USER}:${DATABASE_PASSWORD}@127.0.0.1/${DATABASE}" - [ "$DATABASE_DRIVER" != "sqlite" ] || DATABASE_URL="${DATABASE_DRIVER}://${DATABASE_DIR}/${DATABASE}.db" - tee "$SYSTEMD_OVERWRITE_DIR/override.conf" <