25 lines
649 B
Bash
25 lines
649 B
Bash
#!/bin/bash
|
|
|
|
# 更新密码的函数
|
|
update_password() {
|
|
local script_dir="$(dirname "$(realpath "$0")")"
|
|
local config_file="$script_dir/../config.json"
|
|
|
|
# 加载工具脚本
|
|
source "$script_dir/utils/jq_util.sh"
|
|
source "$script_dir/utils/base.sh"
|
|
|
|
# 检查jq是否安装
|
|
check_jq
|
|
|
|
# 生成一个长度为16的随机密码
|
|
local new_password=$(gen_password 16)
|
|
|
|
# 使用jq_util.sh中的modify_json_file函数修改config.json文件中的auth.password字段
|
|
modify_json_file "$config_file" 'auth.password' "$new_password"
|
|
|
|
echo "设置密码成功"
|
|
}
|
|
|
|
# 调用函数
|
|
update_password |