summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshizhendong <[email protected]>2024-01-17 17:09:40 +0800
committershizhendong <[email protected]>2024-01-17 17:09:40 +0800
commit19f6b73d236ac2f96afd69251128915de05c0eb4 (patch)
tree170a518065cb3b5cf37d421c04b175c32ef70f61
parent3d0ed28a6d0445bb0642404ee484f4fbf1722633 (diff)
chore: nezha.properties 配置文件历史配置兼容调整
-rw-r--r--tools/afterinstall.sh32
1 files changed, 31 insertions, 1 deletions
diff --git a/tools/afterinstall.sh b/tools/afterinstall.sh
index c7506b6..14cc312 100644
--- a/tools/afterinstall.sh
+++ b/tools/afterinstall.sh
@@ -79,7 +79,37 @@ if [ 2 -eq $1 ];then
echo 'return config file '${i}
cp -f $TMP_PATH/config/$i $WEB_PATH/config/$i
fi
- done
+ done
+
+ # nz 配置文件格式变更
+ # database.host 和 database.port 如果存在,拼接后赋值给 database.url
+ # 删除 database.host,database.port,redis.*
+ web_config_file=$WEB_PATH/config/nezha.properties
+ while IFS='=' read -r key value; do
+ key="${key// /}"
+ value="${value// /}"
+
+ case "$key" in
+ database.host)
+ database_host="$value"
+ ;;
+ database.port)
+ database_port="$value"
+ ;;
+ *)
+ esac
+ done < "$web_config_file"
+
+ if [[ -n $database_host ]] && [[ -n $database_port ]]; then
+ database_url="${database_host}:${database_port}"
+ sed -i '/^database\.\(host\|port\)=/d' "$web_config_file"
+ echo "database.url=$database_url" >> "$web_config_file"
+
+ echo "nezha.properties add properties. key='database.url' value=$database_url"
+ fi
+
+ # 删除 redis 配置项
+ sed -i '/^redis\./d' "$web_config_file"
fi
systemctl daemon-reload