Skip to content

Commit

Permalink
Enable localcachedir as configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsihk authored Jun 7, 2024
1 parent f2468ca commit 58473e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ Define the ENV variables in docker-compose.yml file
| AUTO_UPDATE_MOODLE | true | Set to false to disable performing update of Moodle (e.g. plugins) at docker start |
| UPDATE_MOODLE_CODE | true | Set to false to disable auto download latest patch of Moodle core code, only effective if AUTO_UPDATE_MOODLE is true or built with ARG_ENABLE_GIT_CLONE as true |
| DISABLE_WEB_INSTALL_PLUGIN | false | Set to true to disable plugin installation via site admin UI, could be useful to avoid image outsync with HA setting |
| MAINT_STATUS_KEYWORD | Status: enabled | Keyword for detecting Moodle maintainence status when running admin/cli/maintenance.php, language following the Moodle site default language |
| MAINT_STATUS_KEYWORD | Status: enabled | Keyword for detecting Moodle maintenance status when running admin/cli/maintenance.php, language following the Moodle site default language |
| LOCAL_CACHE_DIRECTORY | | Set the path to a local fast filesystem for Moodle local caching that no need to be shared with other instances |

### Important Note about using `AUTO_UPDATE_MOODLE` and `UPDATE_MOODLE_CODE`

Expand Down
24 changes: 23 additions & 1 deletion rootfs/docker-entrypoint-init.d/02-configure-moodle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,29 @@ if [ ! -f "${WEB_PATH}"/config.php ]; then
# shellcheck disable=SC2016
sed -i '/require_once/i $CFG->xsendfile = '\''X-Accel-Redirect'\'';' "${WEB_PATH}"/config.php
# shellcheck disable=SC2016
sed -i '/require_once/i $CFG->xsendfilealiases = array('\''\/dataroot\/'\'' => $CFG->dataroot);' "${WEB_PATH}"/config.php
sed -i '/require_once/i $CFG->xsendfilealiases = array(' "${WEB_PATH}"/config.php
# shellcheck disable=SC2016
sed -i "/\$CFG->xsendfilealiases/a );" "${WEB_PATH}"/config.php
# shellcheck disable=SC2016
sed -i "/\$CFG->xsendfilealiases/a \ \ "\''/dataroot/'\'" => \$CFG->dataroot," "${WEB_PATH}"/config.php

if [ -n "$LOCAL_CACHE_DIRECTORY" ]; then
if [ ! -d "$LOCAL_CACHE_DIRECTORY" ]; then
echo "Creating $LOCAL_CACHE_DIRECTORY for localcachedir..."
mkdir -p "$LOCAL_CACHE_DIRECTORY"
fi
# shellcheck disable=SC2016
sed -i "/require_once/i \$CFG->localcachedir = \'$LOCAL_CACHE_DIRECTORY\';" "${WEB_PATH}"/config.php
# shellcheck disable=SC2016
sed -i "/\$CFG->xsendfilealiases/a \ \ "\''/localcachedir/'\'" => \'$LOCAL_CACHE_DIRECTORY\'," "${WEB_PATH}"/config.php
cat << EOL >> /etc/nginx/conf.d/default/server/moodle.conf
location ~ ^/localcachedir/(.*)$ {
internal;
alias $LOCAL_CACHE_DIRECTORY/\$1;
}
EOL
echo "Set $LOCAL_CACHE_DIRECTORY as localcachedir"
fi

if [ "$SSLPROXY" = 'true' ]; then
# shellcheck disable=SC2016
Expand Down

0 comments on commit 58473e8

Please sign in to comment.