重构代码, 重构update_uuid函数

This commit is contained in:
Olia Lisa
2026-05-28 15:10:40 +08:00
parent c0824d99c0
commit f58c341a28
2 changed files with 10 additions and 5 deletions
+8 -3
View File
@@ -1,11 +1,16 @@
#!/bin/bash
update_uuid(){
local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径
local CONFIG_FILE="$SCRIPT_DIR/../config/config.json"
local CONFIG_FILE="${1}"
if [[ -z "$CONFIG_FILE" ]]; then
echo "[Error] config_file配置文件路径 不能为空"
return 1
fi
# 生成 UUID
local UUID=$(cat /proc/sys/kernel/random/uuid)
local UUID
UUID=$(cat /proc/sys/kernel/random/uuid)
# 修改 UUID
sed -i 's/你的UUID/'"$UUID"'/g' "$CONFIG_FILE"