- shutdown, reboot, poweron: Power management
- tty: Open TTY in GNU Screen
- sanity, sanity-sh: SSH sanity tests, ignore
+
+Define a configuration file in ~/.libremanage.json. See the included
+config.json for an example. Servers correspond to managed servers; managers
+correspond to single-board computers connecting the servers. libremanage SSHs
+into the manager to access the server through the side-channel.
"""
import sys
import json
import functools
import subprocess
+import os.path
def open_ssh(server, command, force_tty=False):
config = server["ssh"]
- subprocess.run(["ssh", "-t" if force_tty else "", config["username"] + "@" + config["host"], "-p", str(config["port"]), command])
+ args = ["ssh"] + (["-t"] if force_tty else []) + [config["username"] + "@" + config["host"], "-p", str(config["port"]), command]
+ subprocess.run(args)
def die_with_usage(message):
print(message)
# Load configuration, get command, and go!
-with open("config.json") as f:
- CONFIG = json.load(f)
+try:
+ with open(os.path.expanduser("~/.libremanage.json")) as f:
+ CONFIG = json.load(f)
+except FileNotFoundError:
+ die_with_usage("Configuration file missing in ~/.libremanage.json")
if len(sys.argv) != 3:
die_with_usage("Incorrect number of arguments")