Scripts: exec to psyncup
This commit is contained in:
parent
2678e52302
commit
b09b3531d3
1 changed files with 17 additions and 0 deletions
|
@ -55,6 +55,11 @@ parser.add_argument(
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Don't delete all non-matching files when rsyncing",
|
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 = parser.add_mutually_exclusive_group(required=True)
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
|
@ -252,6 +257,15 @@ def run_down(rsync_cmd, remote_dir_str):
|
||||||
exit(1)
|
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 __name__ == "__main__":
|
||||||
if args.init:
|
if args.init:
|
||||||
run_init()
|
run_init()
|
||||||
|
@ -269,6 +283,9 @@ if __name__ == "__main__":
|
||||||
elif args.up:
|
elif args.up:
|
||||||
rsync_cmd, _, remote_dir_str = build_commands(args, config)
|
rsync_cmd, _, remote_dir_str = build_commands(args, config)
|
||||||
run_up(rsync_cmd, remote_dir_str, config)
|
run_up(rsync_cmd, remote_dir_str, config)
|
||||||
|
|
||||||
|
if args.exec:
|
||||||
|
run_exec(args.exec, config)
|
||||||
elif args.down:
|
elif args.down:
|
||||||
rsync_cmd, _, remote_dir_str = build_commands(args, config)
|
rsync_cmd, _, remote_dir_str = build_commands(args, config)
|
||||||
run_down(rsync_cmd, remote_dir_str)
|
run_down(rsync_cmd, remote_dir_str)
|
||||||
|
|
Loading…
Reference in a new issue