From f85509a0c779a8e4d3e990e9ce68dcb88b4e5d0e Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 13 Feb 2022 11:59:53 -0500 Subject: [PATCH] Support a custom tmp directory location --- config/config.go | 4 ++++ server/install.go | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index f6314db..e2737f7 100644 --- a/config/config.go +++ b/config/config.go @@ -132,6 +132,10 @@ type SystemConfiguration struct { // Directory where local backups will be stored on the machine. BackupDirectory string `default:"/var/lib/pterodactyl/backups" yaml:"backup_directory"` + // TmpDirectory specifies where temporary files for Pterodactyl installation processes + // should be created. This supports environments running docker-in-docker. + TmpDirectory string `default:"/tmp/pterodactyl" yaml:"tmp_directory"` + // The user that should own all of the server files, and be used for containers. Username string `default:"pterodactyl" yaml:"username"` diff --git a/server/install.go b/server/install.go index 46b2548..8716d2d 100644 --- a/server/install.go +++ b/server/install.go @@ -34,7 +34,7 @@ func (s *Server) Install(sync bool) error { if sync { s.Log().Info("syncing server state with remote source before executing installation process") if err := s.Sync(); err != nil { - return err + return errors.WrapIf(err, "install: failed to sync server state with Panel") } } @@ -58,7 +58,7 @@ func (s *Server) Install(sync bool) error { // error to this log entry. Otherwise ignore it in this log since whatever is calling // this function should handle the error and will end up logging the same one. if err == nil { - l.WithField("error", serr) + l.WithField("error", err) } l.Warn("failed to notify panel of server install state") @@ -72,7 +72,7 @@ func (s *Server) Install(sync bool) error { // the install is completed. s.Events().Publish(InstallCompletedEvent, "") - return err + return errors.WithStackIf(err) } // Reinstalls a server's software by utilizing the install script for the server egg. This @@ -81,7 +81,7 @@ func (s *Server) Reinstall() error { if s.Environment.State() != environment.ProcessOfflineState { s.Log().Debug("waiting for server instance to enter a stopped state") if err := s.Environment.WaitForStop(s.Context(), time.Second*10, true); err != nil { - return err + return errors.WrapIf(err, "install: failed to stop running environment") } } @@ -204,7 +204,7 @@ func (ip *InstallationProcess) Run() error { // Returns the location of the temporary data for the installation process. func (ip *InstallationProcess) tempDir() string { - return filepath.Join(os.TempDir(), "pterodactyl/", ip.Server.ID()) + return filepath.Join(config.Get().System.TmpDirectory, ip.Server.ID()) } // Writes the installation script to a temporary file on the host machine so that it