Subpaths support and system-wide storage folder support
authorFrederic Massart <fred@moodle.com>
Tue, 4 Dec 2012 09:35:11 +0000 (17:35 +0800)
committerFrederic Massart <fred@moodle.com>
Wed, 5 Dec 2012 06:15:09 +0000 (14:15 +0800)
config-dist.json
lib/moodle.py
lib/workplace.py
moodle-check.py

index 4efacc5..8042147 100644 (file)
@@ -1,18 +1,26 @@
 // 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
@@ -64,7 +72,9 @@
     },
 
     // 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
index 500639b..9ab26f2 100644 (file)
@@ -266,10 +266,16 @@ class Moodle(object):
             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.')
index 6cc113d..585942e 100644 (file)
@@ -47,7 +47,7 @@ class Workplace(object):
 
         # 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
index e113df6..621c97f 100755 (executable)
@@ -78,8 +78,8 @@ else:
     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')