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 | |
Ravago Jones | 5127ccc | 2022-07-31 16:32:45 -0700 | [diff] [blame^] | 6 | |
Philipp Schrader | 0f5d250 | 2022-03-08 22:44:55 -0800 | [diff] [blame] | 7 | def 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 Jones | 5127ccc | 2022-07-31 16:32:45 -0700 | [diff] [blame^] | 27 | check=True, |
| 28 | stdin=sys.stdin) |
Philipp Schrader | 0f5d250 | 2022-03-08 22:44:55 -0800 | [diff] [blame] | 29 | subprocess.run(f"ssh -tt {args.host} sudo dpkg -i /tmp/{deb.name}", |
Ravago Jones | 5127ccc | 2022-07-31 16:32:45 -0700 | [diff] [blame^] | 30 | shell=True, |
| 31 | check=True, |
| 32 | stdin=sys.stdin) |
Philipp Schrader | 0f5d250 | 2022-03-08 22:44:55 -0800 | [diff] [blame] | 33 | subprocess.run(f"ssh {args.host} rm -f /tmp/{deb.name}", |
Ravago Jones | 5127ccc | 2022-07-31 16:32:45 -0700 | [diff] [blame^] | 34 | shell=True, |
| 35 | check=True, |
| 36 | stdin=sys.stdin) |
Philipp Schrader | 0f5d250 | 2022-03-08 22:44:55 -0800 | [diff] [blame] | 37 | |
| 38 | |
| 39 | if __name__ == "__main__": |
| 40 | sys.exit(main(sys.argv)) |