tabin-plugins 0.3.1

Libs for building nagios-compatible check scripts, some scripts, and some libs to read from /proc and /sys on Linux.
Documentation
P_VERSION=$(shell head -n4 Cargo.toml | grep version | cut -d ' ' -f3 | tr -d \")
DEB=target/linux/release/tabin-plugins_$(P_VERSION)_amd64.deb
REBUILD_DEB=0
REGISTRY=$(HOME)/.cargo/linux-registry

plugins-deb: $(DEB)

upload:
	aws s3 cp $(DEB) s3://knewton-apt/
	deb-s3 upload -a amd64 --bucket knewton-public $(DEB) --sign 7E94EA8F

deb: $(DEB)

$(DEB): target/linux/release
	cd target/linux/release ; \
	  mkdir -p usr/local/bin ; \
	  cp -u check-* usr/local/bin ; \
	  rm usr/local/bin/*.d ; \
	  fpm -s dir -t deb \
	    -n "tabin-plugins" -v $(P_VERSION) \
	    --description "Nagios-compatible check scripts" \
	    usr
	echo "deb is in $(CURDIR)/target/linux/release/tabin-plugins_$(P_VERSION)_amd64.deb"

linux: target/linux/release

registry: $(REGISTRY)

.linux-registry:
	mkdir -p .linux-registry

target/linux/release: src/bin/check-*.rs registry
	docker run -it --rm \
	    -e CARGO_TARGET_DIR=target/linux \
	    -v $(CURDIR):/source \
	    -v $(REGISTRY):/usr/local/cargo/registry \
	    rust:1-jessie \
	    bash -c "cd /source ; cargo build --release"
# rm -f target/linux/release/tabin-plugins_$(P_VERSION)_amd64.deb

target/osx/release: src/bin/check-*.rs
	CARGO_TARGET_DIR=target/osx cargo build --release

install: target/osx/release
	cp target/osx/release/check-* ~/.local/bin

target/osx/debug: src/bin/check-*.rs
	CARGO_TARGET_DIR=target/osx cargo build

install-debug: target/osx/debug
	cp target/osx/debug/check-* ~/.local/bin

rebuild: registry
	docker run -it --rm \
	    -e CARGO_TARGET_DIR=target/linux \
	    -v $(pwd):/source rust \
	    -v $(CURDIR)/.linux-registry:/usr/local/cargo/registry
	    bash -c "cd /source ; cargo build --release"
#	rm -f target/linux/release/tabin-plugins_$(P_VERSION)_amd64.deb

.PHONY: rebuild \
	linux \
	install