Skip to content

Commit 803a5b7

Browse files
committed
install binary in shared location, accessible by users
1 parent 57965d2 commit 803a5b7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
GIT_TAG := $(shell echo $(shell git describe --tags || git branch --show-current) | sed 's/^v//')
22
COMMIT := $(shell git log -1 --format='%H')
33
BUILD_DATE := $(shell date '+%Y-%m-%d')
4+
IS_SUDO_USER := $(shell if [ "$(shell whoami)" = "root" ] || [ "$(shell groups | grep -e 'sudo' -e 'admin' -e 'google-sudoers' | wc -l)" = "1" ]; then echo "1"; fi)
5+
GO_BIN := $(shell echo $(shell which go || echo "/usr/local/go/bin/go" ))
46

57
###############################################################################
68
### Build flags ###
@@ -12,15 +14,6 @@ LD_FLAGS = -X github.com/bcdevtools/node-management/constants.VERSION=$(GIT_TAG)
1214

1315
BUILD_FLAGS := -ldflags '$(LD_FLAGS)'
1416

15-
###############################################################################
16-
### Test ###
17-
###############################################################################
18-
19-
test: go.sum
20-
@echo "testing"
21-
@go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic
22-
.PHONY: test
23-
2417
###############################################################################
2518
### HTML ###
2619
###############################################################################
@@ -50,5 +43,12 @@ install: go.sum
5043
@echo "Installing Node Management binary..."
5144
@echo "Flags $(BUILD_FLAGS)"
5245
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/nmngd
46+
@echo " [v] Installed in GOPATH/bin"
47+
@if [ "$(shell uname)" = "Linux" ] && [ "$(IS_SUDO_USER)" = "1" ]; then \
48+
sudo mv $(shell $(GO_BIN) env GOPATH)/bin/nmngd /usr/local/bin/nmngd; \
49+
echo " [v] Installed as global command"; \
50+
else \
51+
echo " [x] (Skipped) Install as global command"; \
52+
fi
5353
@echo "Installed Node Management successfully"
5454
.PHONY: install

0 commit comments

Comments
 (0)