mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
support setting argv from config files
This commit is contained in:
parent
3498644055
commit
8164910fe8
|
@ -186,6 +186,32 @@ def configure_ssl_ciphers(al):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
def args_from_cfg(cfg_path):
|
||||||
|
ret = []
|
||||||
|
skip = False
|
||||||
|
with open(cfg_path, "rb") as f:
|
||||||
|
for ln in [x.decode("utf-8").strip() for x in f]:
|
||||||
|
if not ln:
|
||||||
|
skip = False
|
||||||
|
continue
|
||||||
|
|
||||||
|
if ln.startswith("#"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not ln.startswith("-"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if skip:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
ret.extend(ln.split(" ", 1))
|
||||||
|
except:
|
||||||
|
ret.append(ln)
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def sighandler(sig=None, frame=None):
|
def sighandler(sig=None, frame=None):
|
||||||
msg = [""] * 5
|
msg = [""] * 5
|
||||||
for th in threading.enumerate():
|
for th in threading.enumerate():
|
||||||
|
@ -490,6 +516,11 @@ def main(argv=None):
|
||||||
if HAVE_SSL:
|
if HAVE_SSL:
|
||||||
ensure_cert()
|
ensure_cert()
|
||||||
|
|
||||||
|
for k, v in zip(argv, argv[1:]):
|
||||||
|
if k == "-c":
|
||||||
|
supp = args_from_cfg(v)
|
||||||
|
argv.extend(supp)
|
||||||
|
|
||||||
deprecated = [["-e2s", "-e2ds"]]
|
deprecated = [["-e2s", "-e2ds"]]
|
||||||
for dk, nk in deprecated:
|
for dk, nk in deprecated:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -546,6 +546,7 @@ class AuthSrv(object):
|
||||||
|
|
||||||
def _parse_config_file(self, fd, acct, daxs, mflags, mount):
|
def _parse_config_file(self, fd, acct, daxs, mflags, mount):
|
||||||
# type: (any, str, dict[str, AXS], any, str) -> None
|
# type: (any, str, dict[str, AXS], any, str) -> None
|
||||||
|
skip = False
|
||||||
vol_src = None
|
vol_src = None
|
||||||
vol_dst = None
|
vol_dst = None
|
||||||
self.line_ctr = 0
|
self.line_ctr = 0
|
||||||
|
@ -555,6 +556,11 @@ class AuthSrv(object):
|
||||||
vol_src = None
|
vol_src = None
|
||||||
vol_dst = None
|
vol_dst = None
|
||||||
|
|
||||||
|
if skip:
|
||||||
|
if not ln:
|
||||||
|
skip = False
|
||||||
|
continue
|
||||||
|
|
||||||
if not ln or ln.startswith("#"):
|
if not ln or ln.startswith("#"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -562,6 +568,8 @@ class AuthSrv(object):
|
||||||
if ln.startswith("u "):
|
if ln.startswith("u "):
|
||||||
u, p = ln[2:].split(":", 1)
|
u, p = ln[2:].split(":", 1)
|
||||||
acct[u] = p
|
acct[u] = p
|
||||||
|
elif ln.startswith("-"):
|
||||||
|
skip = True # argv
|
||||||
else:
|
else:
|
||||||
vol_src = ln
|
vol_src = ln
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
# append some arguments to the commandline;
|
||||||
|
# the first space in a line counts as a separator,
|
||||||
|
# any additional spaces are part of the value
|
||||||
|
-e2dsa
|
||||||
|
-e2ts
|
||||||
|
-i 127.0.0.1
|
||||||
|
|
||||||
# create users:
|
# create users:
|
||||||
# u username:password
|
# u username:password
|
||||||
u ed:123
|
u ed:123
|
||||||
|
|
Loading…
Reference in a new issue