update
This commit is contained in:
43
ctl.py
43
ctl.py
@@ -12,7 +12,7 @@ import os
|
|||||||
import pty
|
import pty
|
||||||
|
|
||||||
def di_syscall(cmd, workdir='.'):
|
def di_syscall(cmd, workdir='.'):
|
||||||
#print('[dbg] CMD: %s' % (cmd))
|
#print('[dbg] CMD: %s | WD: %s' % (cmd, workdir))
|
||||||
process = subprocess.run(cmd, capture_output=True, cwd=workdir)
|
process = subprocess.run(cmd, capture_output=True, cwd=workdir)
|
||||||
return (process.stdout.decode("utf-8").strip(), process.stderr.decode("utf-8").strip())
|
return (process.stdout.decode("utf-8").strip(), process.stderr.decode("utf-8").strip())
|
||||||
|
|
||||||
@@ -56,6 +56,41 @@ def get_config(path):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def create_example_config():
|
||||||
|
conf_raw = """{
|
||||||
|
# Container name
|
||||||
|
name: example--config
|
||||||
|
# Name container in log/output/console
|
||||||
|
title: Example Config
|
||||||
|
# Image container
|
||||||
|
image: hello-world:linux
|
||||||
|
# (optional) Shell command for container
|
||||||
|
shell: sh
|
||||||
|
# (optional) Signal for update configuration in container
|
||||||
|
upd-sig: HUP
|
||||||
|
# (optional) Arguments|Params for containered application
|
||||||
|
cmd: [
|
||||||
|
--arg_key
|
||||||
|
value
|
||||||
|
]
|
||||||
|
# (optional) Ports
|
||||||
|
ports: [
|
||||||
|
0.0.0.0:8080:80
|
||||||
|
]
|
||||||
|
# (optional) Volumes
|
||||||
|
volumes: [
|
||||||
|
/etc/timezone:/etc/timezone:ro
|
||||||
|
/etc/localtime:/etc/localtime:ro
|
||||||
|
]
|
||||||
|
# (optional) Environment
|
||||||
|
env: {
|
||||||
|
ENV_KEY: value
|
||||||
|
}
|
||||||
|
}"""
|
||||||
|
fd = open('./container.conf', 'w')
|
||||||
|
fd.write(conf_raw)
|
||||||
|
fd.close()
|
||||||
|
|
||||||
# -------------------------- #
|
# -------------------------- #
|
||||||
|
|
||||||
class Container:
|
class Container:
|
||||||
@@ -161,6 +196,11 @@ class Container:
|
|||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
print_help_exit()
|
print_help_exit()
|
||||||
|
|
||||||
|
if sys.argv[1] == 'init':
|
||||||
|
print('Create example config')
|
||||||
|
create_example_config()
|
||||||
|
exit()
|
||||||
|
|
||||||
conf = None
|
conf = None
|
||||||
begin_index_commands = None
|
begin_index_commands = None
|
||||||
workdir = None
|
workdir = None
|
||||||
@@ -168,6 +208,7 @@ if os.path.isfile(sys.argv[1]):
|
|||||||
conf = get_config(sys.argv[1])
|
conf = get_config(sys.argv[1])
|
||||||
begin_index_commands = 2
|
begin_index_commands = 2
|
||||||
workdir = os.path.dirname(sys.argv[1])
|
workdir = os.path.dirname(sys.argv[1])
|
||||||
|
if len(workdir) == 0: workdir = '.'
|
||||||
else:
|
else:
|
||||||
conf = get_config('container.conf')
|
conf = get_config('container.conf')
|
||||||
begin_index_commands = 1
|
begin_index_commands = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user