Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit ce1830d

Browse files
author
Mitch Roote
committed
Ensure host theme directory exists before starting
1 parent 8f61b94 commit ce1830d

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

run.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
set -e
44

55
VERSION='0.1'
6+
67
DOCKER_COMPOSE=$(which docker-compose)
78
BASE_COMPOSE='/etc/moodle-docker/docker-compose.yml'
89
THEME_COMPOSE='/etc/moodle-docker/dc.theme-dev.yml'
9-
BASE_COMMAND="${DOCKER_COMPOSE} --file \"${BASE_COMPOSE}\""
10+
BASE_COMMAND="${DOCKER_COMPOSE} --file ${BASE_COMPOSE}"
11+
12+
THEME_DIR='/opt/moodle/theme'
1013

1114
# Print usage and argument list
1215
function print_usage {
@@ -25,16 +28,23 @@ Actions:
2528
version, -v, --version Print ${0} version and exit
2629
2730
Parameters:
28-
-d Run Moodle in development mode
31+
-d Detach from running docker-compose containers
2932
-t Mount theme directory to host for theme development
3033
3134
Examples:
32-
"${0} start -d" Start Moodle in development mode
35+
"${0} start -d -t" Start Moodle in detached mode with theme directory mounted to host.
3336
3437
Version: ${VERSION}
3538
EOF
3639
}
3740

41+
function ensure_theme_dir {
42+
if [ ! -d "${THEME_DIR}" ] ; then
43+
echo "Theme directory not found, creating ${THEME_DIR}"
44+
mkdir -p "${THEME_DIR}"
45+
fi
46+
}
47+
3848
function clean_moodle {
3949
local compose_command="${BASE_COMMAND}"
4050

@@ -72,6 +82,7 @@ function restart_moodle {
7282
local compose_command="${BASE_COMMAND}"
7383

7484
if [ "${THEME_DEV}" == 'True' ] ; then
85+
ensure_theme_dir
7586
compose_command="${compose_command} --file ${THEME_COMPOSE}"
7687
fi
7788
compose_command="${compose_command} restart"
@@ -83,6 +94,7 @@ function up_moodle {
8394
local compose_command="${BASE_COMMAND}"
8495

8596
if [ "${THEME_DEV}" == 'True' ] ; then
97+
ensure_theme_dir
8698
compose_command="${compose_command} --file ${THEME_COMPOSE}"
8799
fi
88100
compose_command="${compose_command} up"

0 commit comments

Comments
 (0)