marc/sync.py

80 lines
2.5 KiB
Python
Raw Normal View History

2022-05-01 20:58:23 +00:00
#! /usr/bin/env python3
import os
import subprocess
import pubnix
ARGS = [
{'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},
2022-05-29 10:06:48 +00:00
{'dn':'freeshell.de', 'sub': False},
2024-02-24 22:33:54 +00:00
# {'dn':'hextilde.xyz', 'sub': True},
2022-05-01 20:58:23 +00:00
{'dn':'insomnia247.nl', 'dir': True, 'sub': True},
2023-03-02 22:22:55 +00:00
{'dn':'p.projectsegfau.lt', 'sub': True},
2024-02-24 22:22:38 +00:00
# {'dn':'pubnix.pink', 'web': 'sites', 'sub': False},
2023-06-28 08:32:33 +00:00
{'dn':'rawtext.club', 'sub': False},
2022-05-01 20:58:23 +00:00
{'dn':'rw.rs', 'sub': False},
2023-07-25 09:53:59 +00:00
{'dn':'thunix.net', 'sub': False},
2023-06-28 20:05:27 +00:00
{'dn':'tilde.32bit.cafe', 'root': 'www', 'sub': False},
2022-05-01 20:58:23 +00:00
{'dn':'tilde.cafe', 'sub': True},
{'dn':'tilde.club', 'sub': False},
{'dn':'tilde.fun', 'root': 'html', 'sub': False},
2022-08-01 08:49:24 +00:00
{'dn':'tilde.green', 'sub': False},
2022-05-01 20:58:23 +00:00
{'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},
2024-02-24 22:23:59 +00:00
# {'dn':'trash.town', 'sub': False},
2023-10-08 13:00:44 +00:00
# permissions
2024-02-25 18:50:18 +00:00
# {'dn':'sdf.org', 'root': 'html', 'sub': True},
2023-10-08 13:00:44 +00:00
# old
{'dn':'fr.tild3.org', 'sub': True},
{'dn':'remotes.club', 'port': 9022, 'root': 'web', 'sub': True},
{'dn':'squiggle.city', 'sub': False},
# down
# {'dn':'aussies.space', 'sub': False},
# {'dn':'heathens.club', 'root': 'www', 'sub': False},
# {'dn':'vern.cc', 'sub': True},
2022-05-01 20:58:23 +00:00
]
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__))
2023-07-25 12:11:20 +00:00
root = os.path.join(root, 'out', 'web')
2023-10-08 13:00:44 +00:00
dns_length = max([len(pubnix.dn) for pubnix in PUBNIXES])
2022-05-01 20:58:23 +00:00
for pubnix in PUBNIXES:
2023-10-08 13:03:20 +00:00
print()
print(pubnix)
# print(f'{pubnix.dn.rjust(dns_length)} → ', end=str(), flush=True)
2024-02-24 21:32:09 +00:00
sync(root, pubnix, exclude=['__pycache__', 'pgp.asc'])
2023-10-08 13:00:44 +00:00
# print(pubnix.disk_free())
2023-10-08 13:03:20 +00:00
# print(pubnix.os())
2022-05-01 20:58:23 +00:00
if __name__ == '__main__':
main()