From: Frederic Massart Date: Wed, 24 Jul 2013 05:48:47 +0000 (+0800) Subject: Run command supports shell scripts X-Git-Tag: v0.4.2~18 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=24e107f6d7aa4b3892d3d1a14c6efce741c11f30;p=mdk.git Run command supports shell scripts --- diff --git a/lib/scripts.py b/lib/scripts.py index 4d16660..6811efb 100644 --- a/lib/scripts.py +++ b/lib/scripts.py @@ -24,6 +24,7 @@ http://github.com/FMCorz/mdk import os import shutil +import stat from tools import process from config import Conf from exceptions import ScriptNotFound, ConflictInScriptName, UnsupportedScript @@ -33,7 +34,7 @@ C = Conf() class Scripts(object): - _supported = ['php'] + _supported = ['php', 'sh'] _dirs = None _list = None @@ -129,6 +130,14 @@ class Scripts(object): cmd = '%s %s' % (C.get('php'), dest) result = process(cmd, cwd=path, **cmdkwargs) os.remove(dest) + elif cli.endswith('.sh'): + dest = os.path.join(path, 'mdkscriptrun.sh') + shutil.copyfile(cli, dest) + os.chmod(dest, stat.S_IRUSR | stat.S_IXUSR) + + cmd = '%s' % (dest) + result = process(cmd, cwd=path, **cmdkwargs) + os.remove(dest) else: raise UnsupportedScript('Script not supported') diff --git a/scripts/README.md b/scripts/README.md index 39ebc05..ba4cd29 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -12,6 +12,10 @@ Formats PHP scripts will be executed from the web directory of an instance. They will be executed as any other CLI script. +### Shell + +Shell scripts will be executed from the web directory of an instance. They will be made executable and run on their own. If you need to access information about the instance from within the shell script, retrieve it using `mdk info`. + Directories -----------