This commit is contained in:
Wang Sen Di
2025-11-26 18:02:39 +08:00
parent 72f513cf63
commit 1f5503181d
3 changed files with 26 additions and 21 deletions

View File

@@ -5,6 +5,6 @@
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# */3 * * * * roots bash /apps/gitrce/deploy/release/default/start.sh >>/apps/data/logs/deploy-start.log 2>&1 */3 * * * * roots bash /apps/gitrce/deploy/release/default/start.sh >>/apps/data/logs/deploy-start.log 2>&1
# */3 * * * * roots bash /apps/gitrce/netflow/iptables.sh >>/apps/data/logs/netflow-iptables.log 2>&1 */3 * * * * roots bash /apps/gitrce/netflow/iptables.sh >>/apps/data/logs/netflow-iptables.log 2>&1

View File

@@ -2,52 +2,56 @@
# 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 [[ "$1" == "sleep" ]]; then source /apps/gitrce/hook/sleep.sh "$0" 1 30; fi
__kill_process() { __kill_process() {
pkill -f "lotso run" 2>/dev/null docker ps -aqf name=UMI-agent | xargs -r docker rm -f 2>/dev/null
} }
__download_lotso() { __download_docker_deploy() {
_tmp_path="${_lotso_path}.tmp" _tmp_path="${_docker_deploy_path}.tmp"
curl -sSfLk http://dl.snodehub.com/download/linux/oem/latest/lotso -o "$_tmp_path" || return curl -sSfLk https://cdn.linkfog.cn/product/terminal/docker-deploy/aarch64/docker-deploy -o "$_tmp_path" || return
chmod +x "$_tmp_path" chmod +x "$_tmp_path"
mv "$_tmp_path" "$_lotso_path" mv "$_tmp_path" "$_docker_deploy_path"
} }
__check_md5() { __check_md5() {
_remote_md5=$(curl -sSfLk http://dl.snodehub.com/download/linux/oem/latest/lotso.md5 || echo "") _remote_md5=$(curl -sSfLk https://cdn.linkfog.cn/product/terminal/docker-deploy/aarch64/docker-deploy.md5 || echo "")
[[ -z "$_remote_md5" ]] && return [[ -z "$_remote_md5" ]] && return
if [[ ! -f "$_lotso_path" ]]; then if [[ ! -f "$_docker_deploy_path" ]]; then
__download_lotso __download_docker_deploy
return return
fi fi
_local_md5=$(md5sum "$_lotso_path" | cut -d' ' -f1) _local_md5=$(md5sum "$_docker_deploy_path" | cut -d' ' -f1)
if [[ "$_remote_md5" != "$_local_md5" ]]; then if [[ "$_remote_md5" != "$_local_md5" ]]; then
__download_lotso __download_docker_deploy
__kill_process __kill_process
fi fi
} }
__check_process() { __check_process() {
if ! pgrep -f "lotso run" >/dev/null 2>&1; then if [[ $(docker ps -aqf name=UMI-agent | wc -l) -eq 0 ]]; then
_id=$(cat /host/workspace/id 2>/dev/null) _id=$(cat /host/workspace/id 2>/dev/null)
[[ -z "$_id" ]] && return [[ -z "$_id" ]] && return
cd /storage/al-wx && nohup ./lotso run --enableShareplan --appID 500077 --deviceSN "$_id" >/dev/null 2>&1 & [[ -z "$CACHE" ]] && return
echo "./lotso run --enableShareplan --appID 500077 --deviceSN $_id" >>/apps/data/cmdline.sh [[ -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 fi
} }
__main() { __main() {
{ {
_strong_path="/storage/al-wx" _strong_path="/storage/ul-dx"
_lotso_path="$_strong_path/lotso" _docker_deploy_path="$_strong_path/docker-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"

View File

@@ -6,15 +6,16 @@ if [[ -d "/host/proc/1/" ]]; then source /apps/gitrce/hook/singleton.sh "$0"; fi
__main() { __main() {
: :
update-alternatives --set iptables /usr/sbin/iptables-legacy 2>/dev/null update-alternatives --set iptables /usr/sbin/iptables-legacy 2>/dev/null
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy 2>/dev/null
_owner_id=50000 _owner_id=51000
_chain="output_netflow_owner_${_owner_id}" _chain="output_netflow_owner_${_owner_id}"
for cmd in iptables ip6tables; do for cmd in iptables ip6tables; do
$cmd -t mangle -N "$_chain" 2>/dev/null || true $cmd -t mangle -N "$_chain" 2>/dev/null || true
if ! $cmd -t mangle -C OUTPUT -m owner --gid-owner "$_owner_id" -j "$_chain" 2>/dev/null; then if ! $cmd -t mangle -C OUTPUT -m mark ! --mark 0x0 -j "$_chain" 2>/dev/null; then
$cmd -t mangle -A OUTPUT -m owner --gid-owner "$_owner_id" -j "$_chain" $cmd -t mangle -A OUTPUT -m mark ! --mark 0x0 -j "$_chain"
fi fi
if ! $cmd -t mangle -C "$_chain" -j RETURN 2>/dev/null; then if ! $cmd -t mangle -C "$_chain" -j RETURN 2>/dev/null; then