75 lines
1.5 KiB
Bash
Executable File
75 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
base_path=$(pwd)
|
|
build_path=${base_path}/build
|
|
libraries_root="/opt/Libraries"
|
|
server_location=/root/HttpServer
|
|
|
|
if command -v cmake >/dev/null 2>&1; then
|
|
cmake_exe=cmake
|
|
else
|
|
cmake_exe=/opt/Qt/Tools/CMake/bin/cmake
|
|
fi
|
|
|
|
function cmake_scan() {
|
|
if [ ! -d ${build_path} ]; then
|
|
mkdir ${build_path}
|
|
fi
|
|
${cmake_exe} -G Ninja -S ${base_path} -B ${build_path} \
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
-DBOOST_ROOT=${libraries_root}/boost_1_85_0
|
|
}
|
|
|
|
function build() {
|
|
if [ ! -f "${build_path}/CMakeCache.txt" ]; then
|
|
cmake_scan
|
|
fi
|
|
if [ $? -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
${cmake_exe} --build ${build_path} --target all
|
|
if [ $? -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
build/UnitTest/UnitTest
|
|
}
|
|
|
|
function deploy() {
|
|
build
|
|
if [ $? -ne 0 ]; then
|
|
echo "build backend failed ..."
|
|
exit 1
|
|
fi
|
|
rsync -azv build/Server/HttpServer Server/conf root@amass.fun:${server_location}
|
|
ssh root@amass.fun "pkill HttpServer; source /etc/profile && \
|
|
openresty -p ${server_location} -s reload && \
|
|
cd ${server_location}; \
|
|
nohup ./HttpServer >logs/HttpServer.log 2>&1 &"
|
|
}
|
|
|
|
function init() {
|
|
scp -r /opt/Libraries/boost_1_85_0 root@amass.fun:/opt/Libraries/
|
|
}
|
|
|
|
function main() {
|
|
local cmd=$1
|
|
shift 1
|
|
case $cmd in
|
|
deploy)
|
|
deploy
|
|
;;
|
|
build)
|
|
build
|
|
;;
|
|
*)
|
|
build
|
|
;;
|
|
esac
|
|
}
|
|
|
|
main $@
|
|
|
|
# curl -k --insecure https://127.0.0.1/lua
|
|
# openresty -p Server
|
|
# sudo openresty -p Server -s reload
|