#!/bin/sh
echo -e "\033[0;32m请选择更新哪个服务的镜像并重启: \033[0m"
echo "1 : authservice"
echo "2 : dbcompare"
echo "3 : graphcompare"
echo "4 : hbasecompare"
echo "5 : parse"
echo "6 : query"
echo "7 : taskservice"

read -p "请输入服务对应的序号 :" no

echo -e "\033[0;32m构建镜像... \033[0m"

case $no in
(1)
	no="authservice"
	./build-auth.sh
	;;
(2)
	no="dbcompare"
	./build-db.sh
	;;
(3)
	no="graphcompare"
	./build-graph.sh
	;;
(4)
	no="hbasecompare"
	./build-hbase.sh
	;;
(5)
	no="parse"
	./build-parse.sh
	;;
(6)
	no="query"
	./build-query.sh
	;;
(7)
	no="taskservice"
	./build-ts.sh
	;;
*)
	echo -e "\033[0;31m请输出正确的服务序号! \033[0m"
	exit -1
esac

echo -e "\033[0;32m停止原服务... \033[0m"

docker-compose stop $no

echo -e "\033[0;32m删除原服务... \033[0m"

docker-compose rm -f $no

echo -e "\033[0;32m创建并启动服务... \033[0m"

docker-compose up -d $no

echo -e "\033[0;32m当前服务状态: \033[0m"
sleep 3

echo "    Name                  Command               State          Ports        
----------------------------------------------------------------------------"
docker-compose ps | grep $no