commit 49c84ee072f80a6ca0c8ff617b76c498aa25b5ba Author: Markus Pesch Date: Fri Dec 20 11:47:34 2024 +0100 Initial Commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b53e68c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = false + +[Makefile] +indent_style = tab \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1863f48 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +Makefile eol=lf txt \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..233ae87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +pkg +src/prometheus-x509-certificate-exporter +*.rpm +**/*.iml +**/*.idea \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..66cfce6 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +# VERSION / RELEASE +# If no version is specified as a parameter of make, the last git hash +# value is taken. +EPOCH=0 +VERSION?=3.18.0 +RELEASE=0 +ARCH=x86_64 + +# RPM_PACKAGE_NAME +# Defines the name of the rpm package. This name is required to install the rpm package with an rpm package manager like +# dnf, rpm or yum. +RPM_PACKAGE_NAME=prometheus-x509-certificate-exporter +RPM_FILE_NAME_SHORT=${RPM_PACKAGE_NAME}.rpm +RPM_FILE_NAME_FULL:=${RPM_PACKAGE_NAME}-${EPOCH}-${VERSION}-${RELEASE}.${ARCH}.rpm + +root_dir:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) + +# BUILD +# ============================================================================== +PHONY:=${RPM_FILE_NAME_SHORT} +${RPM_FILE_NAME_SHORT}: ${RPM_FILE_NAME_FULL} + +${RPM_FILE_NAME_FULL}: clean + + git clone https://github.com/enix/x509-certificate-exporter.git ./src/${RPM_PACKAGE_NAME} + go build -C ./src/${RPM_PACKAGE_NAME}/cmd/x509-certificate-exporter/ -o ${RPM_PACKAGE_NAME} + + install -D --mode 0644 "${root_dir}/src/systemd.service" "${root_dir}/pkg/usr/lib/systemd/system/${RPM_PACKAGE_NAME}.service" + install -D --mode 0755 --target-directory "${root_dir}/pkg/usr/bin" "${root_dir}/src/${RPM_PACKAGE_NAME}/cmd/x509-certificate-exporter/${RPM_PACKAGE_NAME}" + install -D --mode 0600 /dev/null "${root_dir}/pkg/etc/conf.d/${RPM_PACKAGE_NAME}" + install -D --mode 0755 --target-directory "${root_dir}/pkg/usr/share/licenses/${RPM_PACKAGE_NAME}" "${root_dir}/src/${RPM_PACKAGE_NAME}/LICENSE" + + rpm-builder \ + --dir pkg/:/ \ + --epoch ${EPOCH} \ + --version ${VERSION} \ + --release ${RELEASE} \ + --arch ${ARCH} \ + --out ${RPM_FILE_NAME_FULL} \ + ${RPM_PACKAGE_NAME} + +# # CLEAN +# # ============================================================================== +clean: + - rm --force --recursive ./pkg ./src/${RPM_PACKAGE_NAME} + - rm --force ${RPM_FILE_NAME_FULL} + +# PHONY +# ============================================================================== +# Declare the contents of the PHONY variable as phony. We keep that information +# in a variable so we can use it in if_changed. +.PHONY: ${PHONY} diff --git a/README.md b/README.md new file mode 100644 index 0000000..52da238 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# README \ No newline at end of file diff --git a/src/systemd.service b/src/systemd.service new file mode 100644 index 0000000..761d0ec --- /dev/null +++ b/src/systemd.service @@ -0,0 +1,18 @@ +[Unit] +Description=Prometheus exporter for x509 certificate metrics +Requires=network-online.target +After=network-online.target + +[Service] +EnvironmentFile=-/etc/conf.d/prometheus-x509-certificate-exporter +ExecStart=/usr/bin/prometheus-x509-certificate-exporter $EXTRA_ARGS +ExecReload=/bin/kill -HUP $MAINPID +User=root +Group=root +Restart=on-failure +RestartSec=5s + +NoNewPrivileges=true + +[Install] +WantedBy=multi-user.target \ No newline at end of file