-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Bring setup of test env to next level - Remove unused vcr stuff
- Loading branch information
Showing
6 changed files
with
43 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,5 @@ setuptools | |
PyYAML | ||
bumpversion | ||
pytest | ||
pytest-replay | ||
pytest-vcr | ||
pytest-xdist | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,51 @@ | ||
#!/bin/bash | ||
|
||
exec 10>&1 | ||
exec > /dev/null 2>&1 | ||
|
||
function info() { | ||
echo "${@}" >&10 | ||
} | ||
|
||
MYSQL_PING='mysqladmin ping -h ${DB_HOST:-127.0.0.1} -P ${DB_PORT:-3306} -u ${MYSQL_ROOT_USER:-root} -p${MYSQL_ROOT_PASSWORD:-rootpw}' | ||
|
||
if grep -q podman <<< $(docker --version 2> /dev/null) ; then | ||
echo "Podman is installed" | ||
info "Podman is installed" | ||
DOCKER_CMD=$(which podman) | ||
fi | ||
|
||
while ! nc -z "${DB_HOST:-127.0.0.1}" "${DB_PORT:-3306}"; do | ||
echo "Waiting for database connection..." | ||
sleep 1 | ||
done | ||
if ${DOCKER_CMD} ps | grep -q docker_phpipam_1 && ! eval ${MYSQL_PING} ; then | ||
|
||
info -n "Waiting for database connection " | ||
while ! eval ${MYSQL_PING} ; do | ||
info -n "." | ||
sleep 1 | ||
done | ||
info | ||
fi | ||
|
||
info "Database is up" | ||
|
||
echo "Database is up" | ||
if [[ $(mysqlshow -u root -prootpw -h 127.0.0.1 -P 3306 phpipam | wc -l) -eq 5 ]] ; then | ||
|
||
echo "Creating database ${DB_NAME:-phpipam}" | ||
${DOCKER_CMD} exec -ti docker_phpipam_1 sh -c 'mysql -h database -u phpipam -pphpipamadmin phpipam < /phpipam/db/SCHEMA.sql' | ||
info "Creating database ${DB_NAME:-phpipam}" | ||
${DOCKER_CMD} exec -ti docker_phpipam_1 sh -c 'mysql -h database -u phpipam -pphpipamadmin phpipam < /phpipam/db/SCHEMA.sql' && ((init_result++)) | ||
|
||
echo "Activating API" | ||
mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE settings SET api=1 WHERE id=1;" | ||
info "Activating API" | ||
mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE settings SET api=1 WHERE id=1;" && ((init_result++)) | ||
|
||
echo "Inserting API application" | ||
mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="INSERT INTO api (app_id, app_code, app_permissions, app_security, app_lock_wait) VALUES ('ansible','aAbBcCdDeEfF00112233445566778899',2,'ssl_token',0);" | ||
info "Inserting API application" | ||
mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="INSERT INTO api (app_id, app_code, app_permissions, app_security, app_lock_wait) VALUES ('ansible','aAbBcCdDeEfF00112233445566778899',2,'ssl_token',0);" && ((init_result++)) | ||
|
||
info "Disable forced password reset" | ||
mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE users SET passChange = 'No' WHERE username = 'Admin';" && ((init_result++)) | ||
|
||
[ "$init_result" -eq 4 ] && result=successful || result=failed | ||
|
||
else | ||
|
||
info "Detabase already initiated" && exit 0 | ||
|
||
fi | ||
|
||
echo "Disable forced password reset" | ||
mysql -u phpipam -pphpipamadmin -h "${DB_HOST:-127.0.0.1}" phpipam --execute="UPDATE users SET passChange = 'No' WHERE username = 'Admin';" | ||
info "Database initialisation $result" |