Skip to content
Snippets Groups Projects
Commit b0695678 authored by Administrator's avatar Administrator
Browse files

Configurable config file path

parent 9b34ccd2
No related branches found
No related tags found
No related merge requests found
......@@ -46,8 +46,9 @@ class Config:
periods = {}
@staticmethod
def load():
def load(config_path=None):
import toml
if config_path is None:
config_path = "config.toml"
global_config_path = "/etc/lvm-snapshot.toml"
ENV_VAR = "LVM_SNAPSHOT_CONFIG"
......@@ -429,7 +430,8 @@ operations = {
def main():
import argparse
parser = argparse.ArgumentParser(description="Manage snapshots of thin LVM volumes")
parser.add_argument("command", choices=["list", "update", "mount", "unmount"], default="list")
parser.add_argument("command", choices=["list", "update", "mount", "unmount"], default="list", nargs="?")
parser.add_argument("--config", help="path to config file", required=False)
parser.add_argument("--verbose", "-v", action="count", help="do not redirect the command output to /dev/null")
args = parser.parse_args()
loglevels = {
......@@ -440,7 +442,7 @@ def main():
}
loglevel = loglevels[min(3, max(0, args.verbose or 0))]
logging.basicConfig(level=loglevel)
Config.parse(Config.load())
Config.parse(Config.load(args.config))
operations[args.command]()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment