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:
18
install.sh
18
install.sh
@@ -23,6 +23,15 @@ CONFIG_DIR="/etc/funmc"
|
|||||||
DATA_DIR="/var/lib/funmc"
|
DATA_DIR="/var/lib/funmc"
|
||||||
LOG_DIR="/var/log/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 -e "${CYAN}"
|
||||||
echo "╔═══════════════════════════════════════════════════════════╗"
|
echo "╔═══════════════════════════════════════════════════════════╗"
|
||||||
echo "║ ║"
|
echo "║ ║"
|
||||||
@@ -46,15 +55,6 @@ if [ "$EUID" -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 解析参数:-force 或 --force 为强制覆盖安装,否则为更新(不覆盖数据)
|
|
||||||
FORCE_INSTALL=0
|
|
||||||
for arg in "$@"; do
|
|
||||||
if [ "$arg" = "-force" ] || [ "$arg" = "--force" ]; then
|
|
||||||
FORCE_INSTALL=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# 检测系统
|
# 检测系统
|
||||||
detect_os() {
|
detect_os() {
|
||||||
if [ -f /etc/os-release ]; then
|
if [ -f /etc/os-release ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user