Created
May 23, 2023 09:16
-
-
Save lilydjwg/a25ab503e5b5a7a0d293cf0bae78baf5 to your computer and use it in GitHub Desktop.
recover /rsyncd-munged/ symlinks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
'''recover /rsyncd-munged/ symlinks''' | |
import sys | |
import os | |
def main(topdir): | |
for root, dirs, files in os.walk(topdir): | |
for f in files: | |
path = os.path.join(root, f) | |
try: | |
dest = os.readlink(path) | |
except OSError: | |
continue | |
if dest.startswith('/rsyncd-munged/'): | |
realdest = dest.removeprefix('/rsyncd-munged/') | |
os.unlink(path) | |
print(f'{path} should point to {realdest}') | |
os.symlink(realdest, path) | |
if __name__ == '__main__': | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment