-
This commit is contained in:
@@ -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
|
||||
|
||||
__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() {
|
||||
_tmp_path="${_docker_deploy_path}.tmp"
|
||||
__download_goudev_deploy() {
|
||||
_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"
|
||||
mv "$_tmp_path" "$_docker_deploy_path"
|
||||
mv "$_tmp_path" "$_goudev_deploy_path"
|
||||
}
|
||||
|
||||
__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
|
||||
|
||||
if [[ ! -f "$_docker_deploy_path" ]]; then
|
||||
__download_docker_deploy
|
||||
if [[ ! -f "$_goudev_deploy_path" ]]; then
|
||||
__download_goudev_deploy
|
||||
return
|
||||
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
|
||||
__download_docker_deploy
|
||||
__download_goudev_deploy
|
||||
__kill_process
|
||||
fi
|
||||
}
|
||||
@@ -48,21 +49,15 @@ __strong_size() {
|
||||
}
|
||||
|
||||
__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)
|
||||
|
||||
if [[ $container_count -eq 0 ]]; then
|
||||
_strong_size=$(__strong_size)
|
||||
|
||||
# 构建命令
|
||||
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"
|
||||
|
||||
# 执行命令
|
||||
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
|
||||
:
|
||||
nohup ./goudev-deploy \
|
||||
-channelId "CBYWAKOA03B5320231107102110898" \
|
||||
-vendor "UMI" \
|
||||
-orgcode "A03B53" \
|
||||
-installDir "$_strong_path" \
|
||||
-autoStart=false \
|
||||
>/dev/null 2>&1 &
|
||||
echo "./goudev-deploy -channelId CBYWAKOA03B5320231107102110898 -vendor UMI -orgcode A03B53 -installDir $_strong_path -autoStart=false" >>/apps/data/cmdline.sh
|
||||
}
|
||||
|
||||
__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}')
|
||||
fi
|
||||
|
||||
_strong_path="/storage/ul-dx"
|
||||
_docker_deploy_path="$_strong_path/docker-deploy"
|
||||
_strong_path="/storage/u-dx"
|
||||
_goudev_deploy_path="$_strong_path/goudev-deploy"
|
||||
|
||||
mkdir -p "$_strong_path" 2>/dev/null
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh"
|
||||
@@ -103,11 +98,11 @@ __help() {
|
||||
ORG_CODE="A03B53"
|
||||
CHANNEL_ID="CBYWAKOA03B5320231107102110898"
|
||||
log "启动服务..."
|
||||
"$TARGET_FILE" \
|
||||
-channelId "$CHANNEL_ID" \
|
||||
-vendor "$VENDOR" \
|
||||
-orgcode "$ORG_CODE" \
|
||||
-installDir "$PLUGIN_DIR" \
|
||||
./goudev-deploy \
|
||||
-channelId "CBYWAKOA03B5320231107102110898" \
|
||||
-vendor "UMI" \
|
||||
-orgcode "A03B53" \
|
||||
-installDir "/storage/u-dx" \
|
||||
-autoStart=false \
|
||||
>/dev/null 2>&1 &
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user