Skip to content

Instantly share code, notes, and snippets.

@jramnai
Last active March 8, 2024 20:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save jramnai/9da820c9ed7b2bc0d4c1cae52b777099 to your computer and use it in GitHub Desktop.
Save jramnai/9da820c9ed7b2bc0d4c1cae52b777099 to your computer and use it in GitHub Desktop.
Useful command of Tutor Open edX

Tutor Open edX useful commands

Tutor Installation

Requirements

  • Docker: v18.06.0+
  • Docker Compose: v1.22.0+
  • Ports 80 and 443 should be open
  • Hardware:
    • Minimum configuration: 4 GB RAM, 2 CPU, 8 GB disk space
    • Recommended configuration: 8 GB RAM, 4 CPU, 25 GB disk space
  • Other requirements:
    sudo apt install python3 python3-pip libyaml-dev
    

Installation

There are 2 ways to install Tutor:

  1. Install with pip:
    pip install "tutor[full]==v13.3.0"
    
    Or download the pre-compiled binary and place the tutor executable in your path:
    sudo curl -L "https://github.com/overhangio/tutor/releases/download/v13.3.0/tutor-$(uname -s)_$(uname -m)" -o /usr/local/bin/tutor
    sudo chmod 0755 /usr/local/bin/tutor
    
  2. Run tutor local quickstart
    • Answer a few questions
  3. And Open edX is installed!

Useful Commands

  • List down all available commands under tutor

    tutor local help
    
  • Stop, Start, Restart

    tutor local stop
    tutor local start -d
    tutor local restart
    tutor local restart lms
    
  • Check logs

    # Change lms with the service name for which you want to check logs
    tutor local logs lms -f --tail 100
    
  • Tracking logs directory

    (tutor config printroot)/data/lms/logs/tracking.log
    (tutor config printroot)/data/cms/logs/tracking.log
    
  • Check all container status

    tutor local status
    
  • Create a user with staff and admin access

    tutor local createuser --staff --superuser -pedx edx edx@example.com
    
  • Import the demo course

    tutor local importdemocourse
    
  • Set theme

    # For first time only
    git clone https://github.com/jramnai/mytheme.git
    cp -r /home/ubuntu/mytheme "$(tutor config printroot)/env/build/openedx/themes/"
    tutor local settheme mytheme
    
    # If there is some change in `mytheme`
    cd mytheme
    git pull origin main
    rm -rf "$(tutor config printroot)/env/build/openedx/themes/mytheme"
    cp -r /home/ubuntu/mytheme "$(tutor config printroot)/env/build/openedx/themes/"
    tutor local settheme mytheme
    
  • Running management commands, find some useful management commands here

    tutor local run cms ./manage.py cms reindex_course --all --setup --settings tutor.production
    tutor local run lms ./manage.py lms compile_sass --settings tutor.production
    
  • Reloading Open edX settings

    tutor local exec lms reload-uwsgi
    
  • Open service/container shell

    # replace lms with your service/container name
    tutor local exec lms bash
    tutor local exec mysql bash
    
  • Installing extra requirement

    # For first time only
    cd $(tutor config printroot)/env/build/openedx/requirements/
    git clone https://github.com/jramnai/my_package.git
    echo "-e ./my_package" >> "$(tutor config printroot)/env/build/openedx/requirements/private.txt"
    tutor images build openedx --build-arg EDX_PLATFORM_REPOSITORY=https://github.com/jramnai/edx-platform.git --build-arg EDX_PLATFORM_VERSION=open-release/maple.master
    tutor local stop
    tutor local start -d
    
    # If there is some change in `my_package`
    cd $(tutor config printroot)/env/build/openedx/requirements/my_package
    git pull origin main
    tutor images build openedx --build-arg EDX_PLATFORM_REPOSITORY=https://github.com/jramnai/edx-platform.git --build-arg EDX_PLATFORM_VERSION=open-release/maple.master
    tutor local stop
    tutor local start -d
    

    or simple

    echo "git+https://github.com/open-craft/xblock-pdf@b4e404b1f94ffab15c52de5c1382d61235cd8c81#egg=xblock-pdf==1.1.0" >> "$(tutor config printroot)/env/build/openedx/requirements/private.txt"
    tutor images build openedx --build-arg EDX_PLATFORM_REPOSITORY=https://github.com/jramnai/edx-platform.git --build-arg EDX_PLATFORM_VERSION=open-release/maple.master
    tutor local stop
    tutor local start -d
    
  • View config.yml file content

    cat "$(tutor config printroot)/config.yml"
    
  • Set parameter in config.yml file

    tutor config save --set PARAM1=VALUE1 --set PARAM2=VALUE2
    
  • Print config value

    tutor config printvalue OPENEDX_COMMON_VERSION
    
  • Create tutor image build

    tutor images build openedx --build-arg EDX_PLATFORM_REPOSITORY=https://github.com/jramnai/edx-platform.git --build-arg EDX_PLATFORM_VERSION=open-release/maple.master
    or
    tutor images build openedx --no-cache --build-arg EDX_PLATFORM_REPOSITORY=https://github.com/jramnai/edx-platform.git --build-arg EDX_PLATFORM_VERSION=open-release/maple.master
    
  • Install and enable plugin

    pip install tutor-myapp
    tutor plugins enable myapp
    tutor local quickstart
    
  • List installed plugins

    tutor plugins list
    
  • Enable/disable a plugin

    tutor plugins enable myplugin
    tutor plugins disable myplugin
    tutor config save
    
  • Print location of plugin root

    tutor plugins printroot
    
  • Using Gmail as an SMTP server

    • Check connectivity
      telnet smtp.gmail.com 587
      
    • Disable Tutor SMTP server
      tutor config save --set RUN_SMTP=false
      
    • Configure SMTP credentials
      tutor config save \
      --set SMTP_HOST=smtp.gmail.com \
      --set SMTP_PORT=587 \
      --set SMTP_USE_SSL=false  \
      --set SMTP_USE_TLS=true \
      --set SMTP_USERNAME=YOURUSERNAME@gmail.com \
      --set SMTP_PASSWORD='YOURPASSWORD'
      
    • Restart your platform
      tutor local quickstart
      
    • Test it
      tutor local run --no-deps lms ./manage.py lms shell -c \
        "from django.core.mail import send_mail; send_mail('test subject', 'test message', 'YOURUSERNAME@gmail.com', ['YOURRECIPIENT@domain.com'])"
      
  • Creating DB dumps

    tutor local exec \
        -e USERNAME="$(tutor config printvalue MYSQL_ROOT_USERNAME)" \
        -e PASSWORD="$(tutor config printvalue MYSQL_ROOT_PASSWORD)" \
        mysql sh -c 'mysqldump --all-databases --user=$USERNAME --password=$PASSWORD > /var/lib/mysql/dump.sql'
    tutor local exec mongodb mongodump --out=/data/db/dump.mongodb
    

    The dump.sql and dump.mongodb files will be located in $(tutor config printroot)/data/mysql and $(tutor config printroot)/data/mongodb.

  • Changing Open edX settings (or Creating a Tutor plugin)

    • Create plugins root folder
      mkdir -p "$(tutor plugins printroot)"
      
    • Create an empty “myplugin.py” file in this folder
      touch "$(tutor plugins printroot)/myplugin.py"
      
    • Verify plugin is correctly detected
      tutor plugins list
      
    • Add content in myplugin.py file (the setting which you want to set/modify)
      from tutor import hooks
      
      hooks.Filters.ENV_PATCHES.add_item(
          (
              "openedx-common-settings",
              """
      X_FRAME_OPTIONS = "ALLOWALL"
      """
          )
      )
      
    • Enable the myplugin
      tutor plugins enable myplugin
      
    • Re-render your environment
      tutor config save
      
    • Restart the platform
      tutor local restart
      

References

@wittjeff
Copy link

wittjeff commented Mar 8, 2024

Where you have
tutor local importdemocourse
it should be
tutor local do importdemocourse
Thanks for writing this doc!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment