commit 24387af2a4982194bb718d3b35be30dc6ce2414d Author: Toshaan Bharvani Date: Wed Aug 14 11:56:10 2024 +0200 initial package creation Signed-off-by: Toshaan Bharvani diff --git a/SOURCES/icinga-notifications.service b/SOURCES/icinga-notifications.service new file mode 100644 index 0000000..e06cbcb --- /dev/null +++ b/SOURCES/icinga-notifications.service @@ -0,0 +1,12 @@ +[Unit] +Description=Icinga Notifications +After=syslog.target network-online.target icinga2.service postgresql.service + +[Service] +Type=notify +ExecStart=/usr/sbin/icinga-notifications --config /etc/icinga-notifications/config.yml +User=icinganotifications +Group=icinganotifications + +[Install] +WantedBy=multi-user.target diff --git a/SPECS/icinga-notifications.spec b/SPECS/icinga-notifications.spec new file mode 100644 index 0000000..13647eb --- /dev/null +++ b/SPECS/icinga-notifications.spec @@ -0,0 +1,86 @@ +%global provider github +%global provider_tld com +%global project Icinga +%global repo icinga-notifications +%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} +%global import_path %{provider_prefix} +%define debug_package %nil +%define configdir %{_sysconfdir}/%{name} +%define service %{name}.service + +Name: icinga-notifications +Version: 0.1.1 +Release: 1%{?dist} +Summary: Icinga Notifications +Group: System Environment/Daemons +License: GPLv2+ +URL: https://%{provider_prefix} +#Source0: https://%{import_path}/archive/v%{version}.tar.gz +Source1: icinga-notifications.service +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} +BuildRequires: gcc +BuildRequires: git +BuildRequires: systemd +Requires(pre): shadow-utils + + +%description +Icinga Notifications + + +%prep +%setup -q -T -c %{name}-%{version} +git clone https://%{provider_prefix} . +sed 's/go 1.22$/go 1.22.0/' -i go.mod + +%build +go build -v -ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid "%{version}" \ + -X 'icinga-notifications/internal.LibExecDir="%{_libexecdir}"/"%{name}"/' -X 'icinga-notifications/internal.SysConfDir="%{configdir}"'" \ + -buildvcs=false -trimpath ./cmd/icinga-notifications +go build -v -ldflags "-extldflags -s -w -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -buildid "%{version}"" -buildvcs=false -trimpath -o channels/ ./cmd/channels/... + + +%install +install -d -m 0755 %{buildroot}%{_sbindir} +install -d -m 0755 %{buildroot}%{configdir} +install -d -m 0755 %{buildroot}%{_unitdir} +install -d -m 0755 %{buildroot}%{_libexecdir}/%{name} +install -m 0755 icinga-notifications %{buildroot}%{_sbindir}/ +%{__cp} -r channels %{buildroot}%{_libexecdir}/%{name}/ +install -m 0644 config.example.yml %{buildroot}%{configdir}/config.yml +#install -m 0644 icinga2.conf %{buildroot}%{configdir}/icinga2-notifications.conf +install -m 0644 %{S:1} %{buildroot}%{_unitdir}/ +install -d -m 0755 %{buildroot}%{_datadir}/%{name} +(umask 0022 && cp -rv schema %{buildroot}%{_datadir}/%{name}/) + + +%pre +getent group icinganotifications >/dev/null || groupadd -r icinganotifications +getent passwd icinganotifications >/dev/null || useradd -r -g icinganotifications -d /etc/icinganotifications -s /sbin/nologin -c 'Icinga Notifications' icinganotifications +%post +%systemd_post %{service} +%preun +%systemd_preun %{service} +%postun +%systemd_postun %{service} + + +%clean +rm -rf %{buildroot} + + +%files +%defattr(-,root,root) +%doc LICENSE README.md +%{_sbindir}/icinga-notifications +%{_libexecdir}/%{name}/channels/ +%{_unitdir}/%{service} +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/schema +%defattr(0644,icinganotifications,icinganotifications,0755) +%dir %{configdir} +%config(noreplace) %{configdir}/config.yml +#%config(noreplace) %{configdir}/icinga2-notifications.conf + + +%changelog