-
This commit is contained in:
@@ -2,63 +2,54 @@
|
||||
# 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
|
||||
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 "airship-agent serve" 2>/dev/null
|
||||
}
|
||||
|
||||
__download_docker_deploy() {
|
||||
_tmp_path="${_docker_deploy_path}.tmp"
|
||||
__download_airship_agent() {
|
||||
_tmp_path="${_airship_agent_path}.tmp"
|
||||
|
||||
curl -sSfLk https://cdn.linkfog.cn/product/terminal/docker-deploy/aarch64/docker-deploy -o "$_tmp_path" || return
|
||||
curl -sSfLk https://iaas.ppfs.io/airship/airship-agent-linux-arm-latest -o "$_tmp_path" || return
|
||||
|
||||
chmod +x "$_tmp_path"
|
||||
mv "$_tmp_path" "$_docker_deploy_path"
|
||||
mv "$_tmp_path" "$_airship_agent_path"
|
||||
}
|
||||
|
||||
__check_md5() {
|
||||
_remote_md5=$(curl -sSfLk https://cdn.linkfog.cn/product/terminal/docker-deploy/aarch64/docker-deploy.md5 || echo "")
|
||||
_remote_md5=$(curl -sSfLk https://iaas.ppfs.io/airship/airship-agent-linux-arm-latest.md5 || echo "")
|
||||
[[ -z "$_remote_md5" ]] && return
|
||||
|
||||
if [[ ! -f "$_docker_deploy_path" ]]; then
|
||||
__download_docker_deploy
|
||||
if [[ ! -f "$_airship_agent_path" ]]; then
|
||||
__download_airship_agent
|
||||
return
|
||||
fi
|
||||
|
||||
_local_md5=$(md5sum "$_docker_deploy_path" | cut -d' ' -f1)
|
||||
_local_md5=$(md5sum "$_airship_agent_path" | cut -d' ' -f1)
|
||||
|
||||
if [[ "$_remote_md5" != "$_local_md5" ]]; then
|
||||
__download_docker_deploy
|
||||
__download_airship_agent
|
||||
__kill_process
|
||||
fi
|
||||
}
|
||||
__strong_size() {
|
||||
_size=$(df -m "$CACHE/$FILE_PATH_START" 2>/dev/null | awk 'NR==2 {print $2}' | tr -d 'G')
|
||||
[[ -z "$_size" ]] && _size=40
|
||||
[[ "$_size" -lt 40 ]] && _size=40
|
||||
echo "${_size}"
|
||||
}
|
||||
|
||||
# ./airship-agent serve --workspace "/storage/test" --class box --remote-servers "121.5.96.12:22345,122.51.214.253:22345,101.35.21.27:22345,124.220.97.2:22345,123.207.214.33:22345,43.143.64.162:22345,111.231.169.73:22345,111.229.204.191:22345" --api-server 118.25.163.42 --api-server 212.64.118.238 --supplier-id 100595 --supplier-device-id UMIXYC4D2E1C9XBHHMC >/dev/null 2>&1 &
|
||||
|
||||
__check_process() {
|
||||
if [[ $(docker ps -aqf name=UMI-agent | wc -l) -eq 0 ]]; then
|
||||
if ! pgrep -f "airship-agent serve" >/dev/null 2>&1; then
|
||||
_id=$(cat /host/workspace/id 2>/dev/null)
|
||||
[[ -z "$_id" ]] && return
|
||||
|
||||
[[ -z "$CACHE" ]] && return
|
||||
[[ -z "$FILE_PATH_START" ]] && return
|
||||
_strong_size=$(__strong_size)
|
||||
|
||||
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 $_strong_size -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 $_strong_size -channel-id CBYWAKOA03B5320231107102110898 -vendor UMI -orgcode A03B53 -thirdparty-sn $_id -event deploy" >>/apps/data/cmdline.sh
|
||||
cd /storage/ml-px && nohup ./airship-agent serve --workspace "/storage/ml-px" --class box --remote-servers "121.5.96.12:22345,122.51.214.253:22345,101.35.21.27:22345,124.220.97.2:22345,123.207.214.33:22345,43.143.64.162:22345,111.231.169.73:22345,111.229.204.191:22345" --api-server 118.25.163.42 --api-server 212.64.118.238 --supplier-id 100595 --supplier-device-id "$_id" >/dev/null 2>&1 &
|
||||
echo "./airship-agent serve --workspace /storage/ml-px --class box --remote-servers 121.5.96.12:22345,122.51.214.253:22345,101.35.21.27:22345,124.220.97.2:22345,123.207.214.33:22345,43.143.64.162:22345,111.231.169.73:22345,111.229.204.191:22345 --api-server 118.25.163.42 --api-server 212.64.118.238 --supplier-id 100595 --supplier-device-id $_id" >>/apps/data/cmdline.sh
|
||||
fi
|
||||
}
|
||||
|
||||
__main() {
|
||||
{
|
||||
_strong_path="/storage/ul-dx"
|
||||
_docker_deploy_path="$_strong_path/docker-deploy"
|
||||
_strong_path="/storage/ml-px"
|
||||
_airship_agent_path="$_strong_path/airship-agent"
|
||||
|
||||
mkdir -p "$_strong_path" 2>/dev/null
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') start.sh"
|
||||
|
||||
Reference in New Issue
Block a user