Add a default path for the config file

This commit is contained in:
Simon Ser 2023-02-06 13:16:55 +01:00
parent b4731cbd71
commit c031e08d71
4 changed files with 13 additions and 6 deletions

View File

@ -5,13 +5,18 @@ GOFLAGS ?=
PREFIX ?= /usr/local
BINDIR ?= bin
MANDIR ?= share/man
SYSCONFDIR ?= etc
config_path := $(DESTDIR)/$(SYSCONFDIR)/soju/config
goflags := $(GOFLAGS) \
-ldflags="-X 'git.sr.ht/~emersion/soju/config.DefaultPath=$(config_path)'"
all: soju sojuctl doc/soju.1
soju:
$(GO) build $(GOFLAGS) ./cmd/soju
$(GO) build $(goflags) ./cmd/soju
sojuctl:
$(GO) build $(GOFLAGS) ./cmd/sojuctl
$(GO) build $(goflags) ./cmd/sojuctl
doc/soju.1: doc/soju.1.scd
$(SCDOC) <doc/soju.1.scd >doc/soju.1
@ -20,10 +25,10 @@ clean:
install:
mkdir -p $(DESTDIR)$(PREFIX)/$(BINDIR)
mkdir -p $(DESTDIR)$(PREFIX)/$(MANDIR)/man1
mkdir -p $(DESTDIR)/etc/soju
mkdir -p $(DESTDIR)/$(SYSCONFDIR)/soju
mkdir -p $(DESTDIR)/var/lib/soju
cp -f soju sojuctl $(DESTDIR)$(PREFIX)/$(BINDIR)
cp -f doc/soju.1 $(DESTDIR)$(PREFIX)/$(MANDIR)/man1
[ -f $(DESTDIR)/etc/soju/config ] || cp -f config.in $(DESTDIR)/etc/soju/config
[ -f $(config_path) ] || cp -f config.in $(config_path)
.PHONY: soju sojuctl clean install

View File

@ -108,7 +108,7 @@ func loadConfig() (*config.Server, *soju.Config, error) {
func main() {
var listen []string
flag.Var((*stringSliceFlag)(&listen), "listen", "listening address")
flag.StringVar(&configPath, "config", "", "path to configuration file")
flag.StringVar(&configPath, "config", config.DefaultPath, "path to configuration file")
flag.BoolVar(&debug, "debug", false, "enable debug logging")
flag.Parse()

View File

@ -31,7 +31,7 @@ func init() {
func main() {
var configPath string
flag.StringVar(&configPath, "config", "", "path to configuration file")
flag.StringVar(&configPath, "config", config.DefaultPath, "path to configuration file")
flag.Parse()
var cfg *config.Server

View File

@ -11,6 +11,8 @@ import (
"git.sr.ht/~emersion/go-scfg"
)
var DefaultPath string
type IPSet []*net.IPNet
func (set IPSet) Contains(ip net.IP) bool {