Repository navigation
Expand file tree
/
Copy pathdeploy-binary.sh
More file actions
executable file
·596 lines (534 loc) · 17.5 KB
/
Copy pathdeploy-binary.sh
File metadata and controls
executable file
·596 lines (534 loc) · 17.5 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
#!/bin/sh
set -eu
REPO="yibaiba/hideck"
SOURCE_BASE_URL="https://raw.githubusercontent.com/yibaiba/hideck/main"
RELEASES_API_URL="https://api.github.com/repos/${REPO}/releases/latest"
RELEASES_LATEST_URL="https://github.com/${REPO}/releases/latest"
RELEASES_DOWNLOAD_URL="https://github.com/${REPO}/releases/download"
USER_AGENT="hideck-deploy-binary/1.0 (+https://github.com/${REPO})"
require_command() {
command -v "$1" >/dev/null 2>&1 || {
printf '缺少 %s,无法部署 HiDeck。\n' "$1" >&2
exit 1
}
}
resolve_project_dir() {
if [ -n "${HIDECK_DIR:-}" ]; then
printf '%s\n' "$HIDECK_DIR"
return
fi
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -f "$script_dir/config/config.example.yaml" ] && [ -f "$script_dir/deploy-binary.sh" ]; then
printf '%s\n' "$script_dir"
return
fi
printf '%s/hideck\n' "$PWD"
}
detect_os() {
os=$(uname -s)
case "$os" in
Linux) ;;
*)
printf '二进制部署脚本只支持 Linux,当前系统:%s\n' "$os" >&2
exit 1
;;
esac
}
is_openwrt() {
[ -f /etc/openwrt_release ] && return 0
[ -f /etc/os-release ] && grep -qi '^ID=openwrt' /etc/os-release && return 0
return 1
}
cpu_arch() {
machine=$(uname -m)
case "$machine" in
x86_64|amd64) printf 'amd64\n' ;;
aarch64|arm64) printf 'arm64\n' ;;
armv7l|armv7|armhf) printf 'armv7\n' ;;
*)
printf '无法识别的 CPU 架构:%s\n请设置 HIDECK_ARCH=linux_amd64|linux_arm64|linux_armv7 或 openwrt_amd64|openwrt_arm64|openwrt_armv7\n' "$machine" >&2
exit 1
;;
esac
}
detect_arch() {
if [ -n "${HIDECK_ARCH:-}" ]; then
case "$HIDECK_ARCH" in
openwrt_amd64|openwrt_arm64|openwrt_armv7) printf '%s\n' "$HIDECK_ARCH" ;;
linux_amd64) printf 'linux_amd64\n' ;;
linux_arm64) printf 'linux_arm64\n' ;;
linux_armv7) printf 'linux_armv7\n' ;;
amd64|x86_64)
if is_openwrt; then printf 'openwrt_amd64\n'; else printf 'linux_amd64\n'; fi ;;
arm64|aarch64)
if is_openwrt; then printf 'openwrt_arm64\n'; else printf 'linux_arm64\n'; fi ;;
armv7|armv7l|armhf)
if is_openwrt; then printf 'openwrt_armv7\n'; else printf 'linux_armv7\n'; fi ;;
*)
printf '不支持的 HIDECK_ARCH:%s\n' "$HIDECK_ARCH" >&2
exit 1
;;
esac
return
fi
cpu=$(cpu_arch)
if is_openwrt; then
printf 'openwrt_%s\n' "$cpu"
else
printf 'linux_%s\n' "$cpu"
fi
}
curl_github() {
curl -fL --retry 3 --retry-delay 1 -A "$USER_AGENT" "$@"
}
normalize_version() {
version=$1
case "$version" in
""|latest) printf 'latest\n' ;;
v*) printf '%s\n' "$version" ;;
*) printf 'v%s\n' "$version" ;;
esac
}
extract_tag_name() {
printf '%s\n' "$1" | sed -n 's#.*/releases/tag/\([^/?#]*\).*#\1#p' | head -n 1
}
resolve_latest_version() {
latest=$( { curl_github -sS "$RELEASES_API_URL" || true; } | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)
if [ -n "$latest" ]; then
printf '%s\n' "$latest"
return
fi
latest=$(extract_tag_name "$(curl_github -sS -o /dev/null -w '%{url_effective}' "$RELEASES_LATEST_URL" || true)")
if [ -n "$latest" ]; then
printf '%s\n' "$latest"
return
fi
printf '无法从 GitHub Releases 读取最新版本。\n可设置 HIDECK_VERSION=v2.1.1 后重试。\n' >&2
exit 1
}
resolve_version() {
requested=$(normalize_version "${HIDECK_VERSION:-latest}")
if [ "$requested" != "latest" ]; then
printf '%s\n' "$requested"
return
fi
resolve_latest_version
}
download_file() {
source_url=$1
target_file=$2
file_mode=$3
require_command curl
temporary_file=$(mktemp "${target_file}.tmp.XXXXXX")
if ! curl_github "$source_url" -o "$temporary_file"; then
rm -f "$temporary_file"
printf '下载失败:%s\n' "$source_url" >&2
exit 1
fi
chmod "$file_mode" "$temporary_file"
mv "$temporary_file" "$target_file"
}
try_download_file() {
source_url=$1
target_file=$2
file_mode=$3
temporary_file=$(mktemp "${target_file}.tmp.XXXXXX")
if curl_github "$source_url" -o "$temporary_file"; then
chmod "$file_mode" "$temporary_file"
mv "$temporary_file" "$target_file"
return 0
fi
rm -f "$temporary_file"
return 1
}
download_if_missing() {
target_file=$1
source_url=$2
file_mode=$3
if [ -f "$target_file" ]; then
printf '保留现有文件:%s\n' "$target_file"
return
fi
download_file "$source_url" "$target_file" "$file_mode"
printf '已下载:%s\n' "$target_file"
}
file_sha256() {
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$1" | awk '{print $1}'
return
fi
if command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$1" | awk '{print $1}'
return
fi
printf '缺少 sha256sum 或 shasum,无法校验下载文件。\n' >&2
exit 1
}
checksum_for_asset() {
sums_file=$1
asset_name=$2
awk -v name="$asset_name" '
NF >= 2 {
n = $NF
sub(/^.*\//, "", n)
if (n == name) {
print $1
exit
}
}
' "$sums_file"
}
verify_checksum() {
sums_file=$1
sidecar_file=$2
asset_name=$3
binary_file=$4
actual=$(file_sha256 "$binary_file")
expected=""
source_name=""
if [ -f "$sidecar_file" ]; then
expected=$(checksum_for_asset "$sidecar_file" "$asset_name")
source_name="${asset_name}.sha256"
fi
if [ -z "$expected" ] && [ -f "$sums_file" ]; then
expected=$(checksum_for_asset "$sums_file" "$asset_name")
source_name="SHA256SUMS"
fi
if [ -z "$expected" ]; then
printf '找不到 %s 的校验文件(SHA256SUMS 或 %s.sha256)。\n' "$asset_name" "$asset_name" >&2
exit 1
fi
if [ "$expected" != "$actual" ]; then
printf '校验失败:%s\n来源 %s\n期望 %s\n实际 %s\n文件可能还在上传,或校验清单和二进制不是同一批。请稍后重试,或设置 HIDECK_VERSION 指定版本。\n' \
"$asset_name" "$source_name" "$expected" "$actual" >&2
exit 1
fi
printf '校验通过:%s(%s)\n' "$asset_name" "$source_name"
}
write_procd_init() {
init_file=$1
binary_path=$2
config_file=$3
working_dir=$4
temporary_file=$(mktemp "${init_file}.tmp.XXXXXX")
cat >"$temporary_file" <<EOF
#!/bin/sh /etc/rc.common
START=99
STOP=10
USE_PROCD=1
PROG=${binary_path}
CONFIG=${config_file}
WORKDIR=${working_dir}
start_service() {
mkdir -p "\$WORKDIR/data" "\$WORKDIR/logs"
procd_open_instance
procd_set_param command "\$PROG" -c "\$CONFIG"
procd_set_param respawn 3600 5 5
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param file "\$CONFIG"
procd_set_param limits core="0"
procd_set_param env HOME="\$WORKDIR"
procd_set_param cwd "\$WORKDIR"
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger hideck
}
EOF
chmod 755 "$temporary_file"
mv "$temporary_file" "$init_file"
}
install_openwrt_service() {
init_source=$1
if maybe_sudo install -m 755 "$init_source" /etc/init.d/hideck; then
maybe_sudo /etc/init.d/hideck enable || true
maybe_sudo /etc/init.d/hideck start || true
printf '已安装并启动 procd 服务:/etc/init.d/hideck\n'
return
fi
printf '没有写入 /etc/init.d 的权限。初始化脚本已生成:%s\n可用下面命令安装:\n sudo cp %s /etc/init.d/hideck\n sudo /etc/init.d/hideck enable\n sudo /etc/init.d/hideck start\n或前台运行:\n %s -c %s\n' \
"$init_source" "$init_source" "$BINARY_PATH" "$CONFIG_FILE"
}
install_openwrt_packages() {
if command -v opkg >/dev/null 2>&1; then
maybe_sudo opkg update || return 1
openwrt_installer="maybe_sudo opkg install"
elif command -v apk >/dev/null 2>&1; then
maybe_sudo apk update || return 1
openwrt_installer="maybe_sudo apk add"
else
printf 'OpenWrt 缺少 opkg/apk,无法安装运行依赖。\n' >&2
return 1
fi
openwrt_dependencies_failed=0
install_packages "$openwrt_installer" \
libqmi kmod-usb-net-qmi-wwan kmod-usb-serial-option \
lame-lib libopencore-amrnb libopencore-amrwb libvo-amrwbenc || openwrt_dependencies_failed=1
if modem_voice_requested; then
printf 'OpenWrt 模组直拨需要配套 hideck-adb 安装包;官方旧版 adb 不会替代它。\n'
install_packages "$openwrt_installer" hideck-adb alsa-utils kmod-usb-audio || openwrt_dependencies_failed=1
fi
return "$openwrt_dependencies_failed"
}
write_systemd_unit() {
unit_file=$1
working_dir=$2
binary_path=$3
config_file=$4
temporary_file=$(mktemp "${unit_file}.tmp.XXXXXX")
cat >"$temporary_file" <<EOF
[Unit]
Description=HiDeck modem management service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
WorkingDirectory=${working_dir}
ExecStart=${binary_path} -c ${config_file}
Restart=on-failure
RestartSec=5s
KillMode=control-group
TimeoutStopSec=30s
[Install]
WantedBy=multi-user.target
EOF
chmod 644 "$temporary_file"
mv "$temporary_file" "$unit_file"
}
maybe_sudo() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
return
fi
if command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then
sudo "$@"
return
fi
return 1
}
install_systemd_service() {
unit_source=$1
if ! command -v systemctl >/dev/null 2>&1; then
printf '未检测到 systemd。可手动运行:\n %s -c %s\n' "$BINARY_PATH" "$CONFIG_FILE"
return
fi
if maybe_sudo install -m 644 "$unit_source" /etc/systemd/system/hideck.service; then
maybe_sudo systemctl daemon-reload
maybe_sudo systemctl enable --now hideck.service
maybe_sudo systemctl --no-pager --full status hideck.service || true
printf '已安装并启动 systemd 服务:hideck.service\n'
return
fi
printf '没有 systemd 写入权限。单元文件已生成:%s\n可用下面命令安装:\n sudo cp %s /etc/systemd/system/hideck.service\n sudo systemctl daemon-reload\n sudo systemctl enable --now hideck.service\n或前台运行:\n %s -c %s\n' \
"$unit_source" "$unit_source" "$BINARY_PATH" "$CONFIG_FILE"
}
install_runtime_dependencies() {
printf '正在安装所选运行依赖…\n'
dependencies_failed=0
if ! install_runtime_dependencies_with_pkg; then
printf '运行依赖未装全,请处理上面的包管理器错误。\n' >&2
dependencies_failed=1
fi
if modem_voice_requested; then
if ! check_modem_voice_tools; then dependencies_failed=1; fi
if ! check_usb_audio_support; then dependencies_failed=1; fi
else
printf '未选择模组直拨依赖;OpenWrt 可另装 hideck-modem-voice 配套包。\n'
fi
if [ "$dependencies_failed" -eq 0 ]; then
printf '所选运行依赖检查通过;未执行真实通话测试。\n'
fi
return "$dependencies_failed"
}
modem_voice_requested() {
case "${HIDECK_MODEM_VOICE:-auto}" in
1) return 0 ;;
0) return 1 ;;
auto) ! is_openwrt ;;
esac
}
resolve_modem_voice_adb() {
voice_adb=/usr/libexec/hideck/adb
if [ -e "$voice_adb" ] || [ -L "$voice_adb" ]; then
if [ ! -x "$voice_adb" ]; then
printf 'HiDeck 专用 ADB 不可执行:%s\n' "$voice_adb" >&2
return 1
fi
return 0
fi
voice_adb=adb
command -v "$voice_adb" >/dev/null 2>&1 || {
printf '缺少 adb;OpenWrt 请先安装配套 hideck-adb 包。\n' >&2
return 1
}
}
check_modem_voice_tools() {
resolve_modem_voice_adb || return 1
for voice_tool in arecord aplay; do
if ! command -v "$voice_tool" >/dev/null 2>&1; then
printf '缺少 %s,模组直拨不可用。请安装 ADB 和 alsa-utils。\n' "$voice_tool" >&2
return 1
fi
done
# Help/version commands never start an ADB server or open a PCM device.
if ! adb_help=$("$voice_adb" help 2>&1); then
printf '无法执行 adb help:%s\n' "$adb_help" >&2
return 1
fi
if ! printf '%s\n' "$adb_help" | grep -Eq '^[[:space:]]*-t[[:space:]]'; then
printf 'ADB 不支持 transport-id(-t);请升级 ADB,旧版 OpenWrt adb 不能用于模组直拨。\n' >&2
return 1
fi
if ! printf '%s\n' "$adb_help" | grep -Eq '^[[:space:]]*-L[[:space:]]'; then
printf 'ADB 不支持独立 server socket(-L);请升级 ADB 后再使用模组直拨。\n' >&2
return 1
fi
"$voice_adb" version && arecord --version && aplay --version
}
check_usb_audio_support() {
# A disconnected modem has no /dev/snd nodes. Check the driver, not devices.
if [ -d /sys/bus/usb/drivers/snd-usb-audio ]; then
return 0
fi
if command -v modinfo >/dev/null 2>&1 && modinfo snd_usb_audio >/dev/null 2>&1; then
return 0
fi
printf '无法确认宿主机支持 snd_usb_audio。请安装与运行内核匹配的 USB 音频驱动(OpenWrt:kmod-usb-audio);无需重启模组。\n' >&2
return 1
}
install_packages() {
installer=$1
shift
failed=0
for package in "$@"; do
if ! $installer "$package"; then
printf '未安装:%s\n' "$package"
failed=1
fi
done
return "$failed"
}
install_runtime_dependencies_with_pkg() {
# OpenWrt also uses apk; its package names are not Alpine package names.
if is_openwrt; then
install_openwrt_packages
return $?
fi
for package_manager in apt-get dnf yum apk pacman; do
command -v "$package_manager" >/dev/null 2>&1 || continue
adb_package=android-tools
recording_packages='lame-libs opencore-amr vo-amrwbenc'
case "$package_manager" in
apt-get)
maybe_sudo apt-get update -y || return 1
package_operation='install -y'
adb_package=adb
recording_packages='libmp3lame0 libopencore-amrnb0 libopencore-amrwb0 libvo-amrwbenc0'
;;
dnf|yum) package_operation='install -y' ;;
apk)
package_operation='add --no-cache'
adb_package=android-tools-adb
;;
pacman)
package_operation='-S --needed --noconfirm'
recording_packages='lame opencore-amr vo-amrwbenc'
;;
esac
voice_packages=
if modem_voice_requested; then voice_packages="$adb_package alsa-utils kmod"; fi
# These word lists contain only the fixed package names defined above.
install_packages "maybe_sudo $package_manager $package_operation" $voice_packages $recording_packages
return $?
done
printf '未识别的包管理器,请自行安装 ADB、alsa-utils、USB 音频驱动及 AMR/MP3 库。\n' >&2
return 1
}
detect_os
case "${HIDECK_MODEM_VOICE:-auto}" in
auto|0|1) ;;
*) printf 'HIDECK_MODEM_VOICE 必须为 auto、0 或 1。\n' >&2; exit 1 ;;
esac
require_command curl
require_command uname
ARCH=$(detect_arch)
VERSION=$(resolve_version)
ASSET_NAME="hideck_${VERSION}_${ARCH}"
if is_openwrt && [ -z "${HIDECK_DIR:-}" ]; then
PROJECT_DIR=/var/lib/hideck
CONFIG_DIR=/etc/hideck
CONFIG_FILE="$CONFIG_DIR/config.yaml"
CONFIG_EXAMPLE="$CONFIG_DIR/config.example.yaml"
BINARY_PATH=/usr/bin/hideck
else
PROJECT_DIR=$(resolve_project_dir)
fi
mkdir -p "$PROJECT_DIR"
PROJECT_DIR=$(CDPATH= cd -- "$PROJECT_DIR" && pwd)
if [ -z "${CONFIG_DIR:-}" ]; then
CONFIG_DIR="$PROJECT_DIR/config"
CONFIG_FILE="$CONFIG_DIR/config.yaml"
CONFIG_EXAMPLE="$CONFIG_DIR/config.example.yaml"
BINARY_PATH="$PROJECT_DIR/hideck"
fi
UNIT_FILE="$PROJECT_DIR/hideck.service"
INIT_FILE="$PROJECT_DIR/hideck.init"
ASSET_URL="${RELEASES_DOWNLOAD_URL}/${VERSION}/${ASSET_NAME}"
SUMS_URL="${RELEASES_DOWNLOAD_URL}/${VERSION}/SHA256SUMS"
SIDECAR_URL="${RELEASES_DOWNLOAD_URL}/${VERSION}/${ASSET_NAME}.sha256"
printf '部署目录:%s\n版本:%s\n架构:%s\n' "$PROJECT_DIR" "$VERSION" "$ARCH"
mkdir -p "$PROJECT_DIR/data" "$PROJECT_DIR/logs" 2>/dev/null || maybe_sudo mkdir -p "$PROJECT_DIR/data" "$PROJECT_DIR/logs"
mkdir -p "$CONFIG_DIR" 2>/dev/null || maybe_sudo mkdir -p "$CONFIG_DIR"
if is_openwrt; then
EXAMPLE_URL="$SOURCE_BASE_URL/packaging/openwrt/hideck/files/config.yaml"
else
EXAMPLE_URL="$SOURCE_BASE_URL/config/config.example.yaml"
fi
download_if_missing "$CONFIG_EXAMPLE" "$EXAMPLE_URL" 644
if [ -f "$CONFIG_FILE" ]; then
printf '保留现有配置:%s\n' "$CONFIG_FILE"
else
if [ ! -f "$CONFIG_EXAMPLE" ]; then
printf '缺少配置模板:%s\n' "$CONFIG_EXAMPLE" >&2
exit 1
fi
temporary_file=$(mktemp "$CONFIG_DIR/config.yaml.tmp.XXXXXX")
cp "$CONFIG_EXAMPLE" "$temporary_file"
chmod 600 "$temporary_file"
if ! mv "$temporary_file" "$CONFIG_FILE" 2>/dev/null; then
maybe_sudo mv "$temporary_file" "$CONFIG_FILE"
fi
printf '已创建配置:%s\n' "$CONFIG_FILE"
fi
DOWNLOAD_DIR=$(mktemp -d "${TMPDIR:-/tmp}/hideck-binary.XXXXXX")
trap 'rm -rf "$DOWNLOAD_DIR"' EXIT
download_file "$ASSET_URL" "$DOWNLOAD_DIR/$ASSET_NAME" 755
if ! try_download_file "$SIDECAR_URL" "$DOWNLOAD_DIR/${ASSET_NAME}.sha256" 644; then
printf '未找到 %s.sha256,改用 SHA256SUMS。\n' "$ASSET_NAME"
fi
if ! try_download_file "$SUMS_URL" "$DOWNLOAD_DIR/SHA256SUMS" 644; then
printf '未找到 SHA256SUMS。\n'
fi
verify_checksum "$DOWNLOAD_DIR/SHA256SUMS" "$DOWNLOAD_DIR/${ASSET_NAME}.sha256" "$ASSET_NAME" "$DOWNLOAD_DIR/$ASSET_NAME"
if ! install -m 755 "$DOWNLOAD_DIR/$ASSET_NAME" "$BINARY_PATH" 2>/dev/null; then
maybe_sudo install -m 755 "$DOWNLOAD_DIR/$ASSET_NAME" "$BINARY_PATH"
fi
printf '已安装二进制:%s\n' "$BINARY_PATH"
dependency_status=0
if ! install_runtime_dependencies; then
dependency_status=1
printf '依赖检查未通过,继续安装 HiDeck 服务;这不表示模组直拨或录音已可用。\n' >&2
fi
if is_openwrt; then
write_procd_init "$INIT_FILE" "$BINARY_PATH" "$CONFIG_FILE" "$PROJECT_DIR"
install_openwrt_service "$INIT_FILE"
else
write_systemd_unit "$UNIT_FILE" "$PROJECT_DIR" "$BINARY_PATH" "$CONFIG_FILE"
install_systemd_service "$UNIT_FILE"
fi
printf '\n浏览器打开:http://YOUR_IP:7575\n默认账号:admin / admin,首次登录后请立即改密。\n'
if [ "$dependency_status" -ne 0 ]; then
printf '部署存在未解决的运行依赖问题,请按上述错误补齐后重新检查。\n' >&2
fi
exit "$dependency_status"