26 lines
1002 B
Python
26 lines
1002 B
Python
#!/usr/bin/env python3
|
|
"""Run the sandbox verification on the Orange Pi over SSH."""
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def main():
|
|
host = os.environ.get('LAB_PIMOX_HOST', '192.168.100.80')
|
|
user = os.environ.get('LAB_PIMOX_USER', 'jv')
|
|
key = os.environ.get('LAB_PIMOX_SSH_KEY_PATH', '/home/jv/.ssh/id_ed25519')
|
|
try:
|
|
source = (Path(__file__).resolve().parent / 'network-sandbox-verify-host.py').read_bytes()
|
|
return subprocess.run(['ssh', '-T', '-i', key, '-o', 'BatchMode=yes',
|
|
'-o', 'IdentitiesOnly=yes', '-o', 'ConnectTimeout=10',
|
|
'-o', 'StrictHostKeyChecking=accept-new', f'{user}@{host}',
|
|
'sudo -n python3 -'], input=source, timeout=180).returncode
|
|
except (OSError, subprocess.SubprocessError) as exc:
|
|
print(f'Sandbox verification failed: {exc}', file=sys.stderr)
|
|
return 1
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|