位置:首页  >   服务器运营  > 开发服务器到测试服务器代码上传sdeploy.sh

开发服务器到测试服务器代码上传sdeploy.sh

#!/bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/opt/local/bin:$HOME/bin

#echo $PATH
##echo There are $# arguments to $0: $*
USER_SYNC="evtadmin"
BUILDER="/home/builder"
SRC_DIR="$BUILDER/sp_dist"
IP_ADR="123.125.211.35"
OS=`uname -s`
echo $OS
if [ $OS = "Darwin" ]; then
PREFIX=/opt
else
PREFIX=/home/builder/sp_v1
fi

die() {
  echo "$@"
  exit 1
}

try() {
    echo Executing "$@"
    "$@"
    status=$?
    if test $status -ne 0
    then
        die "Note: command '$@' returned status $status.  Aborting."
    fi
}


check_dist() {
    [ -d $DST_DIR ] || mkdir $DST_DIR
    if [ ! -d $DST_DIR ]; then
        echo "Directory $DST_DIR can not access"
        exit 1;
    fi
}


sync_sproot() {
DST_IP=$1           #目标服务器IP
SRC_FOLDERS=$2         
SPROOT=" ${USER_SYNC}@${DST_IP}:$PREFIX/"
EXCLUDES=$3
echo "sync DIST to SPROOT"
rsync -vrptE -e "ssh -p10086" \
${EXCLUDES} \
${SRC_FOLDERS} ${SPROOT}
}

if [ -z "$1" ]; then
    echo "Usage: $0 [www|admin|cdgn|api]"
    exit 1;
fi


LAST_ARG=""
for i in $*
do
    echo "building $i"
    case "$i" in
        www)
SRC_FOLDERS="${SRC_DIR}/web"
SRC_EXCLUDES="--exclude web/placetool --exclude web/system/libraries/common/base_class.php --exclude web/eveadmin  --exclude web/temp --exclude web/ini/config --exclude core/common.func.php --exclude web/eventown/.htaccess --exclude eventown/application/logs"
#SRC_EXCLUDES=""
        sync_sproot "${IP_ADR}" "${SRC_FOLDERS}" "${SRC_EXCLUDES}"
        ;;
admin)
        SRC_FOLDERS="${SRC_DIR}/web"
        SRC_EXCLUDES="--exclude web/placetool --exclude web/system/libraries/common/base_class.php --exclude web/active --exclude web/api --exclude web/cases --exclude web/clue --exclude web/document --exclude web/eventown --exclude web/links --exclude web/meeting --exclude web/memadmin --exclude web/member --exclude web/mobile --exclude web/place --exclude web/server --exclude web/stat --exclude web/strategy --exclude web/webtt --exclude web/templets/common --exclude web/templets/default --exclude web/templets/index --exclude web/templets/place --exclude web/templets/strategy --exclude web/templets/trigger_mail --exclude web/templets/year  --exclude web/temp --exclude web/ini/config --exclude core/common.func.php"
        #SRC_EXCLUDES=""
        sync_sproot "${IP_ADR}" "${SRC_FOLDERS}" "${SRC_EXCLUDES}"
        ;; 
cdgn)
        SRC_FOLDERS="${SRC_DIR}/cdgn"
        SRC_EXCLUDES="--exclude cdgn/application/config --exclude cdgn/uploads  --exclude cdgn/templets/default/views/parts/footer.php --exclude cdgn/templets/default/views/parts/r_footer.php"
        #SRC_EXCLUDES=""
        sync_sproot "${IP_ADR}" "${SRC_FOLDERS}" "${SRC_EXCLUDES}"
;;
api)
        SRC_FOLDERS="${SRC_DIR}/api"
        SRC_EXCLUDES="--exclude api/db/db.config.php  --exclude api/db/dbconnect.php  --exclude api/db/sql.php  --exclude api/Dlibs/libs/mongo.config.php  --exclude api/script/htapi/controller/htapi.index.php"
        sync_sproot "${IP_ADR}" "${SRC_FOLDERS}" "${SRC_EXCLUDES}"
        ;;
*)
         echo "no such node"

    esac
    LAST_ARG=$i
done

0
文章属性
精彩评论