bigeagle 11 rokov pred
rodič
commit
b0e4648dc3

+ 1 - 1
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]

+ 1 - 1
systemd/tunasync-snapshot-gc@.service → 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

+ 0 - 1
systemd/tunasync-snapshot-gc@.timer → 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

+ 7 - 2
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