Skip to content

Commit 086cdb7

Browse files
authored
Merge pull request #766 from hardyjohnson/enhancement/644-env-reinstall-warning
Enhancement/644 env reinstall warning
2 parents 8f34089 + d4704eb commit 086cdb7

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

bin/warden

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33
trap 'error "$(printf "Command \`%s\` at $BASH_SOURCE:$LINENO failed with exit code $?" "$BASH_COMMAND")"' ERR
44

5-
## find directory where this script is located following symlinks if neccessary
5+
## find directory where this script is located following symlinks if necessary
66
readonly WARDEN_DIR="$(
77
cd "$(
88
dirname "$(
@@ -17,6 +17,7 @@ export readonly WARDEN_BIN="${WARDEN_DIR}/bin/warden"
1717
export readonly DOCKER_COMPOSE_COMMAND="${DOCKER_COMPOSE_COMMAND:-"docker compose"}"
1818

1919
source "${WARDEN_DIR}/utils/core.sh"
20+
source "${WARDEN_DIR}/utils/svc.sh"
2021
source "${WARDEN_DIR}/utils/env.sh"
2122

2223
## verify docker is installed

commands/env.cmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ WARDEN_ENV_PATH="$(locateEnvPath)" || exit $?
55
loadEnvConfig "${WARDEN_ENV_PATH}" || exit $?
66
assertDockerRunning
77

8+
## warn if global services are not running
9+
if [[ "${WARDEN_PARAMS[0]}" == "up" ]]; then
10+
assertSvcRunning
11+
fi
12+
813
HOST_UID=$(id -u)
914
HOST_GID=$(id -g)
1015

utils/svc.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
[[ ! ${WARDEN_DIR} ]] && >&2 echo -e "\033[31mThis script is not intended to be run directly!\033[0m" && exit 1
3+
4+
function assertSvcRunning() {
5+
## test for global services running
6+
wardenNetworkName=$(cat ${WARDEN_DIR}/docker/docker-compose.yml | grep -A3 'networks:' | tail -n1 | sed -e 's/[[:blank:]]*name:[[:blank:]]*//g')
7+
wardenNetworkId=$(docker network ls -q --filter name="${wardenNetworkName}")
8+
9+
if [[ -z "${wardenNetworkId}" ]]; then
10+
warning "Warden core services are not currently running.\033[0m Run \033[36mwarden svc up\033[0m to start Warden core services."
11+
fi
12+
}

0 commit comments

Comments
 (0)