update update_password.sh
This commit is contained in:
parent
a84ff6292a
commit
3cdbad243f
@ -1,12 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# 当前脚本所在目录的绝对路径
|
|
||||||
script_dir="$(dirname "$(realpath "$0")")"
|
|
||||||
|
|
||||||
# 加载jq_util.sh脚本
|
|
||||||
source $script_dir/utils/jq_util.sh
|
|
||||||
source $script_dir/utils/base.sh
|
|
||||||
|
|
||||||
# 函数生成随机密码
|
# 函数生成随机密码
|
||||||
gen_random_pass() {
|
gen_random_pass() {
|
||||||
local pass_length=$1 # 密码长度作为第一个参数
|
local pass_length=$1 # 密码长度作为第一个参数
|
||||||
@ -18,17 +11,27 @@ gen_random_pass() {
|
|||||||
echo "$rand"
|
echo "$rand"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 检查jq是否安装
|
# 更新密码的函数
|
||||||
check_jq
|
update_password() {
|
||||||
|
local script_dir="$(dirname "$(realpath "$0")")"
|
||||||
|
local config_file="$script_dir/../config.json"
|
||||||
|
|
||||||
# 生成一个长度为16的随机密码
|
# 加载工具脚本
|
||||||
new_password=$(gen_random_pass 16)
|
source "$script_dir/utils/jq_util.sh"
|
||||||
|
source "$script_dir/utils/base.sh"
|
||||||
|
|
||||||
# 更新config.json文件中的auth.password字段
|
# 检查jq是否安装
|
||||||
config_file="$script_dir/../config.json"
|
check_jq
|
||||||
|
|
||||||
# 使用jq_util.sh中的modify_json_file函数修改config.json文件中的auth.password字段
|
# 生成一个长度为16的随机密码
|
||||||
modify_json_file "$config_file" 'auth.password' "$new_password"
|
local new_password=$(gen_random_pass 16)
|
||||||
|
|
||||||
echo "New password: $new_password"
|
# 使用jq_util.sh中的modify_json_file函数修改config.json文件中的auth.password字段
|
||||||
echo "config.json file updated with new password."
|
modify_json_file "$config_file" 'auth.password' "$new_password"
|
||||||
|
|
||||||
|
echo "New password: $new_password"
|
||||||
|
echo "config.json file updated with new password."
|
||||||
|
}
|
||||||
|
|
||||||
|
# 调用函数
|
||||||
|
update_password
|
||||||
Loading…
Reference in New Issue
Block a user