added support for fallback config files
This commit is contained in:
parent
bb089bf19c
commit
7a95b46c73
3 changed files with 22 additions and 13 deletions
|
@ -6,14 +6,27 @@ import json
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
def load_cfg(path):
|
||||
with open(path) as f:
|
||||
return json.loads(jsmin.jsmin(f.read()))
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) == 2:
|
||||
cfg_path = sys.argv[1]
|
||||
else:
|
||||
cfg_path = "/etc/safe-harbor/config.json"
|
||||
# try config files in the order they are passed to us
|
||||
# first one wins
|
||||
|
||||
with open(cfg_path) as f:
|
||||
cfg = json.loads(jsmin.jsmin(f.read()))
|
||||
cfg = None
|
||||
|
||||
for path in sys.argv[1:]:
|
||||
try:
|
||||
cfg = load_cfg(path)
|
||||
break
|
||||
except Exception as e:
|
||||
print("! cfg file %s failed to load (%s)" %(path, e))
|
||||
|
||||
|
||||
if not cfg:
|
||||
print("!!! unable to load any configuration")
|
||||
sys.exit(1)
|
||||
|
||||
command = ["/usr/bin/ssh", "-o", "ServerAliveInterval 45", "-o", "ServerAliveCountMax 2", "-o", "ExitOnForwardFailure yes", "-N"]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue