diff --git a/cli.go b/cli.go new file mode 100644 index 0000000000000000000000000000000000000000..c1b6994958139db61b77e7a3babe8a8ac180fa48 --- /dev/null +++ b/cli.go @@ -0,0 +1,54 @@ +// Copyright (c) 2018-2021, Sylabs Inc. All rights reserved. +// This software is licensed under a 3-clause BSD license. Please consult the +// LICENSE.md file distributed with the sources of this project regarding your +// rights to use or distribute this software. + +package main + +import ( + "log" + "log/syslog" + "os" + "os/user" + "strings" + "fmt" + + "github.com/sylabs/singularity/v4/cmd/internal/cli" + "github.com/sylabs/singularity/v4/internal/pkg/buildcfg" + useragent "github.com/sylabs/singularity/v4/pkg/util/user-agent" +) + +func main() { + logger, err := syslog.New(syslog.LOG_INFO|syslog.LOG_USER, "singularity-start") + if err != nil { + log.Fatalf("Error while connecting to syslog: %v", err) + } + defer logger.Close() + + currentUser, err := user.Current() + if err != nil { + currentUser = &user.User{Username: "unknown"} + } + + hostname, err := os.Hostname() + if err != nil { + hostname = "unknown-host" + } + + pbsJobID := os.Getenv("PBS_JOBID") + if pbsJobID == "" { + pbsJobID = "out-of-job" + } + + cmd := os.Args[0] + args := strings.Join(os.Args[1:], " ") + + message := fmt.Sprintf("%s@%s %s %s %s", currentUser.Username, hostname, pbsJobID, cmd, args) + + logger.Info(message) + + useragent.InitValue(buildcfg.PACKAGE_NAME, buildcfg.PACKAGE_VERSION) + + // In cmd/internal/cli/singularity.go + cli.ExecuteSingularity() +} diff --git a/make.sh b/make.sh index 01ea0343b944f3897c6c9d3ffdac5e807b6104eb..2de276b5c40efa64eafb0dce5f83652afbdfc861 100755 --- a/make.sh +++ b/make.sh @@ -43,6 +43,7 @@ GOVERSION=${GOVERSION:-$(curl -s https://go.dev/VERSION?m=text | head -1)} # Priprava adresare pro hotove balicky a zapamatovani cesty mkdir build export BUILD=${PWD}/build +export ROOTPWD=${PWD} # Stazeni a instalace GO wget -q -O /tmp/${GOVERSION}.${OS}-${ARCH}.tar.gz https://dl.google.com/go/${GOVERSION}.${OS}-${ARCH}.tar.gz && tar -C /usr/local -xzf /tmp/${GOVERSION}.${OS}-${ARCH}.tar.gz @@ -70,6 +71,9 @@ curl -LO https://proot.gitlab.io/proot/bin/proot chmod +x ./proot echo "proot usr/bin" >> debian/singularity-ce.install +# Kopie upraveneho cli.go kvuli logovani pouziti do syslogu +cp -v ${ROOTPWD}/cli.go cmd/singularity/cli.go + # Build balicku dpkg-buildpackage -uc -us -b