feat: 增加交互式变量.
This commit is contained in:
@@ -214,16 +214,36 @@ build(){
|
||||
|
||||
}
|
||||
|
||||
# =============================================================
|
||||
# 交互输入函数
|
||||
# 参数1: 提示信息
|
||||
# 参数2: 默认值
|
||||
# 返回: 用户输入值,直接回车返回默认值
|
||||
# =============================================================
|
||||
ask_input() {
|
||||
local prompt="$1"
|
||||
local default="$2"
|
||||
|
||||
read -p "${prompt} [默认: ${default}]: " value
|
||||
|
||||
if [ -z "$value" ]; then
|
||||
echo "$default"
|
||||
else
|
||||
echo "$value"
|
||||
fi
|
||||
}
|
||||
|
||||
# 项目根目录,用来保证从任意位置执行 main.sh 都能找到其他脚本
|
||||
project_dir="$(cd "$(dirname "$0")" && pwd)"
|
||||
cd "$project_dir"
|
||||
|
||||
# 要构建的 ImmortalWrt 版本, 可以在 https://github.com/immortalwrt/immortalwrt 查询版本号
|
||||
version="25.12.1"
|
||||
default_version="25.12.1"
|
||||
version=$(ask_input "请输入 ImmortalWrt 版本" "$default_version")
|
||||
|
||||
# 根分区大小(单位: MB)
|
||||
rootfs_partsize=600
|
||||
default_rootfs_partsize="600"
|
||||
rootfs_partsize=$(ask_input "请输入根分区大小(MB)" "$default_rootfs_partsize")
|
||||
|
||||
# 安装依赖
|
||||
install_dependencies
|
||||
|
||||
Reference in New Issue
Block a user