#!/bin/bash #stop proc killP() { pkill $1 ps aux | grep "$1" | grep -q -v grep PROCESS_STATUS=$? if [ $PROCESS_STATUS -ne 0 ]; then pkill $1 fi } startSdkCompareWithOneParam(){ number=`ps -ef | grep "sdkCompare" | grep -v grep | wc -l` echo $number if [ $number -ne 2 ]; then killP sdkCompare sleep 2 date +%D-%T" sdkCompare start" nohup ./sdkCompare $1 >/dev/null 2>&1 & nohup ./sdkCompare $1 -target=es >/dev/null 2>&1 & return 1 else echo "sdkCompare is exists" return 0 fi } cd /opt/vasystem/ patchPath=$1 files=$(ls $patchPath) echo "patchPath: " $patchPath if [ ! -f $patchPath ]; then echo "$patchPath not exist" else for item in $files do if [ -f $item ]; then killP $item sleep 2 cp $patchPath/$item /opt/vasystem/bin if [[ "$item"=="sdkCompare" ]]; then startSdkCompareWithOneParam sdkCompare -e=pro else nohup ./$item >/dev/null 2>&1 & fi else echo "directory name is ${item}" if [[ "$item"=="dist" ]]; then echo "update web dist" cp -r $patchPath/$item /opt/vasystem/web/dist fi fi done fi ./daemon.sh -shm sleep 3 echo "patch update success"