41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Compatibility command: build and publish the tested server pack on neuro."""
|
|
import argparse
|
|
import hashlib
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
|
|
|
|
def main() -> None:
|
|
ap = argparse.ArgumentParser(description=__doc__)
|
|
ap.add_argument('mrpack', type=Path)
|
|
ap.add_argument('--bootstrap', type=Path)
|
|
args = ap.parse_args()
|
|
archive = args.mrpack.resolve()
|
|
expected = hashlib.sha256(archive.read_bytes()).hexdigest()
|
|
# Publishing a client before deploying its server can prevent players joining.
|
|
deployed = subprocess.run([
|
|
'ssh', '-o', 'BatchMode=yes', 'neuro',
|
|
'systemctl is-active --quiet minecraft-server-wowMineMap && '
|
|
'sha256sum /var/lib/minecraft-modpacks/wowmine/wowmine.mrpack',
|
|
], capture_output=True, text=True, check=True).stdout.split()[0]
|
|
if deployed != expected:
|
|
ap.error('Deploy this mrpack on neuro first: the server archive hash differs')
|
|
scripts = Path(__file__).resolve().parent
|
|
with tempfile.TemporaryDirectory(prefix='prism-publish-') as temporary:
|
|
output = Path(temporary) / 'export'
|
|
command = [sys.executable, str(scripts / 'build-prism-pack.py'),
|
|
str(archive), str(output), '--server', 'wowmine.bfs.band:35565']
|
|
if args.bootstrap:
|
|
command += ['--bootstrap', str(args.bootstrap.resolve())]
|
|
subprocess.run(command, check=True)
|
|
subprocess.run([sys.executable, str(scripts / 'publish-prism-pack.py'),
|
|
str(output)], check=True)
|
|
print('https://wowmine.bfs.band:8443/minecraft/wowmine/', flush=True)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|