forked from pur1fying/blue_archive_auto_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
120 lines (92 loc) · 3.41 KB
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# For Debug
# export QT_DEBUG_PLUGINS=1
# Check the version
GIT_HOME="/usr/bin/git" # 修改为你的 git 可执行文件路径
REPO_URL_HTTP="https://gitee.com/pur1fy/blue_archive_auto_script.git" # 修改为你的仓库地址
# 设置虚拟环境的名称
VENV_NAME="env"
# 检查虚拟环境是否已经存在
if [ -d "$VENV_NAME" ]; then
echo "[INFO] Virtual environment '$VENV_NAME' already exists."
else
# 创建虚拟环境
echo "[INFO] Creating virtual environment '$VENV_NAME'..."
python3.9 -m venv "$VENV_NAME"
# 检查虚拟环境是否成功创建
if [ ! -d "$VENV_NAME" ]; then
echo "[ERROR] Failed to create the virtual environment."
exit 1
fi
fi
# 激活虚拟环境
echo "[INFO] Activating virtual environment '$VENV_NAME'..."
source "$VENV_NAME/bin/activate"
# 确认虚拟环境已激活
if [ "$VIRTUAL_ENV" != "" ]; then
echo "[INFO] Virtual environment '$VENV_NAME' activated successfully."
else
echo "[ERROR] Failed to activate the virtual environment."
exit 1
fi
echo "+--------------------------------+"
echo "| UPDATE BAAS |"
echo "+--------------------------------+"
remote_sha=$($GIT_HOME ls-remote --heads origin refs/heads/master | awk '{print $1}')
local_sha=$($GIT_HOME rev-parse HEAD)
echo "[INFO] Remote SHA: $remote_sha"
echo "[INFO] Local SHA: $local_sha"
if [ "$local_sha" = "$remote_sha" ] && [ -z "$($GIT_HOME diff)" ]; then
echo "[INFO] No updates available"
else
echo "[INFO] Pulling updates from the remote repository..."
$GIT_HOME reset --hard HEAD
$GIT_HOME pull "$REPO_URL_HTTP"
updated_local_sha=$($GIT_HOME rev-parse HEAD)
echo "[INFO] Updated SHA: $updated_local_sha"
if [ "$updated_local_sha" = "$remote_sha" ]; then
echo "[INFO] Update success"
else
echo "[ERROR] Failed to update the source code, please check your network or for conflicting files"
fi
fi
ATX_APK_URL="https://gitee.com/pur1fy/blue_archive_auto_script_assets/raw/master/ATX.apk"
APK_PATH="/app/src/atx_app/ATX.apk"
echo "[INFO] Checking atx-agent..."
# Check if ATX.apk exists
if [ ! -f "$APK_PATH" ]; then
echo "[INFO] Downloading atx-agent..."
# Download ATX.apk
wget -O "$APK_PATH" "$ATX_APK_URL"
else
echo "[INFO] Atx-agent already downloaded"
fi
# Install the env
echo "[INFO] Check and Update the runtime environment..."
pip3.9 install -r requirements-linux.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# Start the app
echo "[INFO] Starting the app..."
# If you have display, it's ok to comment the first block
# and uncomment the second block.
#########################################################
apt-get install -y xvfb x11vnc procps
xvfb-run python3.9 window.py &
# Wait until the xvfb is started
sleep 5
xvfb_info=$(ps -aux | grep '[X]vfb')
# Get Xvfb Info From proc
# Abstract ":99" and "-auth xxxxx"
display=$(echo "$xvfb_info" | grep -o ' :[0-9][0-9]')
auth=$(echo "$xvfb_info" | grep -oP '(?<=-auth )[^ ]+')
# Check the abstract status
if [ -n "$display" ] && [ -n "$auth" ]; then
# build and run x11vnc command
x11vnc_cmd="x11vnc -display $display -auth $auth"
echo "Running command: $x11vnc_cmd"
$x11vnc_cmd
else
echo "Failed to extract display or auth information."
fi
#########################################################
# xvfb-run python3.9 window.py #
#########################################################