mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2025-12-22 09:04:21 +01:00
only add numbers to jsonrpc2.yml config file; skip any other files
starting with a '+'
This commit is contained in:
@@ -43,9 +43,11 @@ func main() {
|
||||
err := filepath.Walk(*signalCliConfigDir, func(path string, info os.FileInfo, err error) error {
|
||||
filename := filepath.Base(path)
|
||||
if strings.HasPrefix(filename, "+") && info.Mode().IsRegular() {
|
||||
if utils.IsPhoneNumber(filename) {
|
||||
number := filename
|
||||
fifoPathname := fifoBasePathName + strconv.FormatInt(ctr, 10)
|
||||
tcpPort := tcpBasePort + ctr
|
||||
jsonRpc2ClientConfig.AddEntry(filename, utils.ConfigEntry{TcpPort: tcpPort, FifoPathname: fifoPathname})
|
||||
jsonRpc2ClientConfig.AddEntry(number, utils.ConfigEntry{TcpPort: tcpPort, FifoPathname: fifoPathname})
|
||||
ctr += 1
|
||||
_, err = exec.Command("mkfifo", fifoPathname).Output()
|
||||
if err != nil {
|
||||
@@ -64,14 +66,19 @@ func main() {
|
||||
log.Fatal("Couldn't create log folder ", supervisorctlLogFolder, ": ", err.Error())
|
||||
}
|
||||
|
||||
log.Info("Found number ", number, " and added it to jsonrpc2.yml")
|
||||
|
||||
//write supervisorctl config
|
||||
supervisorctlConfigFilename := "/etc/supervisor/conf.d/" + "signal-cli-json-rpc-" + strconv.FormatInt(ctr, 10) + ".conf"
|
||||
supervisorctlConfig := fmt.Sprintf(supervisorctlConfigTemplate, supervisorctlProgramName, supervisorctlProgramName,
|
||||
tcpPort, fifoPathname, filename, fifoPathname, supervisorctlProgramName, supervisorctlProgramName)
|
||||
tcpPort, fifoPathname, number, fifoPathname, supervisorctlProgramName, supervisorctlProgramName)
|
||||
err = ioutil.WriteFile(supervisorctlConfigFilename, []byte(supervisorctlConfig), 0644)
|
||||
if err != nil {
|
||||
log.Fatal("Couldn't write ", supervisorctlConfigFilename, ": ", err.Error())
|
||||
}
|
||||
} else {
|
||||
log.Error("Skipping ", filename, " as it is not a valid phone number!")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user