os
This commit is contained in:
parent
047ccc2bb8
commit
d599b19833
2 changed files with 39 additions and 19 deletions
30
pubnix.py
30
pubnix.py
|
@ -32,16 +32,30 @@ class PubNix:
|
||||||
self.url.append(self.context)
|
self.url.append(self.context)
|
||||||
self.url = '/'.join(self.url)
|
self.url = '/'.join(self.url)
|
||||||
|
|
||||||
def run(self, *args):
|
def capturun(self, *args):
|
||||||
subprocess.call(['ssh',
|
return self.run(*args, capture_output=True)
|
||||||
'-o', 'LogLevel Error',
|
|
||||||
'-p', str(self.port),
|
def run(self, *args, **kwargs):
|
||||||
f'{self.user}@{self.ssh}',
|
return subprocess.run(['ssh',
|
||||||
'--',
|
'-o', 'LogLevel Error',
|
||||||
*args])
|
'-p', str(self.port),
|
||||||
|
f'{self.user}@{self.ssh}',
|
||||||
|
'--',
|
||||||
|
*args,
|
||||||
|
], **kwargs)
|
||||||
|
|
||||||
def disk_free(self):
|
def disk_free(self):
|
||||||
self.run('df', '-h', os.curdir)
|
process = self.capturun('df', '-h', os.curdir)
|
||||||
|
return process.stdout.decode('UTF-8').strip()
|
||||||
|
|
||||||
|
def os(self):
|
||||||
|
ps = self.capturun('cat', '/etc/os-release')
|
||||||
|
if ps.returncode == 0:
|
||||||
|
for line in ps.stdout.decode('UTF-8').strip().split(os.linesep):
|
||||||
|
if 'PRETTY_NAME' in line:
|
||||||
|
return line.split('=')[1].split('"')[1]
|
||||||
|
else:
|
||||||
|
return self.capturun('uname', '-sr').stdout.decode('UTF-8').strip()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return os.linesep.join([self.target, self.url])
|
return os.linesep.join([self.target, self.url])
|
||||||
|
|
28
sync.py
28
sync.py
|
@ -6,23 +6,18 @@ import subprocess
|
||||||
import pubnix
|
import pubnix
|
||||||
|
|
||||||
ARGS = [
|
ARGS = [
|
||||||
# {'dn':'aussies.space', 'sub': False},
|
|
||||||
{'dn':'blinkenshell.org',
|
{'dn':'blinkenshell.org',
|
||||||
'ssh': 'ssh', 'port': 2222, 'web': 'u', 'sub': True},
|
'ssh': 'ssh', 'port': 2222, 'web': 'u', 'sub': True},
|
||||||
{'dn':'ctrl-c.club', 'sub': False},
|
{'dn':'ctrl-c.club', 'sub': False},
|
||||||
{'dn':'dimension.sh', 'sub': True},
|
{'dn':'dimension.sh', 'sub': True},
|
||||||
{'dn':'envs.net', 'sub': True},
|
{'dn':'envs.net', 'sub': True},
|
||||||
# {'dn':'fr.tild3.org', 'sub': True},
|
|
||||||
{'dn':'freeshell.de', 'sub': False},
|
{'dn':'freeshell.de', 'sub': False},
|
||||||
{'dn':'heathens.club', 'root': 'www', 'sub': False},
|
|
||||||
{'dn':'hextilde.xyz', 'sub': True},
|
{'dn':'hextilde.xyz', 'sub': True},
|
||||||
{'dn':'insomnia247.nl', 'dir': True, 'sub': True},
|
{'dn':'insomnia247.nl', 'dir': True, 'sub': True},
|
||||||
{'dn':'p.projectsegfau.lt', 'sub': True},
|
{'dn':'p.projectsegfau.lt', 'sub': True},
|
||||||
{'dn':'pubnix.pink', 'web': 'sites', 'sub': False},
|
{'dn':'pubnix.pink', 'web': 'sites', 'sub': False},
|
||||||
{'dn':'remotes.club', 'port': 9022, 'root': 'web', 'sub': True},
|
|
||||||
{'dn':'rawtext.club', 'sub': False},
|
{'dn':'rawtext.club', 'sub': False},
|
||||||
{'dn':'rw.rs', 'sub': False},
|
{'dn':'rw.rs', 'sub': False},
|
||||||
{'dn':'squiggle.city', 'sub': False},
|
|
||||||
{'dn':'thunix.net', 'sub': False},
|
{'dn':'thunix.net', 'sub': False},
|
||||||
{'dn':'tilde.32bit.cafe', 'root': 'www', 'sub': False},
|
{'dn':'tilde.32bit.cafe', 'root': 'www', 'sub': False},
|
||||||
{'dn':'tilde.cafe', 'sub': True},
|
{'dn':'tilde.cafe', 'sub': True},
|
||||||
|
@ -35,8 +30,16 @@ ARGS = [
|
||||||
{'dn':'tilde.team', 'sub': True},
|
{'dn':'tilde.team', 'sub': True},
|
||||||
{'dn':'tilde.town', 'sub': False},
|
{'dn':'tilde.town', 'sub': False},
|
||||||
{'dn':'trash.town', 'sub': False},
|
{'dn':'trash.town', 'sub': False},
|
||||||
{'dn':'vern.cc', 'sub': True},
|
# permissions
|
||||||
# {'dn':'sdf.org', 'root': 'html', 'sub': True},
|
{'dn':'sdf.org', 'root': 'html', 'sub': True},
|
||||||
|
# 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},
|
||||||
]
|
]
|
||||||
PUBNIXES = [pubnix.PubNix(**args) for args in ARGS]
|
PUBNIXES = [pubnix.PubNix(**args) for args in ARGS]
|
||||||
|
|
||||||
|
@ -62,11 +65,14 @@ def sync(root, pubnix, exclude=None):
|
||||||
def main():
|
def main():
|
||||||
root = os.path.dirname(os.path.realpath(__file__))
|
root = os.path.dirname(os.path.realpath(__file__))
|
||||||
root = os.path.join(root, 'out', 'web')
|
root = os.path.join(root, 'out', 'web')
|
||||||
|
dns_length = max([len(pubnix.dn) for pubnix in PUBNIXES])
|
||||||
for pubnix in PUBNIXES:
|
for pubnix in PUBNIXES:
|
||||||
print()
|
# print()
|
||||||
print(pubnix)
|
# print(pubnix)
|
||||||
sync(root, pubnix, exclude=['__pycache__', 'cnam', 'pgp.asc'])
|
print(f'{pubnix.dn.rjust(dns_length)} → ', end=str(), flush=True)
|
||||||
# pubnix.disk_free()
|
# sync(root, pubnix, exclude=['__pycache__', 'cnam', 'pgp.asc'])
|
||||||
|
# print(pubnix.disk_free())
|
||||||
|
print(pubnix.os())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue