2019-08-21 09:57:08 +04:00
|
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
|
|
|
|
|
|
if [ -n "$UTOOLS_DOCKER_ALIASES" ]; then
|
2020-09-17 05:59:36 +04:00
|
|
|
#if [ "$DOCKER_MACHINE_WRAPPED" == true ]; then
|
|
|
|
# alias dm=__docker_machine_wrapper
|
|
|
|
#else
|
|
|
|
# alias dm=docker-machine
|
|
|
|
#fi
|
|
|
|
function dm() {
|
2020-10-02 09:12:56 +04:00
|
|
|
case "$1" in
|
|
|
|
use|ssh)
|
|
|
|
if [ -n "$2" -a -f ~/etc/default/dk ]; then
|
|
|
|
# chercher les aliases éventuels
|
|
|
|
local cmd="$1"; shift
|
|
|
|
local machine="$1"; shift
|
|
|
|
machine="$(
|
|
|
|
CLUSTERDIRS=()
|
|
|
|
DM_ALIASES=()
|
|
|
|
source ~/etc/default/dk
|
|
|
|
for alias_machine in "${DM_ALIASES[@]}"; do
|
|
|
|
if [ "${alias_machine%%:*}" == "$machine" ]; then
|
|
|
|
echo "${alias_machine#*:}"
|
|
|
|
exit
|
2020-09-17 05:59:36 +04:00
|
|
|
fi
|
2020-10-02 09:12:56 +04:00
|
|
|
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
|
2020-09-17 05:59:36 +04:00
|
|
|
if [ "$DOCKER_MACHINE_WRAPPED" == true ]; then
|
|
|
|
__docker_machine_wrapper "$@"
|
|
|
|
else
|
|
|
|
docker-machine "$@"
|
|
|
|
fi
|
|
|
|
}
|
2019-08-21 09:57:08 +04:00
|
|
|
|
2019-08-21 11:20:21 +04:00
|
|
|
if [ -n "$UTOOLS_BASH_COMPLETION" ]; then
|
2019-08-21 09:57:08 +04:00
|
|
|
complete -F _docker_machine dm
|
|
|
|
fi
|
|
|
|
fi
|