31 lines
762 B
Go
31 lines
762 B
Go
package server
|
|
|
|
import (
|
|
"emperror.dev/errors"
|
|
"github.com/pterodactyl/wings/server/filesystem"
|
|
"os"
|
|
)
|
|
|
|
func (s *Server) Filesystem() *filesystem.Filesystem {
|
|
return s.fs
|
|
}
|
|
|
|
// Ensures that the data directory for the server instance exists.
|
|
func (s *Server) EnsureDataDirectoryExists() error {
|
|
if _, err := os.Stat(s.fs.Path()); err != nil && !os.IsNotExist(err) {
|
|
return errors.WithStackIf(err)
|
|
} else if err != nil {
|
|
// Create the server data directory because it does not currently exist
|
|
// on the system.
|
|
if err := os.MkdirAll(s.fs.Path(), 0700); err != nil {
|
|
return errors.WithStackIf(err)
|
|
}
|
|
|
|
if err := s.fs.Chown("/"); err != nil {
|
|
s.Log().WithField("error", err).Warn("failed to chown server data directory")
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|