mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-16 04:24:57 +08:00
b59ccc52ae
增加 Supervisor 状态读取 初始化 启动 重启 设置 日志 功能 Refs https://github.com/1Panel-dev/1Panel/issues/1754 Refs https://github.com/1Panel-dev/1Panel/issues/1409 Refs https://github.com/1Panel-dev/1Panel/issues/1388 Refs https://github.com/1Panel-dev/1Panel/issues/379 Refs https://github.com/1Panel-dev/1Panel/issues/353 Refs https://github.com/1Panel-dev/1Panel/issues/331
36 lines
681 B
Go
36 lines
681 B
Go
package ini_conf
|
|
|
|
import "gopkg.in/ini.v1"
|
|
|
|
func GetIniValue(filePath, Group, Key string) (string, error) {
|
|
cfg, err := ini.Load(filePath)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
service, err := cfg.GetSection(Group)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
startKey, err := service.GetKey(Key)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return startKey.Value(), nil
|
|
}
|
|
|
|
func SetIniValue(filePath, Group, Key, value string) error {
|
|
cfg, err := ini.Load(filePath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
service, err := cfg.GetSection(Group)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
targetKey := service.Key(Key)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
targetKey.SetValue(value)
|
|
return cfg.SaveTo(filePath)
|
|
}
|