Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions init/systemd/unpackerr.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ After=network-online.target
ExecStart=/usr/bin/unpackerr $DAEMON_OPTS
EnvironmentFile=-/etc/default/unpackerr
EnvironmentFile=-/etc/sysconfig/unpackerr
Environment=UN_LOG_FILE=/var/log/unpackerr/unpackerr.log
Environment=UN_WEBSERVER_LOG_FILE=/var/log/unpackerr/http.log
Environment=UN_QUIET=true
Restart=always
RestartSec=10
SyslogIdentifier=unpackerr
Type=simple
WorkingDirectory=/tmp

# These should be set correctly for your environment.
# If you change User, fix ownership on /var/log/unpackerr too.
UMask=0002
User=unpackerr
Group=unpackerr
Expand Down
24 changes: 16 additions & 8 deletions pkg/unpackerr/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"log"
"os"
"path/filepath"
"runtime"
"strconv"
"time"
Expand Down Expand Up @@ -138,10 +139,7 @@ func (u *Unpackerr) setupLogging() {
u.Logger.Error.SetFlags(log.Lshortfile | log.Lmicroseconds | log.Ldate)
}

if logFile, err := homedir.Expand(u.Config.LogFile); err == nil {
u.Config.LogFile = logFile
}

u.Config.LogFile = getLogFilePath(u.Config.LogFile, "unpackerr.log")
fileMode, _ := strconv.ParseUint(u.LogFileMode, bits8, base32)
rotate := &rotatorr.Config{
Filepath: u.Config.LogFile, // log file name.
Expand Down Expand Up @@ -175,6 +173,19 @@ func (u *Unpackerr) setupLogging() {
}
}

// getLogFilePath takes in a path and a base name. In case the path is a directory, they are joined.
func getLogFilePath(logFile, base string) string {
if expanded, err := homedir.Expand(logFile); err == nil {
logFile = expanded
}

if stat, err := os.Stat(logFile); err == nil && stat.IsDir() {
return filepath.Join(logFile, base)
}

return logFile
}

func (u *Unpackerr) updateLogOutput(writer io.Writer, errors io.Writer) {
if u.Webserver != nil && u.Webserver.LogFile != "" {
u.setupHTTPLogging()
Expand All @@ -193,10 +204,7 @@ func (u *Unpackerr) updateLogOutput(writer io.Writer, errors io.Writer) {
}

func (u *Unpackerr) setupHTTPLogging() {
if logFile, err := homedir.Expand(u.Webserver.LogFile); err == nil {
u.Webserver.LogFile = logFile
}

u.Webserver.LogFile = getLogFilePath(u.Webserver.LogFile, "http.log")
rotate := &rotatorr.Config{
Filepath: u.Webserver.LogFile, // log file name.
FileSize: int64(u.Webserver.LogFileMb) * megabyte, // megabytes
Expand Down
2 changes: 1 addition & 1 deletion settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export DATE VERSION ITERATION COMMIT BRANCH
### Optional ###

# Import this signing key only if it's in the keyring.
if gpg --list-keys 2>/dev/null | grep -q B93DD66EF98E54E2EAE025BA0166AD34ABC5A57C; then
if gpg --list-keys 2>/dev/null | grep -q B93DD66EF98E54E2EAE025BA0166AD34ABC5A57C && debsigs -h > /dev/null; then
export SIGNING_KEY=B93DD66EF98E54E2EAE025BA0166AD34ABC5A57C
fi

Expand Down