blob: 596795617fa6436ff766e36e856e35ad1bbe57e2 [file] [log] [blame]
Philipp Schrader0f5d2502022-03-08 22:44:55 -08001import argparse
2from pathlib import Path
3import subprocess
4import sys
5
Ravago Jones5127ccc2022-07-31 16:32:45 -07006
Philipp Schrader0f5d2502022-03-08 22:44:55 -08007def main(argv):
8 """Installs the scouting application on the scouting server."""
9 parser = argparse.ArgumentParser()
10 parser.add_argument(
11 "--deb",
12 type=str,
13 required=True,
14 help="The .deb file to deploy.",
15 )
16 parser.add_argument(
17 "--host",
18 type=str,
19 default="scouting.frc971.org",
20 help="The SSH host to install the scouting web server to.",
21 )
22 args = parser.parse_args(argv[1:])
23 deb = Path(args.deb)
24
25 # Copy the .deb to the scouting server, install it, and delete it again.
26 subprocess.run(["rsync", "-L", args.deb, f"{args.host}:/tmp/{deb.name}"],
Ravago Jones5127ccc2022-07-31 16:32:45 -070027 check=True,
28 stdin=sys.stdin)
Philipp Schrader0f5d2502022-03-08 22:44:55 -080029 subprocess.run(f"ssh -tt {args.host} sudo dpkg -i /tmp/{deb.name}",
Ravago Jones5127ccc2022-07-31 16:32:45 -070030 shell=True,
31 check=True,
32 stdin=sys.stdin)
Philipp Schrader0f5d2502022-03-08 22:44:55 -080033 subprocess.run(f"ssh {args.host} rm -f /tmp/{deb.name}",
Ravago Jones5127ccc2022-07-31 16:32:45 -070034 shell=True,
35 check=True,
36 stdin=sys.stdin)
Philipp Schrader0f5d2502022-03-08 22:44:55 -080037
38
39if __name__ == "__main__":
40 sys.exit(main(sys.argv))