Support a custom tmp directory location

This commit is contained in:
Dane Everitt 2022-02-13 11:59:53 -05:00
parent 225a89be72
commit f85509a0c7
2 changed files with 9 additions and 5 deletions

View File

@ -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"`

View File

@ -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