marc/sync.py
2022-07-31 22:39:46 +02:00

67 lines
2 KiB
Python
Executable file

#! /usr/bin/env python3
import os
import subprocess
import pubnix
ARGS = [
{'dn':'aussies.space', 'sub': False},
{'dn':'blinkenshell.org',
'ssh': 'ssh', 'port': 2222, 'web': 'u', 'sub': True},
{'dn':'ctrl-c.club', 'sub': False},
{'dn':'dimension.sh', 'sub': True},
{'dn':'envs.net', 'sub': True},
{'dn':'fr.tild3.org', 'sub': True},
{'dn':'freeshell.de', 'sub': False},
{'dn':'heathens.club', 'root': 'www', 'sub': False},
{'dn':'hextilde.xyz', 'sub': True},
{'dn':'insomnia247.nl', 'dir': True, 'sub': True},
{'dn':'remotes.club', 'port': 9022, 'root': 'web', 'sub': True},
{'dn':'rw.rs', 'sub': False},
{'dn':'squiggle.city', 'sub': False},
{'dn':'thunix.net', 'sub': False},
{'dn':'tilde.cafe', 'sub': True},
{'dn':'tilde.club', 'sub': False},
{'dn':'tilde.fun', 'root': 'html', 'sub': False},
{'dn':'tilde.green', 'sub': True},
{'dn':'tilde.guru', 'sub': False},
{'dn':'tilde.institute', 'sub': True},
{'dn':'tilde.pink', 'sub': False},
{'dn':'tilde.team', 'sub': True},
{'dn':'tilde.town', 'sub': False},
{'dn':'sdf.org', 'root': 'html', 'sub': True},
{'dn':'southlondon.cc', 'sub': False},
]
PUBNIXES = [pubnix.PubNix(**args) for args in ARGS]
def sync(root, pubnix, exclude=None):
args = [
'rsync',
'--archive',
'--checksum',
'--delete-before',
'--rsh', f"ssh -o 'LogLevel Error' -p {pubnix.port}",
'--partial',
'--progress',
'--verbose',
os.path.join(root, str()),
]
for item in exclude:
args.extend(['--exclude', os.path.join(str(), item)])
args.append(os.path.join(pubnix.target, str()))
subprocess.call(args, stdout=subprocess.DEVNULL)
def main():
root = os.path.dirname(os.path.realpath(__file__))
for pubnix in PUBNIXES:
print()
print(pubnix)
sync(root, pubnix, exclude=['__pycache__', 'cnam', 'pgp.asc'])
# pubnix.disk_free()
if __name__ == '__main__':
main()