diff --git a/examples/tunasync.ini b/examples/tunasync.ini index 2558ca4..f716943 100644 --- a/examples/tunasync.ini +++ b/examples/tunasync.ini @@ -13,7 +13,7 @@ max_retry = 2 [btrfs] service_dir = {mirror_root}/{mirror_name}/_current working_dir = {mirror_root}/{mirror_name}/_working -gc_dir = {mirror_root}/{mirror_name}/_gc_{timestamp} +gc_dir = {mirror_root}/{mirror_name}/_gc_{{timestamp}} # rmirror:archlinux] diff --git a/systemd/tunasync-snapshot-gc@.service b/systemd/tunasync-snapshot-gc.service similarity index 80% rename from systemd/tunasync-snapshot-gc@.service rename to systemd/tunasync-snapshot-gc.service index 6bb4fb1..21a25fe 100644 --- a/systemd/tunasync-snapshot-gc@.service +++ b/systemd/tunasync-snapshot-gc.service @@ -5,7 +5,7 @@ After = network.target [Service] Type=simple -ExecStart=/home/tuna/.virtualenvs/tunasync/bin/python -u /home/tuna/tunasync/tunasync_snapshot_gc.py %i +ExecStart=/home/tuna/.virtualenvs/tunasync/bin/python -u /home/tuna/tunasync/tunasync_snapshot_gc.py -c /etc/tunasync.ini [Install] WantedBy = multi-user.target diff --git a/systemd/tunasync-snapshot-gc@.timer b/systemd/tunasync-snapshot-gc.timer similarity index 75% rename from systemd/tunasync-snapshot-gc@.timer rename to systemd/tunasync-snapshot-gc.timer index 57ec5ab..674e6a1 100644 --- a/systemd/tunasync-snapshot-gc@.timer +++ b/systemd/tunasync-snapshot-gc.timer @@ -3,7 +3,6 @@ Description=TUNAsync GC every 10 minutes [Timer] OnUnitActiveSec=10min -Unit=tunasync-snapshot-gc@%i.service [Install] WantedBy=multi-user.target diff --git a/tunasync_snapshot_gc.py b/tunasync_snapshot_gc.py index 3b80f7e..60957f8 100644 --- a/tunasync_snapshot_gc.py +++ b/tunasync_snapshot_gc.py @@ -3,13 +3,14 @@ import re import sh import os +import ConfigParser import argparse if __name__ == "__main__": parser = argparse.ArgumentParser(prog="tunasync_snapshot_gc") parser.add_argument("--max-level", type=int, default=2, help="max walk level to find garbage snapshots") parser.add_argument("--pattern", default=r"^_gc_\d+", help="pattern to match garbage snapshots") - parser.add_argument("mirror_root", help="tunasync mirror root") + parser.add_argument("-c", "--config", help="tunasync config file") args = parser.parse_args() @@ -31,6 +32,10 @@ if __name__ == "__main__": else: walk(abs_fname, level+1) - walk(args.mirror_root) + settings = ConfigParser.ConfigParser() + settings.read(args.config) + mirror_root = settings.get("global", "mirror_root") + + walk(mirror_root) # vim: ts=4 sw=4 sts=4 expandtab