refactor: Simplify parameter parsing in install script

- Move the parameter parsing for force installation to a more logical position in the script, ensuring it executes before displaying the running mode.
- Remove redundant code related to force installation parameter parsing, improving script clarity and maintainability.
This commit is contained in:
2026-02-26 21:27:23 +08:00
parent 0f183b61a4
commit 0aa51cc932

View File

@@ -23,6 +23,15 @@ CONFIG_DIR="/etc/funmc"
DATA_DIR="/var/lib/funmc"
LOG_DIR="/var/log/funmc"
# 先解析参数(必须在显示运行模式前执行)
FORCE_INSTALL=0
for arg in "$@"; do
if [ "$arg" = "-force" ] || [ "$arg" = "--force" ]; then
FORCE_INSTALL=1
break
fi
done
echo -e "${CYAN}"
echo "╔═══════════════════════════════════════════════════════════╗"
echo "║ ║"
@@ -46,15 +55,6 @@ if [ "$EUID" -ne 0 ]; then
exit 1
fi
# 解析参数:-force 或 --force 为强制覆盖安装,否则为更新(不覆盖数据)
FORCE_INSTALL=0
for arg in "$@"; do
if [ "$arg" = "-force" ] || [ "$arg" = "--force" ]; then
FORCE_INSTALL=1
break
fi
done
# 检测系统
detect_os() {
if [ -f /etc/os-release ]; then