#!/bin/bash # Let's finish it like a flash # usage:sh -x update_cms_backend.sh -v 2018050401 ARGS=`getopt -o v:"$@"` echo $# if [ $# != 2 ];then echo "Need new version" exit fi case "$1" in -v) echo "new version: ". $2 SERVICE_VERSION=$2 ;; esac REGISTRY_URL="172.16.161.215:5000/cloud_portal/portal" SSO_HOST='172.16.160.106' SSO_PORT="8010" MYSQL_HOST="172.16.160.106" MYSQL_PORT="3306" MYSQL_DB="portal_db" MYSQL_PASSWORD='123456!' K8S_URL="http://172.16.160.245:8090" REDIS_HOST="172.16.160.106" # GET the container id for stop and delete CONTAINER_ID=`docker ps -a | grep 8080 | cut -d " " -f 1` docker stop ${CONTAINER_ID} sleep 2 docker rm ${CONTAINER_ID} sleep 2 docker run -itd --name cms -p 8080:8080 --restart=always -v /home/portal/upload:/home/portal/upload -e SSO_HOST=${SSO_HOST} -e SSO_PORT=${SSO_PORT} -e MYSQL_HOST=${MYSQL_HOST} -e MYSQL_PORT=${MYSQL_PORT} -e MYSQL_DB=${MYSQL_DB} -e MYSQL_PASSWORD=${MYSQL_PASSWORD} -e K8S_URL=${K8S_URL} -e REDIS_HOST=${REDIS_HOST} ${REGISTRY_URL}:${SERVICE_VERSION} #docker run -itd --rm --name cms -p 8080:8080 -e SSO_HOST='172.16.160.106' -e SSO_PORT="8010" -e MYSQL_HOST="172.16.160.106" -e MYSQL_PORT="3306" -e MYSQL_DB="portal_db" -e MYSQL_PASSWORD='123456!' -e K8S_URL="http://172.16.160.245:8090" -e REDIS_HOST="172.16.160.106" -v /home/portal/upload:/home/portal/upload 1900cbf55a4c