33set -e
44
55VERSION=' 0.1'
6+
67DOCKER_COMPOSE=$( which docker-compose)
78BASE_COMPOSE=' /etc/moodle-docker/docker-compose.yml'
89THEME_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
1215function print_usage {
@@ -25,16 +28,23 @@ Actions:
2528 version, -v, --version Print ${0} version and exit
2629
2730Parameters:
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
3134Examples:
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
3437Version: ${VERSION}
3538EOF
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+
3848function 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