From 5446c15a4d7e68fac55db678259f3ccc97938f1f Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 2 May 2019 15:24:12 +0200 Subject: [PATCH 1/9] Enable/Disable module automatically --- icinga-build-test | 18 ++++++++++++++++++ icingaweb2-module-director.spec | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100755 icinga-build-test diff --git a/icinga-build-test b/icinga-build-test new file mode 100755 index 0000000..d73365f --- /dev/null +++ b/icinga-build-test @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +module_name=director + +echo "Installing icingaweb2 module ${module_name}" +icinga-build-rpm-install "icingaweb2-module-${module_name}" + +sudo sh -ex <&2 + exit 1 + fi +ROOT diff --git a/icingaweb2-module-director.spec b/icingaweb2-module-director.spec index a8472a6..e940951 100644 --- a/icingaweb2-module-director.spec +++ b/icingaweb2-module-director.spec @@ -46,6 +46,33 @@ cp -r * %{buildroot}%{basedir} %clean rm -rf %{buildroot} +%post +set -e + +# Only for fresh installations +if [ $1 == 1 ]; then + if [ ! -d /etc/icingaweb2/enabledModules ]; then + mkdir /etc/icingaweb2/enabledModules + chmod g=rwx,o= /etc/icingaweb2/enabledModules + fi + + echo "Enabling icingaweb2 module '%{module_name}'" + ln -svf /usr/share/icingaweb2/modules/%{module_name} /etc/icingaweb2/enabledModules/%{module_name} +fi + +exit 0 + +%preun +set -e + +# Only for removal +if [ $1 == 0 ]; then + echo "Disabling icingaweb2 module '%{module_name}'" + rm -f /etc/icingaweb2/enabledModules/%{module_name} +fi + +exit 0 + %files %doc README.md LICENSE From de3c6aeb9a34fd8dea1cfb56088687f4f7ab2c86 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 2 May 2019 16:45:50 +0200 Subject: [PATCH 2/9] ci: Update Fedora builds --- .gitlab-ci.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f3078bc..11b98de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,6 +83,23 @@ upload/epel/6: ################################### # Fedora ################################### +build/fedora/30: + <<: *build + variables: + DOCKER_IMAGE: fedora/30 + +test/fedora/30: + <<: *test + variables: + DOCKER_IMAGE: fedora/30 + dependencies: + - build/fedora/30 + +upload/fedora/30: + <<: *upload + dependencies: + - build/fedora/30 + build/fedora/29: <<: *build variables: @@ -100,23 +117,6 @@ upload/fedora/29: dependencies: - build/fedora/29 -build/fedora/28: - <<: *build - variables: - DOCKER_IMAGE: fedora/28 - -test/fedora/28: - <<: *test - variables: - DOCKER_IMAGE: fedora/28 - dependencies: - - build/fedora/28 - -upload/fedora/28: - <<: *upload - dependencies: - - build/fedora/28 - ################################### # SLES ################################### From eb2b61d7ea3810754086cd59bf2a3a9ea4964171 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 2 May 2019 16:49:40 +0200 Subject: [PATCH 3/9] ci: Update config - Upload snapshots - Cache git clone --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 11b98de..69648d3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ variables: key: "${CI_JOB_NAME}" paths: - ccache/ - - 'icinga2.git' + - 'icinga*.git' artifacts: paths: - build/* @@ -41,6 +41,7 @@ variables: - find build/ - icinga-build-upload-aptly only: + - master - tags ################################### From bc520d32572f8cf1a129c3dc6c8a1efbd21897c8 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 30 Aug 2019 14:44:06 +0200 Subject: [PATCH 4/9] ci: Update os matrix --- .gitlab-ci.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69648d3..d49c5d4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ variables: key: "${CI_JOB_NAME}" paths: - ccache/ - - 'icinga*.git' + - 'icingaweb2-module-director.git' artifacts: paths: - build/* @@ -155,23 +155,6 @@ upload/SUSE/12.4: dependencies: - build/sles/12.4 -build/sles/12.3: - <<: *build - variables: - DOCKER_IMAGE: sles/12.3 - -test/sles/12.3: - <<: *test - variables: - DOCKER_IMAGE: sles/12.3 - dependencies: - - build/sles/12.3 - -upload/SUSE/12.3: - <<: *upload - dependencies: - - build/sles/12.3 - ################################### # openSUSE ################################### From e0f85c90280932fed1b75c6afb8bd1bd454e4ef5 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 30 Aug 2019 16:45:06 +0200 Subject: [PATCH 5/9] Add systemd service --- icinga-director.service | 11 +++++++ icingaweb2-module-director.spec | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 icinga-director.service diff --git a/icinga-director.service b/icinga-director.service new file mode 100644 index 0000000..eba815b --- /dev/null +++ b/icinga-director.service @@ -0,0 +1,11 @@ +[Unit] +Description=Icinga Director Job runner + +[Service] +Type=simple +User=icingaweb2 +ExecStart=/usr/bin/icingacli director jobs run --forever +Restart=on-success + +[Install] +WantedBy=multi-user.target diff --git a/icingaweb2-module-director.spec b/icingaweb2-module-director.spec index e940951..53443d9 100644 --- a/icingaweb2-module-director.spec +++ b/icingaweb2-module-director.spec @@ -14,10 +14,15 @@ Group: Applications/System License: GPLv2+ URL: https://icinga.com Source0: https://github.com/Icinga/icingaweb2-module-%{module_name}/archive/v%{version}.tar.gz +Source1: %{service_name}.service #/icingaweb2-module-%{module_name}-%{version}.tar.gz BuildArch: noarch %global basedir %{_datadir}/icingaweb2/modules/%{module_name} +%global service_name icinga-%{module_name} + +BuildRequires: systemd-devel +Requires: systemd Requires: icingaweb2 >= %{icingaweb_min_version} Requires: php-Icinga >= %{icingaweb_min_version} @@ -43,9 +48,24 @@ mkdir -p %{buildroot}%{basedir} cp -r * %{buildroot}%{basedir} +install -d %{buildroot}%{_unitdir} +install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{service_name}.service + +%if "%{_vendor}" == "suse" +install -d %{buildroot}%{_sbindir} +ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{service_name} +%endif # suse + %clean rm -rf %{buildroot} +%pre +%if "%{_vendor}" == "suse" + %service_add_pre %{service_name}.service +%endif # suse + +exit 0 + %post set -e @@ -60,11 +80,23 @@ if [ $1 == 1 ]; then ln -svf /usr/share/icingaweb2/modules/%{module_name} /etc/icingaweb2/enabledModules/%{module_name} fi +%if "%{_vendor}" == "suse" + %service_add_post %{service_name}.service +%else # suse +%systemd_post %{service_name}.service +%endif # suse + exit 0 %preun set -e +%if "%{_vendor}" == "suse" + %service_del_preun %{service_name}.service +%else # suse + %systemd_preun %{service_name}.service +%endif # suse + # Only for removal if [ $1 == 0 ]; then echo "Disabling icingaweb2 module '%{module_name}'" @@ -73,13 +105,33 @@ fi exit 0 +%postun +set -e + +%if "%{_vendor}" == "suse" + %service_del_postun %{service_name}.service +%else # suse + %systemd_postun_with_restart %{service_name}.service +%endif # suse + +exit 0 + %files %doc README.md LICENSE %defattr(-,root,root) %{basedir} +%{_unitdir}/%{service_name}.service + +%if "%{_vendor}" == "suse" +%{_sbindir}/rc%{service_name} +%endif # suse + %changelog +* Fri Aug 30 2019 Markus Frosch - 1.6.2-2 +- Add icinga-director service + * Thu May 02 2019 Markus Frosch - 1.6.2-1 - Update packaging - Update to 1.6.2 From b65bbbbc16280b5fca6154efa057321c50783fde Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 30 Aug 2019 16:56:14 +0200 Subject: [PATCH 6/9] Remove EPEL 6 from the build matrix --- .gitlab-ci.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d49c5d4..4fb33b2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,23 +64,6 @@ upload/epel/7: dependencies: - build/centos/7 -build/centos/6: - <<: *build - variables: - DOCKER_IMAGE: centos/6 - -test/centos/6: - <<: *test - variables: - DOCKER_IMAGE: centos/6 - dependencies: - - build/centos/6 - -upload/epel/6: - <<: *upload - dependencies: - - build/centos/6 - ################################### # Fedora ################################### From 76acef5648a00664a796a82b52593f5a12203d90 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Mon, 9 Sep 2019 14:38:24 +0200 Subject: [PATCH 7/9] Use correct username for service --- icinga-director.service | 2 +- icingaweb2-module-director.spec | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/icinga-director.service b/icinga-director.service index eba815b..13d89a9 100644 --- a/icinga-director.service +++ b/icinga-director.service @@ -3,7 +3,7 @@ Description=Icinga Director Job runner [Service] Type=simple -User=icingaweb2 +User=apache ExecStart=/usr/bin/icingacli director jobs run --forever Restart=on-success diff --git a/icingaweb2-module-director.spec b/icingaweb2-module-director.spec index 53443d9..b90d47e 100644 --- a/icingaweb2-module-director.spec +++ b/icingaweb2-module-director.spec @@ -21,6 +21,12 @@ BuildArch: noarch %global basedir %{_datadir}/icingaweb2/modules/%{module_name} %global service_name icinga-%{module_name} +%if "%{_vendor}" == "suse" +%global service_user wwwrun +%else # suse +%global service_user apache +%endif # suse + BuildRequires: systemd-devel Requires: systemd @@ -51,6 +57,9 @@ cp -r * %{buildroot}%{basedir} install -d %{buildroot}%{_unitdir} install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{service_name}.service +# Replace user in service unit +sed -i -e 's~^User=.*~User=%{service_user}~' %{buildroot}%{_unitdir}/%{service_name}.service + %if "%{_vendor}" == "suse" install -d %{buildroot}%{_sbindir} ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{service_name} From 563510d385752dbc9c5d5caf4ffc899fdf44413e Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Mon, 9 Sep 2019 16:27:40 +0200 Subject: [PATCH 8/9] Fix changelog --- icingaweb2-module-director.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icingaweb2-module-director.spec b/icingaweb2-module-director.spec index b90d47e..5f28528 100644 --- a/icingaweb2-module-director.spec +++ b/icingaweb2-module-director.spec @@ -138,7 +138,7 @@ exit 0 %endif # suse %changelog -* Fri Aug 30 2019 Markus Frosch - 1.6.2-2 +* Fri Aug 30 2019 Markus Frosch - 1.6.2-1 - Add icinga-director service * Thu May 02 2019 Markus Frosch - 1.6.2-1 From fe3d88f71a4b383c948e519bdc0e5085ef115138 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Mon, 9 Sep 2019 16:32:50 +0200 Subject: [PATCH 9/9] Release version 1.6.2-1 --- icingaweb2-module-director.spec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/icingaweb2-module-director.spec b/icingaweb2-module-director.spec index 5f28528..ee8b386 100644 --- a/icingaweb2-module-director.spec +++ b/icingaweb2-module-director.spec @@ -138,6 +138,9 @@ exit 0 %endif # suse %changelog +* Mon Sep 09 2019 Markus Frosch - 1.6.2-1 +- Release version 1.6.2-1 + * Fri Aug 30 2019 Markus Frosch - 1.6.2-1 - Add icinga-director service