forked from gofed/gofed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgofed-docker
executable file
·46 lines (36 loc) · 1.15 KB
/
gofed-docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/env python
import sys
from subprocess import call
import os
from cmdsignature.program import ProgramSignatureParser
from cmdsignature.interpreter import CmdSignatureInterpreter
def getScriptDir(file = __file__):
return os.path.dirname(os.path.realpath(file))
if __name__ == "__main__":
# no command
if len(sys.argv) < 2:
cmd = "docker run -t gofed/gofed:v1.0.0 /home/gofed/gofed/hack/gofed.sh -h"
else:
script_dir = getScriptDir(__file__)
plugin_directory = "%s/cmd" % script_dir
plugins = filter(lambda l: l.endswith(".yml"), os.listdir(plugin_directory))
plugins = map(lambda l: "%s/%s" % (plugin_directory, l), plugins)
parser = ProgramSignatureParser(
"gofed",
script_dir
).parse(
plugins,
sys.argv[1:]
)
flags = parser.getCommandFlags(sys.argv[1])
interpreter = CmdSignatureInterpreter(
map(lambda l: "%s/cmd/%s" % (script_dir, l), flags),
command = sys.argv[1],
task = "gofed",
image = parser.getCommandImage(sys.argv[1]),
binary = "/home/gofed/gofed/hack/gofed.sh",
keep_default_flags = True
)
interpreter.interpret(sys.argv[2:])
cmd = interpreter.dockerSignature()
exit(call(cmd, shell=True))