From 955b320565faa072f284cf4156020ce5811979ad Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Fri, 25 Mar 2022 12:23:28 +0100 Subject: Set portal username and pass with env vars --- ci/docker/docker-compose.yml | 6 ++++++ ci/docker/starteduvpn.sh | 15 +++++++++++---- ci/startcompose.sh | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100755 ci/startcompose.sh (limited to 'ci') diff --git a/ci/docker/docker-compose.yml b/ci/docker/docker-compose.yml index 12ad767..6c42e1f 100644 --- a/ci/docker/docker-compose.yml +++ b/ci/docker/docker-compose.yml @@ -1,5 +1,9 @@ version: '3' +x-common-env: &common-env + PORTAL_USER: ${PORTAL_USER} + PORTAL_PASS: ${PORTAL_PASS} + networks: eduvpn_network: ipam: @@ -20,6 +24,7 @@ services: ipv4_address: 172.20.0.5 cap_add: # needed for wireguard - NET_ADMIN + environment: *common-env healthcheck: test: ["CMD", "systemctl", "status", "wg-quick@wg0"] # Wait for wireguard to come online interval: 5s @@ -29,6 +34,7 @@ services: build: context: "." dockerfile: 'ci/docker/go-test.docker' + environment: *common-env depends_on: eduvpnserver: condition: service_healthy diff --git a/ci/docker/starteduvpn.sh b/ci/docker/starteduvpn.sh index 191ef79..cddf88c 100644 --- a/ci/docker/starteduvpn.sh +++ b/ci/docker/starteduvpn.sh @@ -1,5 +1,15 @@ #!/usr/bin/env bash +if [[ -z "${PORTAL_USER}" ]]; then + printf "Error: No portal username set, set the PORTAL_USER env var\n" + exit 1 +fi + +if [[ -z "${PORTAL_PASS}" ]]; then + printf "Error: No portal username set, set the PORTAL_PASS env var\n" + exit 1 +fi + systemctl start php-fpm systemctl start httpd systemctl start crond @@ -9,9 +19,6 @@ sleep 5 vpn-maint-apply-changes -USER_NAME="docker" -USER_PASS="docker" - -sudo -u apache vpn-user-portal-account --add "${USER_NAME}" --password "${USER_PASS}" +sudo -u apache vpn-user-portal-account --add "${PORTAL_USER}" --password "${PORTAL_PASS}" sleep infinity diff --git a/ci/startcompose.sh b/ci/startcompose.sh new file mode 100755 index 0000000..90f360c --- /dev/null +++ b/ci/startcompose.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +if [[ -z "${PORTAL_USER}" ]]; then + printf "Error: No portal username set, set the PORTAL_USER env var\n" + exit 1 +fi + +if [[ -z "${PORTAL_PASS}" ]]; then + printf "Error: No portal username set, set the PORTAL_PASS env var\n" + exit 1 +fi + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker-compose --file ci/docker/docker-compose.yml --project-directory $SCRIPT_DIR/.. up --abort-on-container-exit -- cgit v1.2.3