diff --git a/bin/psyncup.py b/bin/psyncup.py index 1545c77..1face57 100755 --- a/bin/psyncup.py +++ b/bin/psyncup.py @@ -55,6 +55,11 @@ parser.add_argument( action="store_true", help="Don't delete all non-matching files when rsyncing", ) +parser.add_argument( + "--exec", + type=str, + help="Run command on remote machine after sync", +) group = parser.add_mutually_exclusive_group(required=True) group.add_argument( @@ -252,6 +257,15 @@ def run_down(rsync_cmd, remote_dir_str): exit(1) +def run_exec(cmd, config): + if config.get("ssh_jump") is not None: + ssh_cmd = ["ssh", "-t", "-J", config["ssh_jump"], config["ssh_remote"], cmd] + else: + ssh_cmd = ["ssh", "-t", config["ssh_remote"], cmd] + + subprocess.run(["ssh", "-t", config["ssh_remote"], cmd]) + + if __name__ == "__main__": if args.init: run_init() @@ -269,6 +283,9 @@ if __name__ == "__main__": elif args.up: rsync_cmd, _, remote_dir_str = build_commands(args, config) run_up(rsync_cmd, remote_dir_str, config) + + if args.exec: + run_exec(args.exec, config) elif args.down: rsync_cmd, _, remote_dir_str = build_commands(args, config) run_down(rsync_cmd, remote_dir_str)