Don't run install scripts if disabled; closes pterodactyl/panel#2265
This commit is contained in:
parent
9780cf902d
commit
c69a0bb107
|
@ -26,14 +26,11 @@ func New(data []byte) (*Installer, error) {
|
||||||
return nil, NewValidationError("uuid provided was not in a valid format")
|
return nil, NewValidationError("uuid provided was not in a valid format")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !govalidator.IsUUIDv4(getString(data, "service", "egg")) {
|
|
||||||
return nil, NewValidationError("service egg provided was not in a valid format")
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg := &server.Configuration{
|
cfg := &server.Configuration{
|
||||||
Uuid: getString(data, "uuid"),
|
Uuid: getString(data, "uuid"),
|
||||||
Suspended: false,
|
Suspended: false,
|
||||||
Invocation: getString(data, "invocation"),
|
Invocation: getString(data, "invocation"),
|
||||||
|
SkipEggScripts: getBoolean(data, "skip_egg_scripts"),
|
||||||
Build: environment.Limits{
|
Build: environment.Limits{
|
||||||
MemoryLimit: getInt(data, "build", "memory"),
|
MemoryLimit: getInt(data, "build", "memory"),
|
||||||
Swap: getInt(data, "build", "swap"),
|
Swap: getInt(data, "build", "swap"),
|
||||||
|
@ -117,7 +114,6 @@ func (i *Installer) Execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
l.Debug("creating required environment for server instance")
|
l.Debug("creating required environment for server instance")
|
||||||
// TODO: ensure data directory exists.
|
|
||||||
if err := i.server.Environment.Create(); err != nil {
|
if err := i.server.Environment.Create(); err != nil {
|
||||||
l.WithField("error", err).Error("failed to create environment for server")
|
l.WithField("error", err).Error("failed to create environment for server")
|
||||||
return
|
return
|
||||||
|
@ -139,3 +135,9 @@ func getInt(data []byte, key ...string) int64 {
|
||||||
|
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getBoolean(data []byte, key ...string) bool {
|
||||||
|
value, _ := jsonparser.GetBoolean(data, key...)
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,10 @@ type Configuration struct {
|
||||||
// The command that should be used when booting up the server instance.
|
// The command that should be used when booting up the server instance.
|
||||||
Invocation string `json:"invocation"`
|
Invocation string `json:"invocation"`
|
||||||
|
|
||||||
|
// By default this is false, however if selected within the Panel while installing or re-installing a
|
||||||
|
// server, specific installation scripts will be skipped for the server process.
|
||||||
|
SkipEggScripts bool `default:"false" json:"skip_egg_scripts"`
|
||||||
|
|
||||||
// An array of environment variables that should be passed along to the running
|
// An array of environment variables that should be passed along to the running
|
||||||
// server process.
|
// server process.
|
||||||
EnvVars environment.Variables `json:"environment"`
|
EnvVars environment.Variables `json:"environment"`
|
||||||
|
|
|
@ -35,10 +35,17 @@ func (s *Server) Install(sync bool) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the start event so the Panel can automatically update.
|
var err error
|
||||||
s.Events().Publish(InstallStartedEvent, "")
|
if !s.Config().SkipEggScripts {
|
||||||
|
// Send the start event so the Panel can automatically update. We don't send this unless the process
|
||||||
|
// is actually going to run, otherwise all sorts of weird rapid UI behavior happens since there isn't
|
||||||
|
// an actual install process being executed.
|
||||||
|
s.Events().Publish(InstallStartedEvent, "")
|
||||||
|
|
||||||
err := s.internalInstall()
|
err = s.internalInstall()
|
||||||
|
} else {
|
||||||
|
s.Log().Info("server configured to skip running installation scripts for this egg, not executing process")
|
||||||
|
}
|
||||||
|
|
||||||
s.Log().Debug("notifying panel of server install state")
|
s.Log().Debug("notifying panel of server install state")
|
||||||
if serr := s.SyncInstallState(err == nil); serr != nil {
|
if serr := s.SyncInstallState(err == nil); serr != nil {
|
||||||
|
|
|
@ -80,6 +80,14 @@ func (s *Server) UpdateDataStructure(data []byte) error {
|
||||||
c.Suspended = v
|
c.Suspended = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v, err := jsonparser.GetBoolean(data, "skip_egg_scripts"); err != nil {
|
||||||
|
if err != jsonparser.KeyPathNotFoundError {
|
||||||
|
return errors.WithStack(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
c.SkipEggScripts = v
|
||||||
|
}
|
||||||
|
|
||||||
// Environment and Mappings should be treated as a full update at all times, never a
|
// Environment and Mappings should be treated as a full update at all times, never a
|
||||||
// true patch, otherwise we can't know what we're passing along.
|
// true patch, otherwise we can't know what we're passing along.
|
||||||
if src.EnvVars != nil && len(src.EnvVars) > 0 {
|
if src.EnvVars != nil && len(src.EnvVars) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user