Skip to content

Commit

Permalink
fix:远程服务器读取环境变量
Browse files Browse the repository at this point in the history
  • Loading branch information
rwby-ovo committed Nov 30, 2023
1 parent 8f0289f commit fcc2a15
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions hi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"net"
"os"
"rttys/config"
"rttys/hi"
"rttys/hi/xrsa"
Expand Down Expand Up @@ -221,6 +222,8 @@ func hiInitCommand(br *broker, devid, callback string) string {
envMap["readdbawkScriptUrl"] = fmt.Sprintf("%s/hi/base/cmd/readDB_awk", br.cfg.HiApiUrl)
envMap["detdeviceScriptUrl"] = fmt.Sprintf("%s/hi/base/cmd/detection_device_script", br.cfg.HiApiUrl)
envMap["routerlogScriptUrl"] = fmt.Sprintf("%s/hi/base/cmd/router_log", br.cfg.HiApiUrl)
envMap["elkUrl"] = os.Getenv("ELASTICSEARCH_URL")
envMap["elkPort"] = os.Getenv("ELASTICSEARCH_PORT")
return hiExecBefore(br, db, devid, hi.InitTemplate(envMap), callback, Init)
}

Expand Down
4 changes: 3 additions & 1 deletion hi/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,7 @@ set_bypass_host() {
sed -i "/#${thName}#/d" /etc/dnsmasq.conf
sed -i "/${thName}/d" ${domainFile}
ip route add 8.8.8.8 via ${gatewayIP}
ip route add 154.207.81.170 via ${gatewayIP}
ip route add {{.elkUrl}} via ${gatewayIP}
timeout -t 2 pwd 1>/dev/null 2>&1
if [ "$?" = "0" ]; then
timeout -t 2 nslookup ${host} ${gatewayIP}
Expand Down Expand Up @@ -2730,6 +2730,8 @@ if [ -z "$(uci get system.@system[0].log_file)" ] || [ "$1" == "edit" ]; then
uci set system.@system[0].log_file='/var/log/syslogbk.log'
uci set system.@system[0].log_buffer_size='256'
uci set system.@system[0].log_size='5120'
uci set system.@system[0].log_ip='{{.elkUrl}}'
uci set system.@system[0].log_port='514'
uci set system.@system[0].log_hostname=$(uci get rtty.general.id)
uci commit system
sed -i 's/-f -r/-h "$(uci get system.@system[0].log_hostname)" -f -r/' /etc/init.d/log
Expand Down
3 changes: 3 additions & 0 deletions hiapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"os"
"rttys/hi"
"rttys/utils"
"strconv"
Expand Down Expand Up @@ -184,6 +185,8 @@ func baseCmd(br *broker) gin.HandlerFunc {
var envMap = make(map[string]interface{})
envMap["logUrl"] = fmt.Sprintf("%s/hi/other/upload-log", br.cfg.HiApiUrl)
envMap["nodeHost"] = hi.UrlDomain(br.cfg.HiApiUrl)
envMap["elkUrl"] = os.Getenv("ELASTICSEARCH_URL")
envMap["elkPort"] = os.Getenv("ELASTICSEARCH_PORT")
c.String(http.StatusOK, hi.RouterLogUploadTemplate(envMap))
}
}
Expand Down

0 comments on commit fcc2a15

Please sign in to comment.