mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 14:56:13 +00:00
adding on server.sh option to get ip address for khanat server on docker
This commit is contained in:
parent
4ac04c6f51
commit
3afcadb9c3
1 changed files with 25 additions and 4 deletions
|
@ -20,6 +20,7 @@ declare -i STOPKHANAT=0
|
||||||
declare -i CLEANCONTAINERKHANAT=0
|
declare -i CLEANCONTAINERKHANAT=0
|
||||||
declare -i CONNECTSSHKHANAT=0
|
declare -i CONNECTSSHKHANAT=0
|
||||||
declare -i KHANAT_CLIENT_VERSION=1
|
declare -i KHANAT_CLIENT_VERSION=1
|
||||||
|
declare -i SHOWIPKHANATSERVER=0
|
||||||
|
|
||||||
declare IMAGEGENERICSERVER="server_generic_debian_jessie_x86_64"
|
declare IMAGEGENERICSERVER="server_generic_debian_jessie_x86_64"
|
||||||
declare IMAGEKHANATSERVER="server_khanat_debian_jessie_x86_64"
|
declare IMAGEKHANATSERVER="server_khanat_debian_jessie_x86_64"
|
||||||
|
@ -49,6 +50,7 @@ options:
|
||||||
-n, --no-launch-khanat : Doesn't launch khanat server
|
-n, --no-launch-khanat : Doesn't launch khanat server
|
||||||
-s, --stop-server : Stop server khanat
|
-s, --stop-server : Stop server khanat
|
||||||
-c, --clean-container-khanat : Remove old server khanat (stopped)
|
-c, --clean-container-khanat : Remove old server khanat (stopped)
|
||||||
|
-i, --show-ip-khanat-server : show ip address for khanat server (launch under docker)
|
||||||
--ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action]
|
--ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action]
|
||||||
--client-version=[INTEGER] : version client khanat (we need to communicate with our server)
|
--client-version=[INTEGER] : version client khanat (we need to communicate with our server)
|
||||||
|
|
||||||
|
@ -82,7 +84,7 @@ function msg_error()
|
||||||
# MAIN
|
# MAIN
|
||||||
#
|
#
|
||||||
|
|
||||||
msg_info "START"
|
#msg_info "START"
|
||||||
|
|
||||||
calldir="$(dirname $0)"
|
calldir="$(dirname $0)"
|
||||||
basedir=$(cd $calldir; pwd)
|
basedir=$(cd $calldir; pwd)
|
||||||
|
@ -137,6 +139,10 @@ do
|
||||||
KHANATSERVER=1
|
KHANATSERVER=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-i|--show-ip-khanat-server)
|
||||||
|
SHOWIPKHANATSERVER=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--client-version*)
|
--client-version*)
|
||||||
KHANAT_CLIENT_VERSION="${1#*=}"
|
KHANAT_CLIENT_VERSION="${1#*=}"
|
||||||
shift
|
shift
|
||||||
|
@ -157,6 +163,11 @@ function chrashed()
|
||||||
|
|
||||||
trap chrashed EXIT
|
trap chrashed EXIT
|
||||||
|
|
||||||
|
if [[ $SHOWIPKHANATSERVER -eq 0 ]]
|
||||||
|
then
|
||||||
|
msg_info "START"
|
||||||
|
fi
|
||||||
|
|
||||||
msg_debug "prg: $0"
|
msg_debug "prg: $0"
|
||||||
|
|
||||||
docker -v 1>/dev/null
|
docker -v 1>/dev/null
|
||||||
|
@ -179,15 +190,25 @@ case "$(uname -m)" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ $CONNECTSSHKHANAT -ne 0 ]]
|
if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
|
||||||
then
|
then
|
||||||
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
|
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
|
||||||
if [[ ${#listcontainer[@]} -eq 1 ]]
|
if [[ ${#listcontainer[@]} -eq 1 ]]
|
||||||
then
|
then
|
||||||
|
|
||||||
ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]})
|
ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]})
|
||||||
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no compil@$ipaddress
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $SHOWIPKHANATSERVER -ne 0 ]]
|
||||||
|
then
|
||||||
|
trap '' EXIT
|
||||||
|
echo "$ipaddress"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $CONNECTSSHKHANAT -ne 0 ]]
|
||||||
|
then
|
||||||
|
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no compil@$ipaddress
|
||||||
trap '' EXIT
|
trap '' EXIT
|
||||||
msg_info "END SSH"
|
msg_info "END SSH"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue