Skip to content

Commit

Permalink
Merge pull request #24 from leoleovich/freebsd_client
Browse files Browse the repository at this point in the history
Add grafsy-client to FreeBSD package

- Make default config's path configurable
- Add grafsy-client to the FreeBSD package
- Add custom version and ConfigPath parameters in freebsd binaries
  • Loading branch information
Felixoid authored Sep 15, 2020
2 parents 17ec023 + 9f7d600 commit 79c8825
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (
"syscall"
)

// ConfigPath is the default path to the configuration file
var ConfigPath = "/etc/grafsy/grafsy.toml"

// Config is the main config specified by user.
type Config struct {
// Supervisor manager which is used to run Grafsy. e.g. systemd.
Expand Down
5 changes: 4 additions & 1 deletion freebsd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ PLIST_SUB= GRAFSY_USER=${GRAFSY_USER} \
GOPATH= ${WRKDIR}/gopath
GOSRC= github.com/${GH_ACCOUNT}/${PORTNAME}
GOCMD= ${SETENV} ${BUILD_ENV} GOCACHE=/tmp GOPATH=${GOPATH}
GOFLAGS= -ldflags "-X 'main.version=${PORTVERSION}-${PORTREVISION}' -X 'github.com/leoleovich/grafsy.ConfigPath=${GRAFSY_ETCDIR}/grafsy.toml'"

post-extract:
mkdir -p ${WRKDIR}/gopath/src/github.com/${GH_ACCOUNT}
Expand All @@ -56,13 +57,15 @@ post-extract:
${MV} ${WRKSRC_pkg_errors} ${GOPATH}/src/github.com/pkg/errors

do-build:
${GOCMD} go install ${GOSRC}/${PORTNAME}
${GOCMD} go install ${GOFLAGS} ${GOSRC}/${PORTNAME}
${GOCMD} go install ${GOFLAGS} ${GOSRC}/${PORTNAME}-client

do-install:
${MKDIR} ${STAGEDIR}${GRAFSY_LOGDIR}
${MKDIR} ${STAGEDIR}${GRAFSY_PIDDIR}
${MKDIR} ${STAGEDIR}${GRAFSY_ETCDIR}
${INSTALL_PROGRAM} ${GOPATH}/bin/${PORTNAME} ${STAGEDIR}${PREFIX}/bin/${PORTNAME}
${INSTALL_PROGRAM} ${GOPATH}/bin/${PORTNAME}-client ${STAGEDIR}${PREFIX}/bin/${PORTNAME}-client
${INSTALL_PROGRAM} ${GOPATH}/src/${GOSRC}/${PORTNAME}.toml ${STAGEDIR}${GRAFSY_ETCDIR}/${PORTNAME}.toml.sample

.include <bsd.port.options.mk>
Expand Down
1 change: 1 addition & 0 deletions freebsd/pkg-plist
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin/grafsy
bin/grafsy-client
@dir(%%GRAFSY_USER%%,%%GRAFSY_GROUP%%,0750) %%GRAFSY_PIDDIR%%
@dir(root,wheel,0755) %%GRAFSY_ETCDIR%%
@sample %%GRAFSY_ETCDIR%%/grafsy.toml.sample
2 changes: 1 addition & 1 deletion grafsy-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func main() {
fmt.Fprintf(os.Stderr, "\nArgs:\n")
flag.PrintDefaults()
}
flag.StringVar(&configFile, "c", "/etc/grafsy/grafsy.toml", "Path to config file.")
flag.StringVar(&configFile, "c", grafsy.ConfigPath, "Path to config file.")
flag.BoolVar(&printVersion, "v", printVersion, "Print version and exit")
flag.IntVar(&connectionTimeout, "w", 50, "Timeout ")
flag.Parse()
Expand Down
2 changes: 1 addition & 1 deletion grafsy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var version = "dev"
func main() {
var configFile string
printVersion := false
flag.StringVar(&configFile, "c", "/etc/grafsy/grafsy.toml", "Path to config file.")
flag.StringVar(&configFile, "c", grafsy.ConfigPath, "Path to config file.")
flag.BoolVar(&printVersion, "v", printVersion, "Print version and exit")
flag.Parse()

Expand Down

0 comments on commit 79c8825

Please sign in to comment.