dm: support des aliases pour ssh aussi

This commit is contained in:
Jephté Clain 2020-10-02 09:12:56 +04:00
parent d1d32de841
commit 82a7952e2a
1 changed files with 33 additions and 28 deletions

View File

@ -7,35 +7,40 @@ if [ -n "$UTOOLS_DOCKER_ALIASES" ]; then
# alias dm=docker-machine # alias dm=docker-machine
#fi #fi
function dm() { function dm() {
if [ "$1" == use -a -n "$2" -a -f ~/etc/default/dk ]; then case "$1" in
# chercher les aliases éventuels use|ssh)
local machine="$2"; shift; shift if [ -n "$2" -a -f ~/etc/default/dk ]; then
machine="$( # chercher les aliases éventuels
CLUSTERDIRS=() local cmd="$1"; shift
DM_ALIASES=() local machine="$1"; shift
source ~/etc/default/dk machine="$(
for alias_machine in "${DM_ALIASES[@]}"; do CLUSTERDIRS=()
if [ "${alias_machine%%:*}" == "$machine" ]; then DM_ALIASES=()
echo "${alias_machine#*:}" source ~/etc/default/dk
exit for alias_machine in "${DM_ALIASES[@]}"; do
fi if [ "${alias_machine%%:*}" == "$machine" ]; then
done echo "${alias_machine#*:}"
for clusterdir in "${CLUSTERDIRS[@]}"; do exit
if [ -f "$clusterdir/0config/configure.conf" ]; then
DM_ALIASES=()
source "$clusterdir/0config/configure.conf"
for alias_machine in "${DM_ALIASES[@]}"; do
if [ "${alias_machine%%:*}" == "$machine" ]; then
echo "${alias_machine#*:}"
exit
fi
done
fi
done
echo "$machine"
)"
set -- use "$machine" "$@"
fi fi
done
for clusterdir in "${CLUSTERDIRS[@]}"; do
if [ -f "$clusterdir/0config/configure.conf" ]; then
DM_ALIASES=()
source "$clusterdir/0config/configure.conf"
for alias_machine in "${DM_ALIASES[@]}"; do
if [ "${alias_machine%%:*}" == "$machine" ]; then
echo "${alias_machine#*:}"
exit
fi
done
fi
done
echo "$machine"
)"
set -- "$cmd" "$machine" "$@"
fi
;;
esac
if [ "$DOCKER_MACHINE_WRAPPED" == true ]; then if [ "$DOCKER_MACHINE_WRAPPED" == true ]; then
__docker_machine_wrapper "$@" __docker_machine_wrapper "$@"
else else