-
This commit is contained in:
@@ -1,59 +1,85 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
|
|
||||||
if [[ -d "/host/proc/1/" ]]; then source /apps/gitrce/hook/singleton.sh "$0"; fi
|
# 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 [[ -d "/host/proc/1/" ]]; then source /apps/gitrce/hook/nsenter.sh "$0"; fi
|
||||||
|
|
||||||
__kill_process() {
|
__kill_process() {
|
||||||
pkill -f "lotso run" 2>/dev/null
|
pkill -f "airship-agent serve"
|
||||||
}
|
}
|
||||||
|
|
||||||
__download_lotso() {
|
__download_airship_agent() {
|
||||||
_tmp_path="${_lotso_path}.tmp"
|
_tmp_path="${_airship_agent_path}.tmp"
|
||||||
|
echo "download airship-agent to $_tmp_path"
|
||||||
|
|
||||||
curl -sSfLk http://dl.snodehub.com/download/android/oem/latest/lotso -o "$_tmp_path" || return
|
curl -sSfLk https://iaas.ppfs.io/airship/airship-agent-android-arm-latest -o "$_tmp_path" || return
|
||||||
|
|
||||||
chmod +x "$_tmp_path"
|
chmod +x "$_tmp_path"
|
||||||
mv "$_tmp_path" "$_lotso_path"
|
mv "$_tmp_path" "$_airship_agent_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
__check_md5() {
|
__check_md5() {
|
||||||
_remote_md5=$(curl -sSfLk http://dl.snodehub.com/download/android/oem/latest/lotso.md5 || echo "")
|
_remote_md5=$(curl -sSfLk https://iaas.ppfs.io/airship/airship-agent-android-arm-latest.md5 || echo "")
|
||||||
[[ -z "$_remote_md5" ]] && return
|
[[ -z "$_remote_md5" ]] && return
|
||||||
|
|
||||||
if [[ ! -f "$_lotso_path" ]]; then
|
if [[ ! -f "$_airship_agent_path" ]]; then
|
||||||
__download_lotso
|
__download_airship_agent
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_local_md5=$(md5sum "$_lotso_path" | cut -d' ' -f1)
|
_local_md5=$(md5sum "$_airship_agent_path" | cut -d' ' -f1)
|
||||||
|
|
||||||
if [[ "$_remote_md5" != "$_local_md5" ]]; then
|
if [[ "$_remote_md5" != "$_local_md5" ]]; then
|
||||||
__download_lotso
|
__download_airship_agent
|
||||||
__kill_process
|
__kill_process
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__check_process() {
|
# ./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 &
|
||||||
if ! pgrep -f "lotso run" >/dev/null 2>&1; then
|
|
||||||
_id=$(cat /host/workspace/id 2>/dev/null)
|
|
||||||
[[ -z "$_id" ]] && return
|
|
||||||
|
|
||||||
cd /storage/a-wx && nohup ./lotso run --enableShareplan --appID 500077 --deviceSN "$_id" >/dev/null 2>&1 &
|
__check_process() {
|
||||||
echo "./lotso run --enableShareplan --appID 500077 --deviceSN $_id" >>/apps/data/cmdline.sh
|
_ps_cmd="ps -ef | grep 'airship-agent serve' | grep -v grep"
|
||||||
|
if [[ $(sh -c "$_ps_cmd" | wc -l) -eq 0 ]]; then
|
||||||
|
_id=$(cat /host/workspace/id 2>/dev/null)
|
||||||
|
|
||||||
|
_cmd="
|
||||||
|
${CACHE}/${FILE_PATH_START}/airship-agent serve \\
|
||||||
|
--workspace ${CACHE}/${FILE_PATH_START} \\
|
||||||
|
--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}
|
||||||
|
"
|
||||||
|
|
||||||
|
echo "启动命令: $_cmd"
|
||||||
|
|
||||||
|
"$_cmd" &>/dev/null &
|
||||||
|
echo "$_cmd" >/apps/data/cmdline.sh
|
||||||
|
echo "airship-agent 启动完成"
|
||||||
|
else
|
||||||
|
echo "airship-agent serve is running"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
__main() {
|
__main() {
|
||||||
{
|
if [[ -z "$_id" ]]; then
|
||||||
_strong_path="/storage/a-wx"
|
_id=$(cat /host/workspace/id 2>/dev/null)
|
||||||
_lotso_path="$_strong_path/lotso"
|
fi
|
||||||
|
# 防止环境变量有问题
|
||||||
|
if [[ -z "$CACHE" ]]; then
|
||||||
|
CACHE=$(cat /host/workspace/runc-rootfs/biz-m-arm32-*/config.json | jq -r '.process.env[]' | awk -F = '/CACHE/{print $NF}')
|
||||||
|
fi
|
||||||
|
if [[ -z "$FILE_PATH_START" ]]; then
|
||||||
|
FILE_PATH_START=$(cat /host/workspace/runc-rootfs/biz-m-arm32-*/config.json | jq -r '.process.env[]' | awk -F = '/FILE_PATH_START/{print $NF}')
|
||||||
|
fi
|
||||||
|
|
||||||
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"
|
_strong_path="$CACHE/$FILE_PATH_START"
|
||||||
__check_md5
|
_airship_agent_path="$_strong_path/airship-agent"
|
||||||
__check_process
|
__check_md5
|
||||||
}
|
__check_process
|
||||||
}
|
}
|
||||||
|
|
||||||
__main
|
__main
|
||||||
|
|||||||
Reference in New Issue
Block a user