mirror of
https://github.com/pengutronix/monitoring-check-systemd-service.git
synced 2025-07-23 05:44:51 +02:00
Standardize rpm builds for checks
This commit is contained in:
parent
ee4144aa69
commit
4928b37a63
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
SPECS/*
|
||||||
|
SOURCES/*
|
||||||
|
BUILD/*
|
||||||
|
BUILDROOT/*
|
||||||
|
RPMS/*
|
||||||
|
SRPMS/*
|
||||||
|
|
101
contrib/build.sh
Executable file
101
contrib/build.sh
Executable file
@ -0,0 +1,101 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
|
LOGLEVEL=5
|
||||||
|
|
||||||
|
source "${SCRIPT_DIR}/version.sh"
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
LOGLEVEL_TEXT[0]="Panic"
|
||||||
|
LOGLEVEL_TEXT[1]="Fatal"
|
||||||
|
LOGLEVEL_TEXT[2]="Error"
|
||||||
|
LOGLEVEL_TEXT[3]="Warning"
|
||||||
|
LOGLEVEL_TEXT[4]="Info"
|
||||||
|
LOGLEVEL_TEXT[5]="Debug"
|
||||||
|
LOGLEVEL=4
|
||||||
|
RPMBUILD_DIR="$(dirname "${SCRIPT_DIR}")"
|
||||||
|
SPECS_DIR="${RPMBUILD_DIR}/SPECS"
|
||||||
|
RPMS_DIR="${RPMBUILD_DIR}/RPMS"
|
||||||
|
SRPMS_DIR="${RPMBUILD_DIR}/SRPMS"
|
||||||
|
BUILD_DIR="${RPMBUILD_DIR}/BUILD"
|
||||||
|
SOURCES_DIR="${RPMBUILD_DIR}/SOURCES"
|
||||||
|
|
||||||
|
for DIR in "${SPECS_DIR}" "${RPMS_DIR}" "${SRPMS_DIR}" "${BUILD_DIR}" "${SOURCES_DIR}"; do
|
||||||
|
if [ ! -d "${DIR}" ]; then
|
||||||
|
echo "$DIR not found. Creating it."
|
||||||
|
mkdir -p "${DIR}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
local LEVEL=$1
|
||||||
|
if [ ${LEVEL} -le ${LOGLEVEL} ]; then
|
||||||
|
shift 1
|
||||||
|
local DATE=$(date +"%Y-%m-%d %H:%M:%S")
|
||||||
|
printf "%s %s %s\n" "${DATE}" "${LOGLEVEL_TEXT[${LEVEL}]}" "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_archive() {
|
||||||
|
local URL="$1"
|
||||||
|
local APP="$2"
|
||||||
|
local VERSION="$3"
|
||||||
|
local TARGET_DIR="$4"
|
||||||
|
if [ -z "${URL}" ]; then
|
||||||
|
echo "get_archive: No URL provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${APP}" ]; then
|
||||||
|
echo "get_archive: No application provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "${VERSION}" ]; then
|
||||||
|
echo "get_archive: No version provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -n "${TARGET_DIR}" ]; then
|
||||||
|
cd "${TARGET_DIR}"
|
||||||
|
fi
|
||||||
|
log 4 "Downloading ${APP}-${VERSION}.tar.gz into ${TARGET_DIR}"
|
||||||
|
curl -sSkjL "${URL}" -o "${APP}-${VERSION}.tar.gz"
|
||||||
|
RESULT=$?
|
||||||
|
local SIZE=$(cat "${APP}-${VERSION}.tar.gz"|wc -c)
|
||||||
|
if [ $SIZE -le 512 ]; then
|
||||||
|
# 112 is the size of a tar.gz with an empty file in it, the average bitbucket error is around 150 bytes
|
||||||
|
log 2 "Download of ${APP}-${VERSION}.tar.gz failed or is damaged: File too small."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
return ${RESULT}
|
||||||
|
}
|
||||||
|
|
||||||
|
function build() {
|
||||||
|
local APP="$1"
|
||||||
|
local VERSION="$2"
|
||||||
|
local RELEASE="$3"
|
||||||
|
local ARCH="$4"
|
||||||
|
|
||||||
|
cp "${SCRIPT_DIR}/${APP}.spec" "${SPECS_DIR}/"
|
||||||
|
cd "${RPMBUILD_DIR}"
|
||||||
|
log 4 "Building ${APP} ${VERSION}-${RELEASE}"
|
||||||
|
rpmbuild --define="_topdir ${RPMBUILD_DIR}" \
|
||||||
|
--define="version ${VERSION}" \
|
||||||
|
--define="release ${RELEASE}" \
|
||||||
|
--define="app ${APP}" \
|
||||||
|
--define="arch ${ARCH}" \
|
||||||
|
-ba "${SPECS_DIR}/${APP}.spec"
|
||||||
|
local RESULT=$?
|
||||||
|
if [ ${RESULT} -ne 0 ]; then
|
||||||
|
log 2 "Building the RPM failed"
|
||||||
|
return ${RESULT}
|
||||||
|
fi
|
||||||
|
log 4 "${APP} RPM built successfully"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
init
|
||||||
|
get_archive "${URL}" "${APP}" "${VERSION}" "${SOURCES_DIR}"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
build "${APP}" "${VERSION}" "${RELEASE}" "${ARCH}"
|
||||||
|
exit $?
|
@ -1,15 +1,11 @@
|
|||||||
%define version 1.1.1
|
Name: monitoring-check_systemd_service
|
||||||
%define plugindir /usr/lib64/nagios/plugins/
|
|
||||||
Name: check-systemd-service
|
|
||||||
Version: %{version}
|
Version: %{version}
|
||||||
Release: 1
|
Release: %{release}
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Summary: Nagios/Icinga check for systemd services
|
Summary: Nagios/Icinga check for systemd services
|
||||||
AutoReqProv: no
|
AutoReqProv: no
|
||||||
BuildRoot: %buildroot
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
Source0: https://github.com/joernott/monitoring-check-systemd-service/archive/v%{version}.tar.gz#/monitoring-check-systemd-service-%{version}.tar.gz
|
Source0: https://github.com/joernott/monitoring-check-systemd-service/archive/v%{version}.tar.gz#/monitoring-check-systemd-service-%{version}.tar.gz
|
||||||
|
|
||||||
License: BSD
|
License: BSD
|
||||||
URL: https://github.com/joernott/monitoring-check-systemd-service
|
URL: https://github.com/joernott/monitoring-check-systemd-service
|
||||||
Requires: rh-python36
|
Requires: rh-python36
|
||||||
@ -25,17 +21,16 @@ Lennart Poettering says it is the right way to do and cli output is not stable
|
|||||||
and should not be parsed.
|
and should not be parsed.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n monitoring-check-systemd-service-%{version}
|
%setup -q monitoring-check-systemd-service-%{version}
|
||||||
|
|
||||||
%build
|
|
||||||
%install
|
%install
|
||||||
mkdir -p $RPM_BUILD_ROOT%{plugindir}
|
mkdir -p "$RPM_BUILD_ROOT/usr/lib64/nagios/plugins"
|
||||||
mv %{_builddir}/monitoring-check-systemd-service-%{version}/check-systemd-service $RPM_BUILD_ROOT%{plugindir}/
|
cp check-systemd-service "$RPM_BUILD_ROOT/usr/lib64/nagios/plugins/"
|
||||||
rm -rf $RPM_BUILD_ROOT/monitoring-check-systemd-service-%{version}
|
|
||||||
|
|
||||||
%clean
|
|
||||||
rm -rf $RPM_BUILD_ROOT/*
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%attr(755,root,root) %{plugindir}/check-systemd-service
|
%attr(755,root,root) /usr/lib64/nagios/plugins/check-systemd-service
|
||||||
|
|
||||||
|
%changelog
|
||||||
|
* Wed Apr 27 2022 Joern Ott <joern.ott@ott-consult.de>
|
||||||
|
- Standardize builds for plugins
|
||||||
|
|
7
contrib/version.sh
Normal file
7
contrib/version.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# see https://github.com/joernott/monitoring-check_systemd-service/tags
|
||||||
|
APP="monitoring-check_systemd_service"
|
||||||
|
VERSION="1.2.0"
|
||||||
|
RELEASE="1"
|
||||||
|
URL="https://github.com/joernott/monitoring-check_systemd_service/archive/refs/tags/v${VERSION}.tar.gz"
|
||||||
|
ARCH="noarch"
|
Loading…
x
Reference in New Issue
Block a user