012181e2afce271152b115086acaef8ca2915fc1 — Ben Morrison 1 year, 2 days ago 6dd01e1
updated makefile to use printf
1 files changed, 31 insertions(+), 47 deletions(-)

M Makefile
M Makefile => Makefile +31 -47
@@ 1,48 1,38 @@
VERSION?=$(shell git tag | grep ^v | sort -V | tail -n 1)
VERSION?=$(shell git describe --tags --abbrev=0)
GOFLAGS?=-ldflags '-X git.sr.ht/~gbmor/getwtxt/svc.Vers=${VERSION}'

getwtxt: getwtxt.go go.mod go.sum
	@echo Building getwtxt. This may take a minute or two.
	@printf "\n%s\n" "Building getwtxt. This may take a minute or two."
	@mkdir -p logs
	go build $(GOFLAGS) -o $@
	@echo ...Done\!
	@printf "\n%s\n" "...Done!"

.PHONY: clean
	@echo Cleaning build and module caches...
	@printf "\n%s\n" "Cleaning build ..."
	go clean
	go clean -cache -modcache
	@echo ...Done\!
	@printf "\n%s\n" "...Done!"

.PHONY: update
	@echo Updating from upstream repository...
	@printf "\n%s\n\n" "Updating from upstream repository..."
	git pull --rebase origin master
	@echo ...Done\!
	@printf "\n%s\n" "...Done!"

.PHONY: install
	@echo Installing getwtxt...
	@echo Creating user/group...
	@printf "\n%s\n" "Installing getwtxt..."

	@printf "\n%s\n" "Creating user/group..."
	adduser -home $(BINDIR) --system --group getwtxt
	@echo Creating directories...

	@printf "\n%s\n" "Creating directories..."
	mkdir -p $(BINDIR)/assets/tmpl $(BINDIR)/docs $(BINDIR)/logs $(BINDIR)/static
	@echo Copying files...

	@printf "\n%s\n" "Copying files..."
	install -m755 getwtxt $(BINDIR)
	install -m644 getwtxt.yml $(BINDIR)
	install -m644 assets/style.css $(BINDIR)/assets

@@ 51,37 41,31 @@ install:
	install -m644 README.md $(BINDIR)/docs
	install -m644 LICENSE $(BINDIR)/docs
	install -m644 etc/getwtxt.service /etc/systemd/system
	@echo Setting ownership...

	@printf "\n%s\n" "Setting ownership..."
	chown -R getwtxt:getwtxt $(BINDIR)
	@echo ...Done\! Don\'t forget to run
	@echo '         $$ systemctl enable getwtxt'

	@printf "\n%s\n\t%s\n" "...Done! Don't forget to run:" "systemctl enable getwtxt"

.PHONY: uninstall
	@echo Uninstalling getwtxt...
	@echo Stopping service if running...
	@echo systemctl stop getwtxt
	@printf "\n%s\n" "Uninstalling getwtxt..."

	@printf "\n%s\n%s\n" "Stopping service if running..." "systemctl stop getwtxt"
	@systemctl stop getwtxt >/dev/null 2>&1 || true
	@echo Disabling service autostart...
	@echo systemctl disable getwtxt

	@printf "\n%s\n%s\n" "Disabling service autostart..." "systemctl disable getwtxt"
	@systemctl disable getwtxt >/dev/null 2>&1 || true
	@echo Removing files

	@printf "\n%s\n" "Removing files"
	rm -rf $(BINDIR)/assets
	rm -rf $(BINDIR)/logs
	rm -f $(BINDIR)/getwtxt
	rm -f $(BINDIR)/getwtxt.yml
	rm -f /etc/systemd/system/getwtxt.service
	@echo Removing user
	- userdel getwtxt
	@echo The database is still intact in /usr/local/getwtxt/
	@echo ...Done\!

	@printf "\n%s\n" "Removing user"
	userdel getwtxt

	@printf "\n%s\n" "The database is still intact in /usr/local/getwtxt/"
	@printf "\n%s\n" "...Done!"