Compare commits
No commits in common. "3f23c11c39af03399a48fd1da8004c5610b8ac3c" and "302bea298eb5a8f562487c41415e8696ddcb88c2" have entirely different histories.
3f23c11c39
...
302bea298e
@ -14,4 +14,4 @@ function _scp_path_completition()
|
|||||||
}
|
}
|
||||||
|
|
||||||
complete -F _ssh_connector_completion ssh-helper
|
complete -F _ssh_connector_completion ssh-helper
|
||||||
complete -o nospace -F _scp_path_completition scp-helper
|
complete -F _scp_path_completition scp-helper
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
|
CMD_TAR_DECOMP='tar -xz'
|
||||||
|
CMD_TAR_COMP='tar -cz'
|
||||||
SUDO_REMOTE=True
|
SUDO_REMOTE=True
|
||||||
#SSH_ARGS='-C -o ControlMaster=auto -o ControlPersist=60s -o ControlPath=~/.ssh/controlmasters/%r@%h:%p -o PreferredAuthentications=publickey'
|
|
||||||
SSH_ARGS=''
|
|
||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
config_path = os.environ.get('SSH_HELPER_HOST_LIST')
|
config_path = os.environ.get('SSH_HELPER_HOST_LIST')
|
||||||
@ -30,9 +30,6 @@ def parse_arg(s):
|
|||||||
connection_name = 'local'
|
connection_name = 'local'
|
||||||
path = s
|
path = s
|
||||||
|
|
||||||
if path == '':
|
|
||||||
path = '/'
|
|
||||||
|
|
||||||
if path[0] not in ('/', '~', '.'):
|
if path[0] not in ('/', '~', '.'):
|
||||||
if connection_name == 'local':
|
if connection_name == 'local':
|
||||||
path = './' + path
|
path = './' + path
|
||||||
@ -69,7 +66,7 @@ def add_sudo(s):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def make_ssh_cmd(host, port, user, cmd):
|
def make_ssh_cmd(host, port, user, cmd):
|
||||||
res = f"/usr/bin/ssh {user}@{host} {SSH_ARGS} -p {port} '{cmd}'"
|
res = f"/usr/bin/ssh {user}@{host} -p {port} '{cmd}'"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def get_connection_config(con_name):
|
def get_connection_config(con_name):
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import sys
|
|||||||
import subprocess
|
import subprocess
|
||||||
from helperlib import get_config, parse_arg, add_sudo, make_ssh_cmd, get_path_config
|
from helperlib import get_config, parse_arg, add_sudo, make_ssh_cmd, get_path_config
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
SUDO_REMOTE = True
|
SUDO_REMOTE = True
|
||||||
|
|
||||||
def get_conf_names():
|
def get_conf_names():
|
||||||
@ -56,9 +56,8 @@ if __name__ == '__main__':
|
|||||||
cur_arg = get_current_arg(args)
|
cur_arg = get_current_arg(args)
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(f'{cur_arg}', file=sys.stderr)
|
print(f'{cur_arg}', file=sys.stderr)
|
||||||
|
|
||||||
comp_list = []
|
if cur_arg is not None and ':' in cur_arg:
|
||||||
if cur_arg is not None:
|
|
||||||
# В нем уже прописали имя подключения
|
# В нем уже прописали имя подключения
|
||||||
cur_set = get_path_config(cur_arg)
|
cur_set = get_path_config(cur_arg)
|
||||||
|
|
||||||
@ -70,6 +69,7 @@ if __name__ == '__main__':
|
|||||||
print(f'{obj_list}', file=sys.stderr)
|
print(f'{obj_list}', file=sys.stderr)
|
||||||
print(cur_set, file=sys.stderr)
|
print(cur_set, file=sys.stderr)
|
||||||
|
|
||||||
|
comp_list = []
|
||||||
for i in obj_list.split('\n'):
|
for i in obj_list.split('\n'):
|
||||||
i_res = ''
|
i_res = ''
|
||||||
if cur_set['connection_name'] != 'local':
|
if cur_set['connection_name'] != 'local':
|
||||||
@ -86,9 +86,11 @@ if __name__ == '__main__':
|
|||||||
if DEBUG:
|
if DEBUG:
|
||||||
print(f'{comp_list}', file=sys.stderr)
|
print(f'{comp_list}', file=sys.stderr)
|
||||||
|
|
||||||
comp_list.extend([f'{i}/' for i in get_conf_names()])
|
print(' '.join(comp_list))
|
||||||
|
else:
|
||||||
|
# Заполняем имя подключения
|
||||||
|
print('/ '.join(get_conf_names()))
|
||||||
|
|
||||||
|
|
||||||
print(' '.join(comp_list))
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,6 @@ import os
|
|||||||
|
|
||||||
from helperlib import *
|
from helperlib import *
|
||||||
|
|
||||||
PV_ENABLED = True
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Copy files'
|
description='Copy files'
|
||||||
@ -31,10 +29,7 @@ if __name__ == '__main__':
|
|||||||
make_unpack_cmd
|
make_unpack_cmd
|
||||||
)
|
)
|
||||||
|
|
||||||
if PV_ENABLED:
|
full_cmd = f'{in_cmd} | {out_cmd}'
|
||||||
full_cmd = f'{in_cmd} | pv | {out_cmd}'
|
|
||||||
else:
|
|
||||||
full_cmd = f'{in_cmd} | {out_cmd}'
|
|
||||||
print("Будет выполнена команда:")
|
print("Будет выполнена команда:")
|
||||||
print(full_cmd)
|
print(full_cmd)
|
||||||
print("продолжить (y/n)")
|
print("продолжить (y/n)")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user