moodle-tools is no longer under active development. Deployment strategies are easier than ever with Git; I may, however, go back sometime and look at backup/restore functionality via the command line.
moodle-tools is a collect of programs used to facilitate administering Moodle installations. Configuration files store information about one or more servers, and all moodle-tools programs use this configuration data.
Every program included in moodle-tools shows helpful output with the -h or
--help option. Similar to Git, you can also get help on a command by running
mdl help COMMAND.
-
mdl server- Shows server configuration data as defined in an XML-based configuration file. This XML file allows you to define an installation directory and a data directory for one or more installations of Moodle on one or more servers.Other programs that need to access information about your Moodle installations will use the output from
mdl serverto do so.mdl servertries to locate a valid XML file in the following order:- Look for the file passed by the command line (
mdl server -f FILEormdl server --file=FILE) - Look for the file defined by the environment variable named
MDL_SERVER_CONFIG - Look for a file named
mdl-server.xmlin the current working directory
Note that if the environment variable exists and points to a valid file, you MUST pass
-for--fileif you want to specify a different file (havingmdl-server.xmlin your working directory is not enough, as the environment variable takes precedence).See the file
src/mdl-server-schema.xmlfor the details of how to construct this XML file, andsrc/mdl-server.sample.xmlfor a sample file. - Look for the file passed by the command line (
mdl archive- Archive a working git branch or a source distribution to a filemdl deploy- Deploy a working git branch, source distribution, or archive file to a working Moodle installation. Can use data frommdl serverto determine installation locationsmdl maintenance- Turn maintenance mode on or off for a Moodle installation.mdl backup- Back up certain parts of a Moodle installation, including source code, data directory, and database schema and data.mdl roll-course- Back up a current course and restore it into a new course. (Might be easier to use RPC mechanisms?)
moodle-tools is written in Python, so you will obviously need a working installation. Currently, any version after 2.4 will work. I personally currently use version 2.6.1.
moodle-tools itself currently depends on no non-standard modules.
Unit tests using nose and coverage (the default in rununittests.sh) requires the coverage module and the nose package.
Install from the root of the repository by running sudo python setup.py install. Create a source distribution by running python setup.py sdist.
clean.sh is a bash script located at the root of the repository that helps
clean up your repository (and system, after an install).
Running clean.sh with no parameters removes all .pyc files, the .coverage
file created during unit testing, and the MANIFEST file generated by
setup.py.
Running clean.sh uninstall attempts to uninstall moodle-tools from your
system. It does this in the following way:
- Find out where Python keeps installed packages by looking at
distutils.sysconfig.get_python_lib(). - Removing
MoodleToolsfrom the Python library path. - Removing
moodle_tools-*.egg-infofrom the Python library path. - Removing
mdlandmdl-*from/usr/local/bin. (Currently it only removes a hard-coded list of files--justmdlandmdl-serverfor now.)
In either case, clean.sh runs checks to see if it can find any remnants of a
moodle-tools installation on your system. It does the following:
ls /usr/local/bin/mdl*to try to find scripts that weren't removed.- Checking for the existance of the MoodleTools folder in the Python library path.
moodle-tools is still in very early planning and development. I decided to put it on GitHub to get things organized and give anyone who might be crazy enough to be interested a chance to take a look at it.
Most of these tools stem from specific needs that I have managing the multiple Moodle installations I have to administer, so some of the tools may feel very specific, and the package may feel pretty narrow. I'd like to expand this into a generic toolset that works for a good number of other people.
If you'd like to contribute code, feel free to fork the project, make changes,
and initiate a pull request. It'd be nice if changes came with documentation
and unit tests, but it's not required (yet). I'm not 100% sure how I want
the documentation to work yet (HTML? man pages?), so I haven't checked anything
in quite yet. However, every program should present helpful information
via mdl-program --help or mdl-program -h.
Clone the project with git clone git://github.com/BinaryMuse/moodle-tools.git
Notes (thoughts, discussion, etc.) for moodle-tools is held at the GitHub wiki for moodle-tools.
If you are working off of the source distribution of moodle-tools (checked out from git or downloaded as a source archive), your directory structure should resemble the following:
.gitignore
LICENSE
MANIFEST.in
README.md
clean.sh
rununittests.sh
setup.py
src/
source files
test/
unit tests
To run the unit tests, be sure to have the nose module installed, change
directories into the root of the source distribution, and run
./rununittests. This runs nosetests with the appropriate coverage options.
If you don't have coverage installed, a simple nosetests will run just the
tests.
Copyright (c) 2010, Fresno Pacific University
Licensed under the New BSD license; see the LICENSE file for details.
