2019-12-01 02:07:05 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2019-12-01 05:46:54 +00:00
|
|
|
"github.com/pterodactyl/wings/parser"
|
2019-12-01 02:07:05 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Parent function that will update all of the defined configuration files for a server
|
|
|
|
// automatically to ensure that they always use the specified values.
|
|
|
|
func (s *Server) UpdateConfigurationFiles() {
|
|
|
|
wg := new(sync.WaitGroup)
|
|
|
|
|
|
|
|
for _, v := range s.processConfiguration.ConfigurationFiles {
|
|
|
|
wg.Add(1)
|
|
|
|
|
2019-12-01 05:46:54 +00:00
|
|
|
go func(f parser.ConfigurationFile, server *Server) {
|
2019-12-01 02:07:05 +00:00
|
|
|
defer wg.Done()
|
|
|
|
|
2019-12-01 05:46:54 +00:00
|
|
|
p, err := s.Filesystem.SafePath(f.FileName)
|
2019-12-01 02:07:05 +00:00
|
|
|
if err != nil {
|
|
|
|
zap.S().Errorw("failed to generate safe path for configuration file", zap.String("server", server.Uuid), zap.Error(err))
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-12-08 00:48:26 +00:00
|
|
|
if err := f.Parse(p, false); err != nil {
|
2019-12-01 02:07:05 +00:00
|
|
|
zap.S().Errorw("failed to parse and update server configuration file", zap.String("server", server.Uuid), zap.Error(err))
|
|
|
|
}
|
2019-12-01 05:46:54 +00:00
|
|
|
}(v, s)
|
2019-12-01 02:07:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wg.Wait()
|
|
|
|
}
|