Created
August 13, 2021 04:36
-
-
Save PurpleIsEverything/54d4f3c47778dc4abacd13b33e26edc0 to your computer and use it in GitHub Desktop.
Very quick modification to allow for data format changing in the pterodactyl wings daemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/config/config.go b/config/config.go | |
index 2d46e85..ab1dd8f 100644 | |
--- a/config/config.go | |
+++ b/config/config.go | |
@@ -122,8 +122,14 @@ type SystemConfiguration struct { | |
// Directory where logs for server installations and other wings events are logged. | |
LogDirectory string `default:"/var/log/pterodactyl" yaml:"log_directory"` | |
- // Directory where the server data is stored at. | |
- Data string `default:"/var/lib/pterodactyl/volumes" yaml:"data"` | |
+ // Data folder format of where the server data is stored at. | |
+ Data string `default:"/var/lib/pterodactyl/volumes/%uuid%" yaml:"data"` | |
+ | |
+ // (Advanced) Data folder format of sever data used by SFTP. | |
+ SFTPData string `default:"/var/lib/pterodactyl/volumes/%uuid%" yaml:"sftp_data"` | |
+ | |
+ // (Advanced) Data folder format of server data used by install containers. | |
+ InstallData string `default:"/var/lib/pterodactyl/volumes/%uuid%" yaml:"install_data"` | |
// Directory where server archives for transferring will be stored. | |
ArchiveDirectory string `default:"/var/lib/pterodactyl/archives" yaml:"archive_directory"` | |
diff --git a/server/install.go b/server/install.go | |
index 1cd978b..017ff9a 100644 | |
--- a/server/install.go | |
+++ b/server/install.go | |
@@ -424,7 +424,7 @@ func (ip *InstallationProcess) Execute() (string, error) { | |
Mounts: []mount.Mount{ | |
{ | |
Target: "/mnt/server", | |
- Source: ip.Server.Filesystem().Path(), | |
+ Source: ip.Server.InstallFilesystem().Path(), | |
Type: mount.TypeBind, | |
ReadOnly: false, | |
}, | |
diff --git a/server/manager.go b/server/manager.go | |
index 2b5249b..7541341 100644 | |
--- a/server/manager.go | |
+++ b/server/manager.go | |
@@ -7,8 +7,8 @@ import ( | |
"io" | |
"io/ioutil" | |
"os" | |
- "path/filepath" | |
"runtime" | |
+ "strings" | |
"sync" | |
"time" | |
@@ -176,7 +176,9 @@ func (m *Manager) InitServer(data remote.ServerConfigurationResponse) (*Server, | |
return nil, err | |
} | |
- s.fs = filesystem.New(filepath.Join(config.Get().System.Data, s.ID()), s.DiskSpace(), s.Config().Egg.FileDenylist) | |
+ s.fs = filesystem.New(strings.ReplaceAll(config.Get().System.Data, "%uuid%", s.ID()), s.DiskSpace(), s.Config().Egg.FileDenylist) | |
+ s.sftpFs = filesystem.New(strings.ReplaceAll(config.Get().System.Data, "%uuid%", s.ID()), s.DiskSpace(), s.Config().Egg.FileDenylist) | |
+ s.installFs = filesystem.New(strings.ReplaceAll(config.Get().System.Data, "%uuid%", s.ID()), s.DiskSpace(), s.Config().Egg.FileDenylist) | |
// Right now we only support a Docker based environment, so I'm going to hard code | |
// this logic in. When we're ready to support other environment we'll need to make | |
diff --git a/server/server.go b/server/server.go | |
index 3526faa..ab1cef6 100644 | |
--- a/server/server.go | |
+++ b/server/server.go | |
@@ -46,7 +46,9 @@ type Server struct { | |
resources ResourceUsage | |
Environment environment.ProcessEnvironment `json:"-"` | |
- fs *filesystem.Filesystem | |
+ fs *filesystem.Filesystem | |
+ sftpFs *filesystem.Filesystem | |
+ installFs *filesystem.Filesystem | |
// Events emitted by the server instance. | |
emitter *events.EventBus | |
@@ -236,6 +238,16 @@ func (s *Server) Filesystem() *filesystem.Filesystem { | |
return s.fs | |
} | |
+// SFTPFilesystem returns an instance of the sftp filesystem for this server. | |
+func (s *Server) SFTPFilesystem() *filesystem.Filesystem { | |
+ return s.fs | |
+} | |
+ | |
+// InstallFilesystem returns an instance of the install filesystem for this server. | |
+func (s *Server) InstallFilesystem() *filesystem.Filesystem { | |
+ return s.fs | |
+} | |
+ | |
// EnsureDataDirectoryExists ensures that the data directory for the server | |
// instance exists. | |
func (s *Server) EnsureDataDirectoryExists() error { | |
diff --git a/sftp/handler.go b/sftp/handler.go | |
index 2f3f0b9..2fa5bbf 100644 | |
--- a/sftp/handler.go | |
+++ b/sftp/handler.go | |
@@ -42,7 +42,7 @@ func NewHandler(sc *ssh.ServerConn, srv *server.Server) *Handler { | |
return &Handler{ | |
permissions: strings.Split(sc.Permissions.Extensions["permissions"], ","), | |
server: srv, | |
- fs: srv.Filesystem(), | |
+ fs: srv.SFTPFilesystem(), | |
ro: config.Get().System.Sftp.ReadOnly, | |
logger: log.WithFields(log.Fields{ | |
"subsystem": "sftp", | |
diff --git a/sftp/server.go b/sftp/server.go | |
index a2d03f0..a176181 100644 | |
--- a/sftp/server.go | |
+++ b/sftp/server.go | |
@@ -42,7 +42,7 @@ func New(m *server.Manager) *SFTPServer { | |
cfg := config.Get().System | |
return &SFTPServer{ | |
manager: m, | |
- BasePath: cfg.Data, | |
+ BasePath: cfg.SFTPData, | |
ReadOnly: cfg.Sftp.ReadOnly, | |
Listen: cfg.Sftp.Address + ":" + strconv.Itoa(cfg.Sftp.Port), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment