21 lines
482 B
Bash
21 lines
482 B
Bash
#!/bin/bash
|
|
|
|
# 更新密码的函数
|
|
update_password() {
|
|
local script_dir="$(dirname "$(realpath "$0")")"
|
|
local config_file="$script_dir/../config/config.json"
|
|
|
|
# 加载工具脚本
|
|
source "$script_dir/utils/base.sh"
|
|
|
|
# 生成一个长度为16的随机密码
|
|
local new_password=$(gen_password 16)
|
|
|
|
# 修改密码
|
|
sed -i 's/你的密码/'"$new_password"'/g' $config_file
|
|
|
|
echo "设置密码成功"
|
|
}
|
|
|
|
# 调用函数
|
|
update_password |