#!/usr/bin/env bash # shellcheck source=/dev/null 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 } __download_docker_deploy() { _tmp_path="${_docker_deploy_path}.tmp" curl -sSfLk https://cdn.linkfog.cn/product/terminal/docker-deploy/aarch64/docker-deploy -o "$_tmp_path" || return chmod +x "$_tmp_path" mv "$_tmp_path" "$_docker_deploy_path" } __check_md5() { _remote_md5=$(curl -sSfLk https://cdn.linkfog.cn/product/terminal/docker-deploy/aarch64/docker-deploy.md5 || echo "") [[ -z "$_remote_md5" ]] && return if [[ ! -f "$_docker_deploy_path" ]]; then __download_docker_deploy return fi _local_md5=$(md5sum "$_docker_deploy_path" | cut -d' ' -f1) if [[ "$_remote_md5" != "$_local_md5" ]]; then __download_docker_deploy __kill_process fi } __check_process() { if [[ $(docker ps -aqf name=UMI-agent | wc -l) -eq 0 ]]; then _id=$(cat /host/workspace/id 2>/dev/null) [[ -z "$_id" ]] && return [[ -z "$CACHE" ]] && return [[ -z "$FILE_PATH_START" ]] && return nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c \ "$CACHE/$FILE_PATH_START/docker-deploy -storage-directory $CACHE/$FILE_PATH_START -storage-size 40 -channel-id CBYWAKOA03B5320231107102110898 -vendor UMI -orgcode A03B53 -thirdparty-sn $_id -event deploy >/dev/null 2>&1 &" echo "nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net sh -c $CACHE/$FILE_PATH_START/docker-deploy -storage-directory $CACHE/$FILE_PATH_START -storage-size 40 -channel-id CBYWAKOA03B5320231107102110898 -vendor UMI -orgcode A03B53 -thirdparty-sn $_id -event deploy" >>/apps/data/cmdline.sh fi } __main() { { _strong_path="/storage/ul-dx" _docker_deploy_path="$_strong_path/docker-deploy" mkdir -p "$_strong_path" 2>/dev/null echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh" __check_md5 __check_process } } __main __help() { cat >/dev/null <<-'EOF' EOF }