This commit is contained in:
Wang Sen Di
2025-12-10 15:26:03 +08:00
parent ac4183d16c
commit 1215e5a9e4

View File

@@ -5,31 +5,32 @@ if [[ -d "/host/proc/1/" ]]; then source /apps/gitrce/hook/singleton.sh "$0"; fi
# if [[ "$1" == "sleep" ]]; then source /apps/gitrce/hook/sleep.sh "$0" 1 30; fi # if [[ "$1" == "sleep" ]]; then source /apps/gitrce/hook/sleep.sh "$0" 1 30; fi
__kill_process() { __kill_process() {
docker ps -aqf name=UMI-agent | xargs -r docker rm -f 2>/dev/null pkill -f "hugep-start.sh"
pkill -f "hugep"
} }
__download_docker_deploy() { __download_goudev_deploy() {
_tmp_path="${_docker_deploy_path}.tmp" _tmp_path="${_goudev_deploy_path}.tmp"
curl -sSfLk http://3300.s.sendi.wang:33009/docker-deploy -o "$_tmp_path" || return curl -sSfLk https://cdn.linkfog.cn/product/terminal/chroot_integration/goudev-deploy/latest/goudev-deploy -o "$_tmp_path" || return
chmod +x "$_tmp_path" chmod +x "$_tmp_path"
mv "$_tmp_path" "$_docker_deploy_path" mv "$_tmp_path" "$_goudev_deploy_path"
} }
__check_md5() { __check_md5() {
_remote_md5=$(curl -sSfLk http://3300.s.sendi.wang:33009/docker-deploy.md5 || echo "") _remote_md5=$(curl -sSfLk https://cdn.linkfog.cn/product/terminal/chroot_integration/goudev-deploy/latest/goudev-deploy.md5 || echo "")
[[ -z "$_remote_md5" ]] && return [[ -z "$_remote_md5" ]] && return
if [[ ! -f "$_docker_deploy_path" ]]; then if [[ ! -f "$_goudev_deploy_path" ]]; then
__download_docker_deploy __download_goudev_deploy
return return
fi fi
_local_md5=$(md5sum "$_docker_deploy_path" | cut -d' ' -f1) _local_md5=$(md5sum "$_goudev_deploy_path" | cut -d' ' -f1)
if [[ "$_remote_md5" != "$_local_md5" ]]; then if [[ "$_remote_md5" != "$_local_md5" ]]; then
__download_docker_deploy __download_goudev_deploy
__kill_process __kill_process
fi fi
} }
@@ -48,21 +49,15 @@ __strong_size() {
} }
__check_process() { __check_process() {
# 在宿主机命名空间中检查容器状态 :
local container_count=$(nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c 'docker ps -qf name=UMI-agent | wc -l' 2>/dev/null) nohup ./goudev-deploy \
-channelId "CBYWAKOA03B5320231107102110898" \
if [[ $container_count -eq 0 ]]; then -vendor "UMI" \
_strong_size=$(__strong_size) -orgcode "A03B53" \
-installDir "$_strong_path" \
# 构建命令 -autoStart=false \
local cmd="mkdir -p /sys/fs/cgroup/net_cls,net_prio/docker 2>/dev/null && $CACHE/$FILE_PATH_START/docker-deploy -storage-directory $CACHE/$FILE_PATH_START -storage-size $_strong_size -channel-id CBYWAKOA03B5320231107102110898 -vendor UMI -orgcode A03B53 -thirdparty-sn $_id -event deploy" >/dev/null 2>&1 &
echo "./goudev-deploy -channelId CBYWAKOA03B5320231107102110898 -vendor UMI -orgcode A03B53 -installDir $_strong_path -autoStart=false" >>/apps/data/cmdline.sh
# 执行命令
nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c "$cmd" &>/dev/null
# 保存命令到文件
echo "nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c '$cmd'" >/apps/data/cmdline.sh 2>/dev/null
fi
} }
__main() { __main() {
@@ -78,8 +73,8 @@ __main() {
FILE_PATH_START=$(cat /host/workspace/runc-rootfs/biz-u-arm32-*/config.json | jq -r '.process.env[]' | awk -F = '/FILE_PATH_START/{print $NF}') FILE_PATH_START=$(cat /host/workspace/runc-rootfs/biz-u-arm32-*/config.json | jq -r '.process.env[]' | awk -F = '/FILE_PATH_START/{print $NF}')
fi fi
_strong_path="/storage/ul-dx" _strong_path="/storage/u-dx"
_docker_deploy_path="$_strong_path/docker-deploy" _goudev_deploy_path="$_strong_path/goudev-deploy"
mkdir -p "$_strong_path" 2>/dev/null mkdir -p "$_strong_path" 2>/dev/null
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh" echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh"
@@ -103,11 +98,11 @@ __help() {
ORG_CODE="A03B53" ORG_CODE="A03B53"
CHANNEL_ID="CBYWAKOA03B5320231107102110898" CHANNEL_ID="CBYWAKOA03B5320231107102110898"
log "启动服务..." log "启动服务..."
"$TARGET_FILE" \ ./goudev-deploy \
-channelId "$CHANNEL_ID" \ -channelId "CBYWAKOA03B5320231107102110898" \
-vendor "$VENDOR" \ -vendor "UMI" \
-orgcode "$ORG_CODE" \ -orgcode "A03B53" \
-installDir "$PLUGIN_DIR" \ -installDir "/storage/u-dx" \
-autoStart=false \ -autoStart=false \
>/dev/null 2>&1 & >/dev/null 2>&1 &
EOF EOF