3 stringContain() { [ -z "${2##*$1*}" ]; }
8 USAGE="\nUsage: ./$SCRIPT <MS NAME> <ACTION>\nValid Options: ./$SCRIPT <simu,dbass,e2mgr,e2> <stop,start,restart,status>\nE.g ./$SCRIPT dbass stop"
9 OPTIONS="simu,dbass,e2mgr,e2,stop,start,restart,status"
10 DOC_SCRIPT="/opt/docker_ms.sh"
11 K8S_SCRIPT="/opt/k8s_ms.py"
12 # Check if script got the reqiured arguments
13 [ -z ${SYS_TYPE} ] && echo -e "\nThe SYS_TYPE environemnt variable is not set!" && echo -e "${USAGE}" && exit 1
14 [ -z ${MS} ] && echo -e "\nThe MS argument is reqiured!" && echo -e "${USAGE}" && exit 2
15 [ -z ${ACTION} ] && echo -e "\nThe ACTION argument is reqiured!" && echo -e "${USAGE}" && exit 2
16 ! grep -q $MS <<<"$OPTIONS" && echo -e "\nThe microservice '${MS}' is not a valid value!" && echo -e "${USAGE}" && exit 3
17 ! grep -q $ACTION <<<"$OPTIONS" && echo -e "\nThe action '${ACTION}' is not a valid value!" && echo -e "${USAGE}" && exit 3
19 if [ "${SYS_TYPE}" == "docker" ]; then
20 echo "SYS_TYPE=docker, Docker mode is set"
21 [ ! -f ${DOC_SCRIPT} ] && echo "reqiured file '${DOC_SCRIPT}' is missing, exit" && exit 4
22 echo "Executing the '${DOC_SCRIPT}' script!"
23 ${DOC_SCRIPT} ${MS} ${ACTION}
24 elif [ "${SYS_TYPE}" == "k8s" ]; then
25 echo "SYS_TYPE=k8s, K8S mode is set"
26 [ ! -f ${K8S_SCRIPT} ] && echo "reqiured file '${K8S_SCRIPT}' is missing, exit" && exit 4
27 echo "Executing the '${K8S_SCRIPT}' script!"
28 ${K8S_SCRIPT} ${MS} ${ACTION}