This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from lovoo/packaging
add packaging target in Makefile
- Loading branch information
Showing
5 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
BUILD_DIR = build | ||
BUILD_DIR = $(CURDIR)/build | ||
PROJECT_NAME = ipmi_exporter | ||
|
||
GO = go | ||
GOX = gox | ||
GOX_ARGS = -output="$(BUILD_DIR)/{{.Dir}}_{{.OS}}_{{.Arch}}" -osarch="linux/amd64 linux/386 linux/arm linux/arm64 darwin/amd64 freebsd/amd64 freebsd/386 windows/386 windows/amd64" | ||
VERSION = $(shell git describe --tags || echo 0.0.0-dev) | ||
GO = go | ||
GOX = gox | ||
GOX_ARGS = -output="$(BUILD_DIR)/{{.Dir}}_{{.OS}}_{{.Arch}}" -osarch="linux/amd64 linux/386 linux/arm linux/arm64 darwin/amd64 freebsd/amd64 freebsd/386 windows/386 windows/amd64" | ||
|
||
.PHONY: build | ||
build: | ||
$(GO) build -o $(BUILD_DIR)/$(PROJECT_NAME) . | ||
GOBIN=$(BUILD_DIR) $(GO) install -v -ldflags '-X main.Version=$(VERSION)' | ||
|
||
.PHONY: clean | ||
clean: | ||
|
@@ -19,5 +19,40 @@ test: | |
|
||
.PHONY: release-build | ||
release-build: | ||
@go get -u github.com/mitchellh/gox | ||
@$(GO) get -u github.com/mitchellh/gox | ||
@$(GOX) $(GOX_ARGS) github.com/lovoo/$(PROJECT_NAME) | ||
|
||
.PHONY: deb | ||
deb: | ||
make build-deb ARCH=amd64 GOARCH=amd64 | ||
make build-deb ARCH=i386 GOARCH=386 | ||
make build-deb ARCH=arm64 GOARCH=arm64 | ||
make build-deb ARCH=armhf GOARCH=arm | ||
|
||
.PHONY: build-deb | ||
build-deb: | ||
fpm -s dir -t deb \ | ||
--name $(PROJECT_NAME) \ | ||
--version $(VERSION) \ | ||
--package $(BUILD_DIR)/$(PROJECT_NAME)_$(VERSION)_$(ARCH).deb \ | ||
--depends ipmitool \ | ||
--maintainer "LOVOO IT Operations <[email protected]>" \ | ||
--deb-priority optional \ | ||
--category monitoring \ | ||
--force \ | ||
--deb-compression bzip2 \ | ||
--license "BSD-3-Clause" \ | ||
--vendor "LOVOO GmbH" \ | ||
--deb-no-default-config-files \ | ||
--after-install packaging/postinst.deb \ | ||
--before-remove packaging/prerm.deb \ | ||
--url https://github.com/lovoo/ipmi_exporter \ | ||
--description "Exports statistics from IPMI and publishes them for scraping by Prometheus." \ | ||
--architecture $(ARCH) \ | ||
$(BUILD_DIR)/$(PROJECT_NAME)_linux_$(GOARCH)=/usr/bin/ipmi_exporter \ | ||
packaging/ipmi-exporter.service=/lib/systemd/system/ipmi-exporter.service | ||
|
||
.PHONY: release-package | ||
release-package: | ||
package_cloud push lovoo/prometheus-exporters/debian/jessie build/*.deb | ||
package_cloud push lovoo/prometheus-exporters/debian/stretch build/*.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[Unit] | ||
Description=IPMI Metrics Exporter for Prometheus | ||
After=syslog.target network.target | ||
|
||
[Service] | ||
Type=simple | ||
User=root | ||
Group=root | ||
WorkingDirectory=/tmp | ||
ExecStart=/usr/bin/ipmi_exporter | ||
RestartSec=1 | ||
Restart=on-failure | ||
StandardOutput=syslog | ||
StandardError=syslog | ||
SyslogIdentifier=ipmi_exporter | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
case "$1" in | ||
abort-upgrade|abort-remove|abort-deconfigure) | ||
;; | ||
|
||
configure) | ||
if which systemctl > /dev/null; then | ||
systemctl daemon-reload || : | ||
systemctl enable ipmi-exporter || : | ||
systemctl restart ipmi-exporter || : | ||
else | ||
echo "Couldn't find systemd to control IPMI Metrics Exporter, cannot proceed." | ||
echo "Open an issue and tell us about your system." | ||
exit 1 | ||
fi | ||
;; | ||
|
||
*) | ||
echo "postinst called with unknown argument \`$1'" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ $1 = "remove" ] ; then | ||
if which systemctl > /dev/null; then | ||
systemctl --no-reload disable ipmi-exporter || : | ||
systemctl stop ipmi-exporter || : | ||
fi | ||
fi |