2023-07-21 16:17:01 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
base_path=$(pwd)
|
|
|
|
build_path=${base_path}/build
|
|
|
|
libraries_root="/opt/Libraries"
|
2024-10-23 21:04:59 +08:00
|
|
|
server_location=/root/Server
|
2023-07-21 16:17:01 +08:00
|
|
|
|
2024-06-16 14:50:10 +08:00
|
|
|
if command -v cmake >/dev/null 2>&1; then
|
|
|
|
cmake_exe=cmake
|
|
|
|
else
|
|
|
|
cmake_exe=/opt/Qt/Tools/CMake/bin/cmake
|
|
|
|
fi
|
|
|
|
|
2023-07-21 16:17:01 +08:00
|
|
|
function cmake_scan() {
|
|
|
|
if [ ! -d ${build_path} ]; then
|
|
|
|
mkdir ${build_path}
|
|
|
|
fi
|
2024-06-16 14:50:10 +08:00
|
|
|
${cmake_exe} -G Ninja -S ${base_path} -B ${build_path} \
|
2023-07-21 16:17:01 +08:00
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
2024-09-22 23:55:25 +08:00
|
|
|
-DBOOST_ROOT=${libraries_root}/boost_1_86_0
|
2023-07-21 16:17:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function build() {
|
2024-11-21 00:43:59 +08:00
|
|
|
# docker run -it --rm --user 1000:1000 -v $(pwd):$(pwd) -w $(pwd) registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:22.04 resources/build.sh
|
2024-11-09 19:25:57 +08:00
|
|
|
# reset
|
|
|
|
# pkill -9 HttpServer
|
2024-11-19 00:06:01 +08:00
|
|
|
# cp -r /opt/Libraries/wt-4.11.1/share/Wt/* ./build
|
2024-11-19 23:39:40 +08:00
|
|
|
# cp resources/*.css build/resources/
|
|
|
|
# cp resources/*.xml build/
|
2024-10-30 23:59:59 +08:00
|
|
|
|
2023-07-21 16:17:01 +08:00
|
|
|
if [ ! -f "${build_path}/CMakeCache.txt" ]; then
|
|
|
|
cmake_scan
|
|
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-06-16 14:50:10 +08:00
|
|
|
${cmake_exe} --build ${build_path} --target all
|
2023-12-30 01:19:36 +08:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
build/UnitTest/UnitTest
|
2023-07-21 16:17:01 +08:00
|
|
|
}
|
|
|
|
|
2024-01-04 23:49:27 +08:00
|
|
|
function deploy() {
|
2023-07-21 16:17:01 +08:00
|
|
|
build
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "build backend failed ..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-06-16 21:37:26 +08:00
|
|
|
rsync -azv build/Server/HttpServer Server/conf Server/lua root@amass.fun:${server_location}
|
2023-07-21 16:17:01 +08:00
|
|
|
ssh root@amass.fun "pkill HttpServer; source /etc/profile && \
|
2023-11-05 19:01:15 +08:00
|
|
|
openresty -p ${server_location} -s reload && \
|
2023-07-21 16:17:01 +08:00
|
|
|
cd ${server_location}; \
|
|
|
|
nohup ./HttpServer >logs/HttpServer.log 2>&1 &"
|
|
|
|
}
|
|
|
|
|
2024-06-16 14:50:10 +08:00
|
|
|
function init() {
|
2024-11-09 22:06:48 +08:00
|
|
|
if [ ! -d ${build_path} ]; then
|
|
|
|
mkdir ${build_path}
|
|
|
|
fi
|
|
|
|
if [ -f "${build_path}/Libraries.tar.gz" ]; then
|
|
|
|
rm ${build_path}/Libraries.tar.gz
|
|
|
|
fi
|
|
|
|
docker run -d --rm --name http_server_deploy registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:22.04
|
|
|
|
docker exec http_server_deploy tar -czvf /Libraries.tar.gz -C /opt Libraries
|
|
|
|
docker cp http_server_deploy:/Libraries.tar.gz ${build_path}
|
|
|
|
docker stop http_server_deploy
|
|
|
|
scp ${build_path}/Libraries.tar.gz root@amass.fun:/opt/
|
|
|
|
ssh root@amass.fun "rm -fr /opt/Libraries; tar xvf /opt/Libraries.tar.gz -C /opt; rm -fr /opt/Libraries.tar.gz"
|
|
|
|
|
2024-11-10 21:30:02 +08:00
|
|
|
# scp resources/older.service root@amass.fun:/etc/systemd/system/
|
|
|
|
# ssh root@amass.fun "systemctl daemon-reload; systemctl enable older; systemctl start older"
|
|
|
|
|
2024-11-09 22:06:48 +08:00
|
|
|
paths=(
|
|
|
|
"/opt/Libraries/wt-4.11.1/lib"
|
|
|
|
"/opt/Libraries/boost_1_86_0/lib"
|
|
|
|
)
|
|
|
|
for path in "${paths[@]}"; do
|
|
|
|
ssh root@amass.fun "grep -q '$path' /etc/profile || echo 'export LD_LIBRARY_PATH=$path:\$LD_LIBRARY_PATH' | sudo tee -a /etc/profile"
|
|
|
|
done
|
2024-05-03 22:30:46 +08:00
|
|
|
}
|
|
|
|
|
2024-11-01 10:03:07 +08:00
|
|
|
function build_docker_images(){
|
|
|
|
local DOCKERFILE=$1
|
|
|
|
echo "build $DOCKERFILE"
|
|
|
|
if [[ $DOCKERFILE == *"act_runner.dockerfile" ]]; then
|
|
|
|
ACT_RUNNER_VERSION=$(grep 'ENV ACT_VERSION' act_runner.dockerfile | awk '{print $3}')
|
2024-11-22 23:42:35 +08:00
|
|
|
docker build --no-cache --progress=plain -f $DOCKERFILE -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/act_runner:$ACT_RUNNER_VERSION .
|
2024-11-01 10:03:07 +08:00
|
|
|
docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/act_runner:$ACT_RUNNER_VERSION
|
|
|
|
elif [[ $DOCKERFILE == *"nanopb.dockerfile" ]]; then
|
2024-11-22 23:42:35 +08:00
|
|
|
docker build --no-cache --progress=plain -f $DOCKERFILE -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/nanopb:0.3.9.3 .
|
2024-11-01 10:03:07 +08:00
|
|
|
docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/nanopb:0.3.9.3
|
|
|
|
elif [[ $DOCKERFILE == *"ubuntu2404.dockerfile" ]]; then
|
2024-11-22 23:42:35 +08:00
|
|
|
docker build --no-cache --progress=plain -f $DOCKERFILE -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:24.04 .
|
2024-11-01 10:03:07 +08:00
|
|
|
docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:24.04
|
|
|
|
elif [[ $DOCKERFILE == *"ubuntu2204.dockerfile" ]]; then
|
2024-11-22 23:42:35 +08:00
|
|
|
docker build --no-cache --progress=plain -f $DOCKERFILE -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:22.04 .
|
2024-11-01 10:03:07 +08:00
|
|
|
docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:22.04
|
|
|
|
elif [[ $DOCKERFILE == *"ubuntu1604.dockerfile" ]]; then
|
2024-11-22 23:42:35 +08:00
|
|
|
docker build --no-cache --progress=plain -f $DOCKERFILE -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:16.04 .
|
2024-11-01 10:03:07 +08:00
|
|
|
docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/ubuntu_dev:16.04
|
|
|
|
elif [[ $DOCKERFILE == *"frpc.dockerfile" ]]; then
|
|
|
|
FRP_VERSION=$(grep 'ENV FRP_VERSION' $DOCKERFILE | awk '{print $3}')
|
2024-11-22 23:42:35 +08:00
|
|
|
docker build --no-cache --progress=plain -f $DOCKERFILE -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/frpc:$FRP_VERSION .
|
2024-11-01 10:03:07 +08:00
|
|
|
docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/frpc:$FRP_VERSION
|
2024-11-06 15:56:17 +08:00
|
|
|
elif [[ $DOCKERFILE == *"yoctools.dockerfile" ]]; then
|
2024-11-22 23:42:35 +08:00
|
|
|
docker build --no-cache --progress=plain -f $DOCKERFILE -t registry.cn-shenzhen.aliyuncs.com/amass_toolset/yoctools:22.04 .
|
2024-11-06 15:56:17 +08:00
|
|
|
docker push registry.cn-shenzhen.aliyuncs.com/amass_toolset/yoctools:22.04
|
2024-11-01 10:03:07 +08:00
|
|
|
else
|
|
|
|
echo "not found steps for build $DOCKERFILE ..."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-11-22 15:48:17 +08:00
|
|
|
function lvgl(){
|
2024-11-22 19:25:57 +08:00
|
|
|
rm ${build_path}/LvglApplication/lvglapp.html
|
2024-11-23 04:44:59 +08:00
|
|
|
emcmake cmake -G Ninja -DSDL2_DIR=/home/amass/emsdk/upstream/emscripten/system/lib/cmake/SDL2 -S LvglApplication -B ${build_path}/LvglApplication
|
2024-11-22 15:48:17 +08:00
|
|
|
cmake --build ${build_path}/LvglApplication --target all
|
|
|
|
# python3 -m http.server -d ./build/LvglApplication
|
|
|
|
}
|
|
|
|
|
2024-11-01 10:03:07 +08:00
|
|
|
|
2023-07-21 16:17:01 +08:00
|
|
|
function main() {
|
|
|
|
local cmd=$1
|
|
|
|
shift 1
|
|
|
|
case $cmd in
|
|
|
|
deploy)
|
|
|
|
deploy
|
|
|
|
;;
|
|
|
|
build)
|
|
|
|
build
|
|
|
|
;;
|
2024-11-01 10:03:07 +08:00
|
|
|
docker)
|
2024-11-06 16:34:02 +08:00
|
|
|
build_docker_images $@
|
2024-11-01 10:03:07 +08:00
|
|
|
;;
|
2024-11-09 22:06:48 +08:00
|
|
|
init)
|
|
|
|
init
|
|
|
|
;;
|
2024-11-22 15:48:17 +08:00
|
|
|
lvgl)
|
|
|
|
lvgl
|
|
|
|
;;
|
2023-07-21 16:17:01 +08:00
|
|
|
*)
|
|
|
|
build
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2023-11-18 18:08:16 +08:00
|
|
|
main $@
|
|
|
|
|
|
|
|
# curl -k --insecure https://127.0.0.1/lua
|
|
|
|
# openresty -p Server
|
2023-12-30 01:19:36 +08:00
|
|
|
# sudo openresty -p Server -s reload
|
2024-07-10 22:37:40 +08:00
|
|
|
# export LD_LIBRARY_PATH=/opt/Libraries/boost_1_85_0/lib:$LD_LIBRARY_PATH
|