Philipp Schrader | 0f5d250 | 2022-03-08 22:44:55 -0800 | [diff] [blame] | 1 | import argparse |
| 2 | from pathlib import Path |
| 3 | import subprocess |
| 4 | import sys |
| 5 | |
| 6 | def main(argv): |
| 7 | """Installs the scouting application on the scouting server.""" |
| 8 | parser = argparse.ArgumentParser() |
| 9 | parser.add_argument( |
| 10 | "--deb", |
| 11 | type=str, |
| 12 | required=True, |
| 13 | help="The .deb file to deploy.", |
| 14 | ) |
| 15 | parser.add_argument( |
| 16 | "--host", |
| 17 | type=str, |
| 18 | default="scouting.frc971.org", |
| 19 | help="The SSH host to install the scouting web server to.", |
| 20 | ) |
| 21 | args = parser.parse_args(argv[1:]) |
| 22 | deb = Path(args.deb) |
| 23 | |
| 24 | # Copy the .deb to the scouting server, install it, and delete it again. |
| 25 | subprocess.run(["rsync", "-L", args.deb, f"{args.host}:/tmp/{deb.name}"], |
| 26 | check=True, stdin=sys.stdin) |
| 27 | subprocess.run(f"ssh -tt {args.host} sudo dpkg -i /tmp/{deb.name}", |
| 28 | shell=True, check=True, stdin=sys.stdin) |
| 29 | subprocess.run(f"ssh {args.host} rm -f /tmp/{deb.name}", |
| 30 | shell=True, check=True, stdin=sys.stdin) |
| 31 | |
| 32 | |
| 33 | if __name__ == "__main__": |
| 34 | sys.exit(main(sys.argv)) |