fix path
This commit is contained in:
parent
a18ae36dfb
commit
a6504842f2
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
"os"
|
"os"
|
||||||
@ -19,22 +20,23 @@ var wazuhData types.WazuhMessage
|
|||||||
var BasePath string
|
var BasePath string
|
||||||
|
|
||||||
func InitNotify() types.Params {
|
func InitNotify() types.Params {
|
||||||
BasePath, _ := os.Executable()
|
BaseFilePath, _ := os.Executable()
|
||||||
|
BaseDirPath := path.Dir(BaseFilePath)
|
||||||
|
|
||||||
|
log.OpenLogFile(BaseDirPath)
|
||||||
|
|
||||||
log.OpenLogFile(BasePath)
|
err := godotenv.Load(path.Join(BaseDirPath, "../../etc/.env"))
|
||||||
|
|
||||||
err := godotenv.Load(path.Join(BasePath, "../../etc/.env"))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log("env failed to load")
|
log.Log("env failed to load")
|
||||||
godotenv.Load(path.Join(BasePath, ".env"))
|
godotenv.Load(path.Join(BaseDirPath, ".env"))
|
||||||
} else {
|
} else {
|
||||||
log.Log("env loaded")
|
log.Log("env loaded")
|
||||||
}
|
}
|
||||||
|
|
||||||
yamlFile, err := os.ReadFile(path.Join(BasePath, "../../etc/wazuh-notify-config.yaml"))
|
yamlFile, err := os.ReadFile(path.Join(BaseDirPath, "../../etc/wazuh-notify-config.yaml"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Log("yaml failed to load")
|
log.Log("yaml failed to load")
|
||||||
yamlFile, err = os.ReadFile(path.Join(BasePath, "wazuh-notify-config.yaml"))
|
yamlFile, err = os.ReadFile(path.Join(BaseDirPath, "wazuh-notify-config.yaml"))
|
||||||
}
|
}
|
||||||
yaml.Unmarshal(yamlFile, &configParams)
|
yaml.Unmarshal(yamlFile, &configParams)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user