fix: NEZ-2203 从 /opt/nezha/nz-web/config/nezha.properties 获取数据源信息
1. 升级之后对 nezha.properties database.pin 加密
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package net.geedge.handler;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.setting.dialect.Props;
|
||||
import net.geedge.dao.SqlDao;
|
||||
import net.geedge.util.AesUtil;
|
||||
import net.geedge.util.Constant;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -10,7 +13,9 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 此类用于数据同步完成后 清除无用表
|
||||
* 此类用于数据同步完成后
|
||||
* 1. 清除无用表
|
||||
* 2. 修改 nezha.properties 密码加密
|
||||
* @author admin
|
||||
*
|
||||
*/
|
||||
@@ -41,6 +46,20 @@ public class AfterHandler implements CommandLineRunner {
|
||||
}
|
||||
sqlDao.execute(sb.toString());
|
||||
log.info("remove table successful");
|
||||
|
||||
// nezha.properties database.pin
|
||||
// 21.07 -> 22.02 pin 加密
|
||||
String propsPath = "/opt/nezha/nz-web/config/nezha.properties";
|
||||
Props props = new Props(propsPath, "UTF-8");
|
||||
|
||||
String dbPin = props.getStr("database.pin");
|
||||
String encryptPin = AesUtil.encrypt(dbPin, Constant.AES_SECRET_KEY);
|
||||
props.put("database.pin", encryptPin);
|
||||
|
||||
// store
|
||||
props.store(propsPath);
|
||||
log.info("nezha.properties database.pin encrypt successful");
|
||||
|
||||
log.info("-----------------transfer data success-----------------------");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user