X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Froles%2Ffiles%2Fstatic-mirroring%2Fstatic-master-run;h=95c9355a5ffc6172f550f8489a09c1ebbae47fd7;hb=5dc5997952b5754e99c246f2887057de4ad4b126;hp=e7e8b2d92a0b478bb6ed68a0c628e686b3dee615;hpb=a3d0ee7754397443a449a5916e709ed0f8660ef1;p=mirror%2Fdsa-puppet.git diff --git a/modules/roles/files/static-mirroring/static-master-run b/modules/roles/files/static-mirroring/static-master-run index e7e8b2d92..95c9355a5 100755 --- a/modules/roles/files/static-mirroring/static-master-run +++ b/modules/roles/files/static-mirroring/static-master-run @@ -22,9 +22,9 @@ with open(conffile) as f: (name, value) = line.split("=") config[name] = value -for key in ('base'): +for key in ('base',): if not key in config: - raise Exception("Configuration element '%s' not found in config file %s", key, conffile) + raise Exception("Configuration element '%s' not found in config file %s"%(key, conffile)) allclients = set() with open('/etc/static-clients.conf') as f: @@ -174,14 +174,25 @@ def run_mirror(component): os.chmod(tmpdir_new, 0755) locks = [] - for p in (componentdir, live, tmpdir_new): - if not os.path.exists(p): os.mkdir(p, 0755) + lockfiles = [ os.path.join(basemaster, component + ".lock") ] + for p in lockfiles: fd = os.open(p, os.O_RDONLY) log("Acquiring lock for %s(%d)."%(p,fd)) fcntl.flock(fd, fcntl.LOCK_EX) locks.append(fd) log("All locks acquired.") + for p in (live, ): + if not os.path.exists(p): os.mkdir(p, 0755) + + #for p in (componentdir, live, tmpdir_new): + # if not os.path.exists(p): os.mkdir(p, 0755) + # fd = os.open(p, os.O_RDONLY) + # log("Acquiring lock for %s(%d)."%(p,fd)) + # fcntl.flock(fd, fcntl.LOCK_EX) + # locks.append(fd) + #log("All locks acquired.") + serialfile = os.path.join(componentdir, serialname) try: with open(serialfile) as f: serial = int(f.read())