From 7a24e976ef04abb513c63ec7e5bd1d301f8b9d07 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Sat, 17 Jul 2021 10:25:33 -0600 Subject: [PATCH] feat(logrotate): fix config with bad user fixes https://github.com/pterodactyl/panel/issues/3452 --- cmd/root.go | 9 ++++----- config/config.go | 6 ++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index bfd810e..da70e59 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -122,11 +122,6 @@ func rootCmdRun(cmd *cobra.Command, _ []string) { log.WithField("error", err).Fatal("failed to configure system directories for pterodactyl") return } - if err := config.EnableLogRotation(); err != nil { - log.WithField("error", err).Fatal("failed to configure log rotation on the system") - return - } - log.WithField("username", config.Get().System.User).Info("checking for pterodactyl system user") if err := config.EnsurePterodactylUser(); err != nil { log.WithField("error", err).Fatal("failed to create pterodactyl system user") @@ -136,6 +131,10 @@ func rootCmdRun(cmd *cobra.Command, _ []string) { "uid": config.Get().System.User.Uid, "gid": config.Get().System.User.Gid, }).Info("configured system user successfully") + if err := config.EnableLogRotation(); err != nil { + log.WithField("error", err).Fatal("failed to configure log rotation on the system") + return + } pclient := remote.New( config.Get().PanelLocation, diff --git a/config/config.go b/config/config.go index 9bc331c..99f375f 100644 --- a/config/config.go +++ b/config/config.go @@ -538,8 +538,7 @@ func EnableLogRotation() error { } defer f.Close() - t, err := template.New("logrotate").Parse(` -{{.LogDirectory}}/wings.log { + t, err := template.New("logrotate").Parse(`{{.LogDirectory}}/wings.log { size 10M compress delaycompress @@ -547,9 +546,8 @@ func EnableLogRotation() error { maxage 7 missingok notifempty - create 0640 {{.User.Uid}} {{.User.Gid}} postrotate - killall -SIGHUP wings + /usr/bin/systemctl kill -s HUP wings.service >/dev/null 2>&1 || true endscript }`) if err != nil {