timetable-extension #1

Open
fred.boniface wants to merge 160 commits from timetable-extension into main
2 changed files with 24 additions and 2 deletions
Showing only changes of commit ff98adf1a6 - Show all commits

View File

@ -5,4 +5,5 @@ RUN go build .
FROM scratch
COPY --from=builder /source/timetable-mgr /bin/timetable-mgr
USER nobody
CMD [ "/bin/timetable-mgr" ]

25
main.go
View File

@ -19,9 +19,19 @@ import (
"go.uber.org/zap"
)
const (
bold = "\033[1m"
redB = "\033[1;31m"
blue = "\033[32m" //Actually green!
cyan = "\033[36m"
reset = "\033[0m"
)
func init() {
printStartupBanner()
fmt.Printf("Version %s \n\n", helpers.Version)
fmt.Printf("%sVersion %s \n\n%s", bold+blue, helpers.Version, reset)
checkRunAsRoot()
}
func main() {
@ -110,5 +120,16 @@ func printStartupBanner() {
|___/
`
fmt.Println(art)
fmt.Println(cyan + art + reset)
}
func checkRunAsRoot() {
uid := os.Getuid()
if uid != 0 {
return
}
fmt.Println(redB + "This program must not be run as the root user" + reset)
fmt.Println("")
os.Exit(1)
}