blob: c9886fbc14419a523a5716e867504d24d989fdf2 [file] [log] [blame]
Philipp Schrader0f5d2502022-03-08 22:44:55 -08001import argparse
2from pathlib import Path
3import subprocess
4import sys
5
6def 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
33if __name__ == "__main__":
34 sys.exit(main(sys.argv))