Mercurial > code > home > repos > infra
comparison sync.py @ 288:3af02e24eaf9
minor
author | drewp@bigasterisk.com |
---|---|
date | Sun, 21 Apr 2024 17:01:13 -0700 |
parents | 0befc8696a07 |
children | 65e28d2e0cd8 |
comparison
equal
deleted
inserted
replaced
287:c094d23b7943 | 288:3af02e24eaf9 |
---|---|
16 | 16 |
17 def install_syncthing(user, version, os='linux', arch='amd64'): | 17 def install_syncthing(user, version, os='linux', arch='amd64'): |
18 tmpdir = Path('/tmp/syncthing_install') | 18 tmpdir = Path('/tmp/syncthing_install') |
19 dl_name = f'syncthing-{os}-{arch}-{version}' | 19 dl_name = f'syncthing-{os}-{arch}-{version}' |
20 url = f'https://github.com/syncthing/syncthing/releases/download/{version}/{dl_name}.tar.gz' | 20 url = f'https://github.com/syncthing/syncthing/releases/download/{version}/{dl_name}.tar.gz' |
21 files.directory(tmpdir) | 21 files.directory(path=tmpdir) |
22 files.download(url, str(tmpdir / f'{dl_name}.tgz')) # bugreport | 22 files.download(src=url, dest=str(tmpdir / f'{dl_name}.tgz')) # bugreport |
23 server.shell([f'cd {tmpdir}; aunpack {dl_name}.tgz']) | 23 server.shell(commands=[f'cd {tmpdir}; aunpack {dl_name}.tgz']) |
24 | 24 |
25 systemd.service(service=f'syncthing@{user}', running=False) | 25 systemd.service(service=f'syncthing@{user}', running=False) |
26 | 26 |
27 user_svc_template = '/lib/systemd/system/syncthing@.service' | 27 user_svc_template = '/lib/systemd/system/syncthing@.service' |
28 server.shell([ | 28 server.shell(commands=[ |
29 f'cp -a {tmpdir}/{dl_name}/{s} {d}' for s, d in [ | 29 f'cp -a {tmpdir}/{dl_name}/{s} {d}' for s, d in [ |
30 ('syncthing', '/usr/bin'), | 30 ('syncthing', '/usr/bin'), |
31 #('etc/linux-systemd/user/syncthing.service', ''), # unused | |
32 ('etc/linux-systemd/system/syncthing@.service', user_svc_template), | 31 ('etc/linux-systemd/system/syncthing@.service', user_svc_template), |
33 ('etc/linux-systemd/system/syncthing-resume.service', '/etc/systemd/system/syncthing-resume.service'), | 32 ('etc/linux-systemd/system/syncthing-resume.service', '/etc/systemd/system/syncthing-resume.service'), |
34 ] | 33 ] |
35 ]) | 34 ]) |
36 files.link(f'/etc/systemd/system/multi-user.target.wants/syncthing@{user}.service', user_svc_template) | 35 files.link(path=f'/etc/systemd/system/multi-user.target.wants/syncthing@{user}.service', target=user_svc_template) |
37 systemd.service(service=f'syncthing@{user}', enabled=True, restarted=True, daemon_reload=True) | 36 systemd.service(service=f'syncthing@{user}', enabled=True, restarted=True, daemon_reload=True) |
38 | 37 |
39 | 38 |
40 # also see /my/serv/filesync/syncthing/deploy.yaml for the container one | 39 # also see /my/serv/filesync/syncthing/deploy.yaml for the container one |
41 version = 'v1.26.1' | 40 version = 'v1.26.1' |
48 | 47 |
49 if not host_running_version(user, version): | 48 if not host_running_version(user, version): |
50 install_syncthing(user, version) | 49 install_syncthing(user, version) |
51 | 50 |
52 # something above has broken devnull #bugreport | 51 # something above has broken devnull #bugreport |
53 server.shell(['chmod a+w /dev/null']) | 52 server.shell(commands=['chmod a+w /dev/null']) |
54 | 53 |
55 # also consider https://github.com/Martchus/syncthingtray tray status viewer on dtops | 54 # also consider https://github.com/Martchus/syncthingtray tray status viewer on dtops |