You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
241 lines
5.7 KiB
241 lines
5.7 KiB
#!/bin/bash
|
|
|
|
#脚本出错时中断执行
|
|
set -e
|
|
|
|
SYSTEM=`uname -s`
|
|
|
|
BUILD_CONFIG=Debug
|
|
PUBLISH_CONFIG=Release
|
|
NETCOREVER=net6.0
|
|
|
|
RUNTIME_WIN=win-x64
|
|
RUNTIME_LINUX=linux-x64
|
|
RUNTIME_MAC=osx-x64
|
|
RUNTIME=$RUNTIME_WIN
|
|
|
|
if [ $SYSTEM = "Linux" ] ; then
|
|
RUNTIME=$RUNTIME_LINUX;
|
|
elif [ $SYSTEM = "Darwin" ] ; then
|
|
RUNTIME=$RUNTIME_MAC;
|
|
fi
|
|
|
|
RESTORE=false
|
|
PUBLISH=false
|
|
BUILD_SERVER_PROJ=true
|
|
DEBUG_OUTPUT=bin
|
|
RELEASE_OUTPUT=./publish/bin
|
|
|
|
|
|
PublishSvr=( "u2" )
|
|
IS_PUBLISH_SVR=0
|
|
for i in ${PublishSvr[@]} ; do
|
|
if [ "$2" == "$i" ] || [ "$3" == "$i" ] ; then
|
|
IS_PUBLISH_SVR=1
|
|
break
|
|
fi
|
|
done
|
|
|
|
|
|
build_one_proj()
|
|
{
|
|
if [ $RESTORE = "true" ] ; then
|
|
dotnet restore ./$1
|
|
fi
|
|
|
|
if [ $PUBLISH = "true" ] ; then
|
|
dotnet publish $1 --configuration $PUBLISH_CONFIG --runtime $RUNTIME --self-contained --output $RELEASE_OUTPUT --framework $NETCOREVER
|
|
else
|
|
dotnet build $1 --configuration $BUILD_CONFIG --runtime $RUNTIME --no-self-contained --output $DEBUG_OUTPUT --framework $NETCOREVER
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "****************************** build error **********************"
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
build_one_proj_exe()
|
|
{
|
|
if [ $RESTORE = "true" ] ; then
|
|
dotnet restore ./$1
|
|
fi
|
|
|
|
if [ $PUBLISH = "true" ] ; then
|
|
dotnet publish $1 --configuration $PUBLISH_CONFIG --runtime $RUNTIME --self-contained --output $RELEASE_OUTPUT --framework $NETCOREVER
|
|
else
|
|
dotnet build $1 --configuration $BUILD_CONFIG --runtime $RUNTIME --no-self-contained --output $DEBUG_OUTPUT --framework $NETCOREVER
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "****************************** build error ******************************"
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
#参数顺序 bin ip port
|
|
scp_to_destsvr()
|
|
{
|
|
echo "scp -P$3 $1 mmog@$2:~"
|
|
scp -P$3 $1 mmog@$2:~
|
|
}
|
|
|
|
cd ..
|
|
pwd
|
|
|
|
if [ "$1" = "rebuild" ] ; then
|
|
rm ./bin/* -rf
|
|
elif [ "$1" = "publish" ] ; then
|
|
RUNTIME=$RUNTIME_LINUX
|
|
PUBLISH=true
|
|
mkdir -p ./publish/bin
|
|
mkdir -p ./publish/cfg/clihotpatch
|
|
mkdir -p ./publish/ctrl_sh
|
|
mkdir -p ./publish/tools/version
|
|
mkdir -p ./publish/tools/sql
|
|
mkdir -p ./publish/ta-logBus
|
|
|
|
rm ./publish/bin/* -rf
|
|
rm ./publish/tools/sql/* -rf
|
|
rm ./publish/cfg/* -rf
|
|
rm ./publish/ctrl_sh/* -rf
|
|
rm ./publish/tools/version/* -rf
|
|
rm ./publish/ta-logBus/* -rf
|
|
|
|
cp ./cfg/* ./publish/cfg/ -rf
|
|
# 删除客户端热补丁文件,免得不小心带到外网去了
|
|
rm ./publish/cfg/clihotpatch/* -rf
|
|
cp ./ctrl_sh/* ./publish/ctrl_sh/ -rf
|
|
cp ./tools/version/gen_patch_file.py ./publish/tools/version/gen_patch_file.py -rf
|
|
cp ./tools/sql/* ./publish/tools/sql/ -rf
|
|
cp ./tools/ta-logBus/* ./publish/ta-logBus/ -rf
|
|
|
|
#服务器配置文件和策划配置文件
|
|
if [ "$2" == "cfgdesc" ] ; then
|
|
BUILD_SERVER_PROJ=false
|
|
rm ./publish/tools/sql/mysql_master_salve/* -rf
|
|
fi
|
|
|
|
#只有策划配置文件
|
|
if [ "$2" == "desc" ] ; then
|
|
BUILD_SERVER_PROJ=false
|
|
rm ./publish/tools/sql/mysql_master_salve/* -rf
|
|
rm ./publish/cfg/* -rf
|
|
mkdir -p ./publish/cfg/data
|
|
cp ./cfg/data/* ./publish/cfg/data/ -rf
|
|
fi
|
|
|
|
#只有服务器配置文件
|
|
if [ "$2" == "cfg" ] ; then
|
|
BUILD_SERVER_PROJ=false
|
|
rm ./publish/tools/sql/mysql_master_salve/* -rf
|
|
rm ./publish/cfg/data/* -rf
|
|
fi
|
|
|
|
#只有服务器配置文件
|
|
if [ "$2" == "logbus" ] ; then
|
|
BUILD_SERVER_PROJ=false
|
|
rm ./publish/cfg/* -rf
|
|
rm ./publish/bin/* -rf
|
|
rm ./publish/tools/* -rf
|
|
rm ./publish/ctrl_sh/* -rf
|
|
fi
|
|
elif [ "$1" = "1svr" ] ; then
|
|
#直接编某个svr时,换个目录编译后再拷过来,方便开发测试
|
|
rm ./debug_bin/* -rf
|
|
DEBUG_OUTPUT=debug_bin
|
|
if [ "$2" == "SogLoader" ] ; then
|
|
build_one_proj_exe $2
|
|
else
|
|
build_one_proj $2
|
|
fi
|
|
cp -f ./debug_bin/* ./bin
|
|
exit 0
|
|
fi
|
|
|
|
#只拷贝配置的话,不用构建
|
|
if [ $BUILD_SERVER_PROJ == "true" ] ; then
|
|
|
|
# build_one_proj GameServer
|
|
# build_one_proj WorldServer
|
|
# build_one_proj HttpProxyPay
|
|
# #build_one_proj BattleServer
|
|
# build_one_proj RankServer
|
|
# build_one_proj GameDBServer
|
|
# build_one_proj FriendServer
|
|
# build_one_proj HttpProxyWorld
|
|
# build_one_proj ChatServer
|
|
build_one_proj GateServer
|
|
# build_one_proj DBServer
|
|
# build_one_proj HttpProxy
|
|
# build_one_proj AccountServer
|
|
# build_one_proj RealmlistServer
|
|
# build_one_proj VersionServer
|
|
# build_one_proj OperationServer
|
|
# build_one_proj BillLogServer
|
|
# build_one_proj MailServer
|
|
# build_one_proj PlayerOpServer
|
|
# build_one_proj NameServer
|
|
build_one_proj FrameSync
|
|
build_one_proj_exe SogLoader
|
|
|
|
#build_one_proj_exe ClientTest
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $PUBLISH = "true" ] ; then
|
|
rm ./publish/bin/ref -rf
|
|
if [ "$2" != "full" ] ; then
|
|
rm ./publish/bin/lib* -rf
|
|
rm ./publish/bin/Microsoft* -rf
|
|
rm ./publish/bin/System.* -rf
|
|
rm ./publish/bin/Newtonsoft.* -rf
|
|
rm ./publish/bin/Pathoschild.* -rf
|
|
rm ./publish/bin/createdump -rf
|
|
rm ./publish/bin/DynamicExpresso* -rf
|
|
rm ./publish/bin/mscorlib.dll -rf
|
|
rm ./publish/bin/netstandard.dll -rf
|
|
rm ./publish/bin/TencentCloud.* -rf
|
|
rm ./publish/bin/WindowsBase.* -rf
|
|
rm ./publish/bin/DnsClient.dll -rf
|
|
rm ./publish/bin/MongoDB.* -rf
|
|
rm ./publish/bin/SogLoader -rf
|
|
rm ./publish/bin/SOS_README.md -rf
|
|
rm ./publish/tools/sql/mysql_master_salve/* -rf
|
|
fi
|
|
|
|
if [ "$2" != "logbus" ] ; then
|
|
rm ./publish/ta-logBus/* -rf
|
|
fi
|
|
|
|
if [ $BUILD_SERVER_PROJ == "true" ] ; then
|
|
cp ./SogLoader/SogLoader.runtimeconfig.json ./publish/bin/ -rf
|
|
else
|
|
rm ./publish/bin/* -rf
|
|
fi
|
|
|
|
BinName=pandora_server.tgz
|
|
if [ $IS_PUBLISH_SVR == 1 ] ; then
|
|
rm ./pandora_server*.tgz -f
|
|
Suffix=`date +%Y_%m_%d_%Hh`
|
|
BinName=pandora_server_$Suffix.tgz
|
|
else
|
|
if [ -f "$BinName" ]; then
|
|
rm ./$BinName
|
|
fi
|
|
fi
|
|
|
|
tar zcvf $BinName ./publish
|
|
|
|
if [ "$2" == "yuanvm" ]||[ "$3" == "yuanvm" ] ; then
|
|
scp_to_destsvr $BinName "192.168.1.159" 56000
|
|
elif [ "$2" == "gz" ]||[ "$3" == "gz" ] ; then
|
|
scp_to_destsvr $BinName "43.139.10.237" 56000
|
|
elif [ "$2" == "se" ]||[ "$3" == "se" ] ; then
|
|
scp_to_destsvr $BinName "4.193.90.54" 56000
|
|
fi
|
|
|
|
md5sum ./$BinName
|
|
fi
|
|
|