()
| 44 | |
| 45 | |
| 46 | def main(): |
| 47 | parser = argparse.ArgumentParser() |
| 48 | parser.add_argument( |
| 49 | "setup_script_path", |
| 50 | nargs="?", |
| 51 | default="/home/ubuntu/.mp4/setup/bare-server-setup.sh", |
| 52 | ) |
| 53 | parser.add_argument( |
| 54 | "lock_file_path", |
| 55 | nargs="?", |
| 56 | default="/home/ubuntu/.mp4/setup/bare-server-setup.sh.lock", |
| 57 | ) |
| 58 | parser.add_argument("--ts-tags", default="") |
| 59 | parser.add_argument("--ts-auth-key", default="") |
| 60 | parser.add_argument("--ts-hostname", default="") |
| 61 | args = parser.parse_args() |
| 62 | |
| 63 | env_vars = { |
| 64 | "TAILSCALE_TAGS": args.ts_tags, |
| 65 | "TAILSCALE_AUTH_KEY": args.ts_auth_key, |
| 66 | "TAILSCALE_HOSTNAME": args.ts_hostname, |
| 67 | } |
| 68 | |
| 69 | # Create a separate process to run the setup script and hold the lock, so that the main process |
| 70 | # can die (e.g. if the SSH connection is lost) without affecting the setup script. |
| 71 | p = multiprocessing.Process( |
| 72 | target=run_inner_script, |
| 73 | args=(env_vars, args.setup_script_path, args.lock_file_path), |
| 74 | ) |
| 75 | p.start() |
| 76 | p.join() |
| 77 | exit(p.exitcode) |
| 78 | |
| 79 | |
| 80 | if __name__ == "__main__": |
no test coverage detected