diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 2e91822e..55f2d2ac 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -186,6 +186,32 @@ def configure_ssl_ciphers(al): 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): msg = [""] * 5 for th in threading.enumerate(): @@ -490,6 +516,11 @@ def main(argv=None): if HAVE_SSL: ensure_cert() + for k, v in zip(argv, argv[1:]): + if k == "-c": + supp = args_from_cfg(v) + argv.extend(supp) + deprecated = [["-e2s", "-e2ds"]] for dk, nk in deprecated: try: diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 6931767a..1658f6a0 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -546,6 +546,7 @@ class AuthSrv(object): def _parse_config_file(self, fd, acct, daxs, mflags, mount): # type: (any, str, dict[str, AXS], any, str) -> None + skip = False vol_src = None vol_dst = None self.line_ctr = 0 @@ -555,6 +556,11 @@ class AuthSrv(object): vol_src = None vol_dst = None + if skip: + if not ln: + skip = False + continue + if not ln or ln.startswith("#"): continue @@ -562,6 +568,8 @@ class AuthSrv(object): if ln.startswith("u "): u, p = ln[2:].split(":", 1) acct[u] = p + elif ln.startswith("-"): + skip = True # argv else: vol_src = ln continue diff --git a/docs/example.conf b/docs/example.conf index 5c836e30..1fe868f3 100644 --- a/docs/example.conf +++ b/docs/example.conf @@ -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: # u username:password u ed:123