// Moodle Development Kit configuration file
//
-// A comment in this file MUST be preceded by white spaces or nothing
+// A comment in this file MUST be preceded by white spaces or nothing.
+//
+// This configuration file will be looked for in those directories:
+// - ~/.moodle-sdk/config.json
+// - /etc/moodle-sdk/config.json
+// - <MDK>/config.json
//
{
// Directories to work with.
- // All 3 of them must exist.
+ // All of them must exist and must be writeable by the current user.
// www and storage CANNOT point to the same directory and must be writeable.
"dirs": {
- // The web directory you are going to access Moodle from. A symlink will be created here.
- "www": "/var/www",
- // The directory where the instances will be stored
+ // The web directory you are going to access Moodle from, typically your virtual host DocumentRoot.
+ // A symlink to the web directory of your Moodle instance will be created here.
+ "www": "/var/lib/moodle-sdk/www",
+ // The directory where the instances will be stored.
"storage": "~/moodles",
- // A directory used by MDK to store different kind of things such as backups and cached repositories.
- "moodle": "~/.moodle-sdk"
+ // A directory used by MDK to store different kind of things such as scripts and backups.
+ "moodle": "~/.moodle-sdk",
+ // Global MDK storage folder. Used for cached repositories and stuff which can be shared system-wide.
+ "mdk": "/var/lib/moodle-sdk/storage"
},
// List of remotes to work with
},
// The host name to set during an install
- "host": "localhost",
+ "host": "moodle-sdk",
+ // Path to your Moodle instances, http://host/path/ should point to dirs.www.
+ "path": "",
// Moodle admin login
"login": "admin",
// Moodle admin password
db.createdb(dbname)
db.selectdb(dbname)
+ # Defining wwwroot.
+ wwwroot = 'http://%s/' % C.get('host')
+ if C.get('path') != '' and C.get('path') != None:
+ wwwroot = wwwroot + C.get('path') + '/'
+ wwwroot = wwwroot + self.identifier
+
debug('Installing %s...' % self.identifier)
cli = 'admin/cli/install.php'
- params = (C.get('host'), self.identifier, dataDir, engine, dbname, C.get('db.%s.user' % engine), C.get('db.%s.passwd' % engine), C.get('db.%s.host' % engine), fullname, self.identifier, C.get('login'), C.get('passwd'))
- args = '--wwwroot="http://%s/%s/" --dataroot="%s" --dbtype="%s" --dbname="%s" --dbuser="%s" --dbpass="%s" --dbhost="%s" --fullname="%s" --shortname="%s" --adminuser="%s" --adminpass="%s" --allow-unstable --agree-license --non-interactive' % params
+ params = (wwwroot, dataDir, engine, dbname, C.get('db.%s.user' % engine), C.get('db.%s.passwd' % engine), C.get('db.%s.host' % engine), fullname, self.identifier, C.get('login'), C.get('passwd'))
+ args = '--wwwroot="%s" --dataroot="%s" --dbtype="%s" --dbname="%s" --dbuser="%s" --dbpass="%s" --dbhost="%s" --fullname="%s" --shortname="%s" --adminuser="%s" --adminpass="%s" --allow-unstable --agree-license --non-interactive' % params
result = self.cli(cli, args, stdout=None, stderr=None)
if result[0] != 0:
raise Exception('Error while running the install, please manually fix the problem.')
# Directory paths
self.path = os.path.abspath(os.path.realpath(os.path.expanduser(path)))
- self.cache = os.path.abspath(os.path.realpath(os.path.expanduser(C.get('dirs.moodle'))))
+ self.cache = os.path.abspath(os.path.realpath(os.path.expanduser(C.get('dirs.mdk'))))
self.www = os.path.abspath(os.path.realpath(os.path.expanduser(C.get('dirs.www'))))
# Directory names
myremoteurl = C.get('remotes.mine')
if C.get('useCacheAsRemote'):
- remoteInt = os.path.abspath(os.path.realpath(os.path.join(C.get('dirs.moodle'), 'integration.git')))
- remoteSta = os.path.abspath(os.path.realpath(os.path.join(C.get('dirs.moodle'), 'moodle.git')))
+ remoteInt = os.path.abspath(os.path.realpath(os.path.join(C.get('dirs.mdk'), 'integration.git')))
+ remoteSta = os.path.abspath(os.path.realpath(os.path.join(C.get('dirs.mdk'), 'moodle.git')))
else:
remoteInt = C.get('remotes.integration')
remoteSta = C.get('remotes.stable')