Merge branch 'develop' into dane/backup-restore
This commit is contained in:
commit
981071cda8
47
Dockerfile
47
Dockerfile
|
@ -1,33 +1,22 @@
|
|||
# Stage 1 (Build)
|
||||
FROM golang:1.15-alpine3.12 AS builder
|
||||
FROM golang:1.15-alpine3.12 AS builder
|
||||
|
||||
ARG VERSION
|
||||
|
||||
RUN apk add --update --no-cache git=2.26.2-r0 make=4.3-r0 upx=3.96-r0
|
||||
|
||||
WORKDIR /app/
|
||||
|
||||
COPY go.mod go.sum /app/
|
||||
RUN go mod download
|
||||
|
||||
COPY . /app/
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags="-s -w -X github.com/pterodactyl/wings/system.Version=$VERSION" \
|
||||
-v \
|
||||
-trimpath \
|
||||
-o wings \
|
||||
wings.go
|
||||
|
||||
RUN upx wings
|
||||
|
||||
# --------------------------------------- #
|
||||
ARG VERSION
|
||||
RUN apk add --update --no-cache git=2.26.2-r0 make=4.3-r0 upx=3.96-r0
|
||||
WORKDIR /app/
|
||||
COPY go.mod go.sum /app/
|
||||
RUN go mod download
|
||||
COPY . /app/
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags="-s -w -X github.com/pterodactyl/wings/system.Version=$VERSION" \
|
||||
-v \
|
||||
-trimpath \
|
||||
-o wings \
|
||||
wings.go
|
||||
RUN upx wings
|
||||
|
||||
# Stage 2 (Final)
|
||||
FROM busybox:1.33.0
|
||||
|
||||
RUN echo "ID=\"busybox\"" > /etc/os-release
|
||||
|
||||
COPY --from=builder /app/wings /usr/bin/
|
||||
|
||||
CMD [ "wings", "--config", "/etc/pterodactyl/config.yml" ]
|
||||
FROM busybox:1.33.0
|
||||
RUN echo "ID=\"busybox\"" > /etc/os-release
|
||||
COPY --from=builder /app/wings /usr/bin/
|
||||
CMD [ "wings", "--config", "/etc/pterodactyl/config.yml" ]
|
||||
|
|
|
@ -164,6 +164,12 @@ func rootCmdRun(cmd *cobra.Command, _ []string) {
|
|||
for _, serv := range server.GetServers().All() {
|
||||
s := serv
|
||||
|
||||
// For each server we encounter make sure the root data directory exists.
|
||||
if err := s.EnsureDataDirectoryExists(); err != nil {
|
||||
s.Log().Error("could not create root data directory for server: not loading server...")
|
||||
continue
|
||||
}
|
||||
|
||||
pool.Submit(func() {
|
||||
s.Log().Info("configuring server environment and restoring to previous state")
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ services:
|
|||
- "/var/lib/pterodactyl/:/var/lib/pterodactyl/"
|
||||
- "/var/log/pterodactyl/:/var/log/pterodactyl/"
|
||||
- "/tmp/pterodactyl/:/tmp/pterodactyl/"
|
||||
- "/etc/ssl/certs:/etc/ssl/certs:ro"
|
||||
# you may need /srv/daemon-data if you are upgrading from an old daemon
|
||||
#- "/srv/daemon-data/:/srv/daemon-data/"
|
||||
# Required for ssl if you use let's encrypt. uncomment to use.
|
||||
|
|
|
@ -30,6 +30,7 @@ func getServerFileContents(c *gin.Context) {
|
|||
f, st, err := s.Filesystem().File(p)
|
||||
if err != nil {
|
||||
middleware.CaptureAndAbort(c, err)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
|
@ -48,6 +49,7 @@ func getServerFileContents(c *gin.Context) {
|
|||
// take since a panic will at least be recovered and this should be incredibly
|
||||
// rare?
|
||||
middleware.CaptureAndAbort(c, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/pterodactyl/wings/server/filesystem"
|
||||
)
|
||||
|
||||
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 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 err
|
||||
}
|
||||
|
||||
if err := s.fs.Chown("/"); err != nil {
|
||||
s.Log().WithField("error", err).Warn("failed to chown server data directory")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -447,6 +447,14 @@ func (ip *InstallationProcess) Execute() (string, error) {
|
|||
NetworkMode: container.NetworkMode(config.Get().Docker.Network.Mode),
|
||||
}
|
||||
|
||||
// Ensure the root directory for the server exists properly before attempting
|
||||
// to trigger the reinstall of the server. It is possible the directory would
|
||||
// not exist when this runs if Wings boots with a missing directory and a user
|
||||
// triggers a reinstall before trying to start the server.
|
||||
if err := ip.Server.EnsureDataDirectoryExists(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ip.Server.Log().WithField("install_script", ip.tempDir()+"/install.sh").Info("creating install container for server process")
|
||||
// Remove the temporary directory when the installation process finishes for this server container.
|
||||
defer func() {
|
||||
|
|
|
@ -3,6 +3,7 @@ package server
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
|
@ -221,3 +222,27 @@ func (s *Server) ProcessConfiguration() *api.ProcessConfiguration {
|
|||
|
||||
return s.procConfig
|
||||
}
|
||||
|
||||
// Filesystem returns an instance of the filesystem for this server.
|
||||
func (s *Server) Filesystem() *filesystem.Filesystem {
|
||||
return s.fs
|
||||
}
|
||||
|
||||
// EnsureDataDirectoryExists ensures that the data directory for the server
|
||||
// instance exists.
|
||||
func (s *Server) EnsureDataDirectoryExists() error {
|
||||
if _, err := os.Lstat(s.fs.Path()); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
s.Log().Debug("server: creating root directory and setting permissions")
|
||||
if err := os.MkdirAll(s.fs.Path(), 0700); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
if err := s.fs.Chown("/"); err != nil {
|
||||
s.Log().WithField("error", err).Warn("server: failed to chown server data directory")
|
||||
}
|
||||
} else {
|
||||
return errors.WrapIf(err, "server: failed to stat server root directory")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user