-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
swdc
executable file
·88 lines (69 loc) · 2.13 KB
/
swdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
export COMPOSE_PROJECT_NAME="shopware-docker"
export DOCKER_COMPOSE_FILE="/tmp/swdc-docker-compose.yml"
if ! docker compose 1> /dev/null 2> /dev/null; then
echo "> docker-compose v2 is now required. Please install from https://docs.docker.com/compose/install/"
exit 1
fi
FILE="$0"
if [[ -L "$0" ]]; then
FILE="$(readlink "${0}")"
fi
DIR="$(dirname "${FILE}")"
REALDIR="$(cd "$(dirname "${DIR}")" && pwd)/$(basename "${DIR}")"
DIR=$REALDIR
CONFIG_DIR=${XDG_CONFIG_HOME:-${HOME}/.config}
export DIR="${DIR}"
export REALDIR="${REALDIR}"
# shellcheck source=functions.sh
source "${DIR}/functions.sh"
if [[ ! -d "${CONFIG_DIR}/swdc" ]]; then
mkdir -p "${CONFIG_DIR}/swdc"
fi
if [[ -f "${HOME}/.swdc_env" ]]; then
mv "${HOME}/.swdc_env" "${CONFIG_DIR}/swdc/env"
fi
if [[ ! -f "${CONFIG_DIR}/swdc/env" ]]; then
cp "${DIR}/.env.dist" "${CONFIG_DIR}/swdc/env"
fi
# shellcheck source=.env.dist
source "${DIR}/.env.dist"
# shellcheck source=.env.dist
source "${CONFIG_DIR}/swdc/env"
# shellcheck source=docker.env
source "${DIR}/docker.env"
if [[ ! -d "${CONFIG_DIR}/swdc/ssl" ]]; then
mkdir -p "${CONFIG_DIR}/swdc/ssl"
generate_wildcard_certs
fi
SHOPWARE_PROJECT="$2"
export SHOPWARE_FOLDER="${CODE_DIRECTORY}/${SHOPWARE_PROJECT}"
# Need to be in docker folder for docker-compose
cd "${DIR}" || exit 1
modules=(base)
if [[ -f "${CODE_DIRECTORY}/${2}/src/Kernel.php" || -f "${CODE_DIRECTORY}/${2}/src/Core/composer.json" || -f "$SHOPWARE_FOLDER/bin/build-js.sh" ]]; then
modules=(base platform-local)
fi
if [[ "${1}" == "" ]]; then
source modules/base/command-list.sh
exit 1
fi
for module in "${modules[@]}"; do
# shellcheck source=/dev/null
if [[ -f "./modules/${module}/${1}.sh" ]]; then
# shellcheck source=/dev/null
source "./modules/${module}/${1}.sh"
exit 0
fi
# shellcheck source=/dev/null
if [[ -f "$HOME/.config/swdc/modules/${module}/${1}.sh" ]]; then
# shellcheck source=/dev/null
source "$HOME/.config/swdc/modules/${module}/${1}.sh"
exit 0
fi
done
if [[ "$RUN_MODE" == 'local' ]]; then
source "$REALDIR/swdc-inside"
else
compose exec cli bash /opt/swdc/swdc-inside "$@"
fi