This repository was archived by the owner on Jan 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Mount theme directory for theme development #26
Open
mroote
wants to merge
5
commits into
develop
Choose a base branch
from
feature/mount_theme_directory
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
|
|
||
| # Build version | ||
| BUILD_VERSION=v0.1.12 | ||
| BUILD_VERSION=v0.1.13 | ||
|
|
||
| # Moodle version | ||
| MOODLE_VERSION=3.5.2 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # This file contains configuration for theme development | ||
| --- | ||
|
|
||
| version: '3.6' | ||
|
|
||
| services: | ||
| nginx-php-moodle: | ||
| volumes: | ||
| - type: volume | ||
| source: theme | ||
| target: /opt/moodle/app/theme | ||
|
|
||
| volumes: | ||
| theme: | ||
| driver: local | ||
| driver_opts: | ||
| type: none | ||
| o: bind | ||
| device: /opt/moodle/theme/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e | ||
|
|
||
| VERSION='0.1' | ||
|
|
||
| DOCKER_COMPOSE=$(which docker-compose) | ||
| BASE_COMPOSE='/etc/moodle-docker/docker-compose.yml' | ||
| THEME_COMPOSE='/etc/moodle-docker/dc.theme-dev.yml' | ||
| BASE_COMMAND="${DOCKER_COMPOSE} --file ${BASE_COMPOSE}" | ||
|
|
||
| THEME_DIR='/opt/moodle/theme' | ||
|
|
||
| # Print usage and argument list | ||
| function print_usage { | ||
| cat << EOF | ||
| usage: ${0} options | ||
|
|
||
| This script will create an organization and update the associated DNS record. | ||
|
|
||
| OPTIONS: | ||
| Actions: | ||
| clean | ||
| down | ||
| stop | ||
| restart | ||
| up | ||
| version, -v, --version Print ${0} version and exit | ||
|
|
||
| Parameters: | ||
| -d Detach from running docker-compose containers | ||
| -t Mount theme directory to host for theme development | ||
|
|
||
| Examples: | ||
| "${0} start -d -t" Start Moodle in detached mode with theme directory mounted to host. | ||
|
|
||
| Version: ${VERSION} | ||
| EOF | ||
| } | ||
|
|
||
| function ensure_theme_dir { | ||
| if [ ! -d "${THEME_DIR}" ] ; then | ||
| echo "Theme directory not found, creating ${THEME_DIR}" | ||
| mkdir -p "${THEME_DIR}" | ||
| fi | ||
| } | ||
|
|
||
| function clean_moodle { | ||
| local compose_command="${BASE_COMMAND}" | ||
|
|
||
| if [ "${THEME_DEV}" == 'True' ] ; then | ||
| compose_command="${compose_command} --file ${THEME_COMPOSE}" | ||
| fi | ||
| compose_command="${compose_command} rm" | ||
|
|
||
| eval "${compose_command}" | ||
| } | ||
|
|
||
| function down_moodle { | ||
| local compose_command="${BASE_COMMAND}" | ||
|
|
||
| if [ "${THEME_DEV}" == 'True' ] ; then | ||
| compose_command="${compose_command} --file ${THEME_COMPOSE}" | ||
| fi | ||
| compose_command="${compose_command} down" | ||
|
|
||
| eval "${compose_command}" | ||
| } | ||
|
|
||
| function stop_moodle { | ||
| local compose_command="${BASE_COMMAND}" | ||
|
|
||
| if [ "${THEME_DEV}" == 'True' ] ; then | ||
| compose_command="${compose_command} --file ${THEME_COMPOSE}" | ||
| fi | ||
| compose_command="${compose_command} stop" | ||
|
|
||
| eval "${compose_command}" | ||
| } | ||
|
|
||
| function restart_moodle { | ||
| local compose_command="${BASE_COMMAND}" | ||
|
|
||
| if [ "${THEME_DEV}" == 'True' ] ; then | ||
| ensure_theme_dir | ||
| compose_command="${compose_command} --file ${THEME_COMPOSE}" | ||
| fi | ||
| compose_command="${compose_command} restart" | ||
|
|
||
| eval "${compose_command}" | ||
| } | ||
|
|
||
| function up_moodle { | ||
| local compose_command="${BASE_COMMAND}" | ||
|
|
||
| if [ "${THEME_DEV}" == 'True' ] ; then | ||
| ensure_theme_dir | ||
| compose_command="${compose_command} --file ${THEME_COMPOSE}" | ||
| fi | ||
| compose_command="${compose_command} up" | ||
|
|
||
| if [ "${DETACH}" == 'True' ] ; then | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment about |
||
| compose_command="${compose_command} --detach" | ||
| fi | ||
|
|
||
| eval "${compose_command}" | ||
| } | ||
|
|
||
| subcommand="${1:-}" | ||
| shift | ||
|
|
||
| while getopts ":dt" opt; do | ||
| case ${opt} in | ||
| 'd') DETACH='True' ;; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make these |
||
| 't') THEME_DEV='True' ;; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as the other boolean variable |
||
| '?') | ||
| color_echo red "Invalid option: -${OPTARG}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do you load |
||
| print_usage | ||
| exit 0 | ||
| ;; | ||
| ':') | ||
| color_echo red "Missing option argument for -${OPTARG}" | ||
| print_usage | ||
| exit 0 | ||
| ;; | ||
| '*') # Anything else | ||
| color_echo red "Unknown error while processing options" | ||
| print_usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # Run the right subcommand | ||
| case "${subcommand}" in | ||
| 'start'|'up') | ||
| up_moodle | ||
|
|
||
| exit 0 | ||
| ;; | ||
| 'stop') | ||
| stop_moodle | ||
|
|
||
| exit 0 | ||
| ;; | ||
| 'restart') | ||
| restart_moodle | ||
|
|
||
| exit 0 | ||
| ;; | ||
| 'down') | ||
| down_moodle | ||
|
|
||
| exit 0 | ||
| ;; | ||
| 'clean') | ||
| clean_moodle | ||
|
|
||
| exit 0 | ||
| ;; | ||
| 'help'|'--help'|'-h') # Help | ||
| print_usage | ||
| exit 0 | ||
| ;; | ||
| 'version'|'--version'|'-v') # Version | ||
| color_echo green "Version: ${VERSION}" | ||
| exit 0 | ||
| ;; | ||
| *) # Invalid subcommand | ||
| color_echo red "Invalid subcommand \"${subcommand}\"" | ||
| print_usage | ||
| exit 64 | ||
| ;; | ||
| esac | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably abstract out this
ifblock into a function and reuse it the other places with the same code