Add a default path for the config file
This commit is contained in:
parent
b4731cbd71
commit
c031e08d71
13
Makefile
13
Makefile
@ -5,13 +5,18 @@ GOFLAGS ?=
|
|||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
BINDIR ?= bin
|
BINDIR ?= bin
|
||||||
MANDIR ?= share/man
|
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
|
all: soju sojuctl doc/soju.1
|
||||||
|
|
||||||
soju:
|
soju:
|
||||||
$(GO) build $(GOFLAGS) ./cmd/soju
|
$(GO) build $(goflags) ./cmd/soju
|
||||||
sojuctl:
|
sojuctl:
|
||||||
$(GO) build $(GOFLAGS) ./cmd/sojuctl
|
$(GO) build $(goflags) ./cmd/sojuctl
|
||||||
doc/soju.1: doc/soju.1.scd
|
doc/soju.1: doc/soju.1.scd
|
||||||
$(SCDOC) <doc/soju.1.scd >doc/soju.1
|
$(SCDOC) <doc/soju.1.scd >doc/soju.1
|
||||||
|
|
||||||
@ -20,10 +25,10 @@ clean:
|
|||||||
install:
|
install:
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/$(BINDIR)
|
mkdir -p $(DESTDIR)$(PREFIX)/$(BINDIR)
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/$(MANDIR)/man1
|
mkdir -p $(DESTDIR)$(PREFIX)/$(MANDIR)/man1
|
||||||
mkdir -p $(DESTDIR)/etc/soju
|
mkdir -p $(DESTDIR)/$(SYSCONFDIR)/soju
|
||||||
mkdir -p $(DESTDIR)/var/lib/soju
|
mkdir -p $(DESTDIR)/var/lib/soju
|
||||||
cp -f soju sojuctl $(DESTDIR)$(PREFIX)/$(BINDIR)
|
cp -f soju sojuctl $(DESTDIR)$(PREFIX)/$(BINDIR)
|
||||||
cp -f doc/soju.1 $(DESTDIR)$(PREFIX)/$(MANDIR)/man1
|
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
|
.PHONY: soju sojuctl clean install
|
||||||
|
@ -108,7 +108,7 @@ func loadConfig() (*config.Server, *soju.Config, error) {
|
|||||||
func main() {
|
func main() {
|
||||||
var listen []string
|
var listen []string
|
||||||
flag.Var((*stringSliceFlag)(&listen), "listen", "listening address")
|
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.BoolVar(&debug, "debug", false, "enable debug logging")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ func init() {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var configPath string
|
var configPath string
|
||||||
flag.StringVar(&configPath, "config", "", "path to configuration file")
|
flag.StringVar(&configPath, "config", config.DefaultPath, "path to configuration file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var cfg *config.Server
|
var cfg *config.Server
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
"git.sr.ht/~emersion/go-scfg"
|
"git.sr.ht/~emersion/go-scfg"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var DefaultPath string
|
||||||
|
|
||||||
type IPSet []*net.IPNet
|
type IPSet []*net.IPNet
|
||||||
|
|
||||||
func (set IPSet) Contains(ip net.IP) bool {
|
func (set IPSet) Contains(ip net.IP) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user