From: Frederic Massart Date: Tue, 4 Dec 2012 09:35:11 +0000 (+0800) Subject: Subpaths support and system-wide storage folder support X-Git-Tag: v0.2~12 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=442ebf710af236a874e24d0117afb150259cc58e;p=mdk.git Subpaths support and system-wide storage folder support --- diff --git a/config-dist.json b/config-dist.json index 4efacc5..8042147 100644 --- a/config-dist.json +++ b/config-dist.json @@ -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 +// - /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 diff --git a/lib/moodle.py b/lib/moodle.py index 500639b..9ab26f2 100644 --- a/lib/moodle.py +++ b/lib/moodle.py @@ -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.') diff --git a/lib/workplace.py b/lib/workplace.py index 6cc113d..585942e 100644 --- a/lib/workplace.py +++ b/lib/workplace.py @@ -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 diff --git a/moodle-check.py b/moodle-check.py index e113df6..621c97f 100755 --- a/moodle-check.py +++ b/moodle-check.py @@ -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')