diff --git a/init.d/restraintd.service b/init.d/restraintd.service index eac63c11..eb1b9b91 100644 --- a/init.d/restraintd.service +++ b/init.d/restraintd.service @@ -8,6 +8,7 @@ Type=simple StandardError=journal+console ExecStartPre=/usr/bin/check_beaker ExecStart=/usr/bin/restraintd --port 8081 +StateDirectory=restraint KillMode=process OOMScoreAdjust=-1000 OOMPolicy=continue diff --git a/legacy/Makefile b/legacy/Makefile index 7204effe..af4d1bd5 100644 --- a/legacy/Makefile +++ b/legacy/Makefile @@ -10,7 +10,7 @@ clean: .PHONY: install install: set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install; done - install -m 644 data/install_config $(DESTDIR)/var/lib/restraint/ + install -m 644 -D data/install_config $(DESTDIR)/etc/restraint/install_config .PHONY: check check: diff --git a/plugins/pkg_commands.d/centos b/plugins/pkg_commands.d/centos new file mode 100644 index 00000000..4b379d24 --- /dev/null +++ b/plugins/pkg_commands.d/centos @@ -0,0 +1,13 @@ +#!/bin/bash + +. /etc/os-release + +if [ -f "/run/ostree-booted" ];then + # OSTree based filesystems are read-only and install with rpm-ostree + RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-rpm-ostree} + RSTRNT_PKG_ARGS=${RSTRNT_PKG_ARGS:--y --idempotent --allow-inactive} + RSTRNT_PKG_INSTALL=${RSTRNT_PKG_INSTALL:-install --apply-live} +elif [ 0"$(echo $VERSION_ID | cut -d'.' -f1)" -ge 8 ]; then + # CentOS 8 and newer use dnf as default + RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-dnf} +fi diff --git a/plugins/pkg_commands.d/fedora b/plugins/pkg_commands.d/fedora index 85f255da..af06f3ee 100644 --- a/plugins/pkg_commands.d/fedora +++ b/plugins/pkg_commands.d/fedora @@ -2,7 +2,12 @@ . /etc/os-release -# Fedora 22 and newer use dnf as default -if [ 0"$VERSION_ID" -gt 21 ]; then +if [ -f "/run/ostree-booted" ]; then + # OSTree based filesystems are read-only and install with rpm-ostree + RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-rpm-ostree} + RSTRNT_PKG_ARGS=${RSTRNT_PKG_ARGS:--y --idempotent --allow-inactive} + RSTRNT_PKG_INSTALL=${RSTRNT_PKG_INSTALL:-install --apply-live} +elif [ 0"$VERSION_ID" -gt 21 ]; then + # Fedora 22 and newer use dnf as default RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-dnf} fi diff --git a/plugins/pkg_commands.d/rhel b/plugins/pkg_commands.d/rhel index cd196edf..1212b255 100644 --- a/plugins/pkg_commands.d/rhel +++ b/plugins/pkg_commands.d/rhel @@ -2,7 +2,12 @@ . /etc/os-release -# RHEL 8 and newer use dnf as default -if [ 0"$(echo $VERSION_ID | cut -d'.' -f1)" -ge 8 ]; then +if [ -f "/run/ostree-booted" ];then + # OSTree based filesystems are read-only and install with rpm-ostree + RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-rpm-ostree} + RSTRNT_PKG_ARGS=${RSTRNT_PKG_ARGS:--y --idempotent --allow-inactive} + RSTRNT_PKG_INSTALL=${RSTRNT_PKG_INSTALL:-install --apply-live} +elif [ 0"$(echo $VERSION_ID | cut -d'.' -f1)" -ge 8 ]; then + # RHEL 8 and newer use dnf as default RSTRNT_PKG_CMD=${RSTRNT_PKG_CMD:-dnf} fi diff --git a/restraint.conf b/restraint.conf new file mode 100644 index 00000000..16967c3b --- /dev/null +++ b/restraint.conf @@ -0,0 +1,3 @@ +# Type Path Mode User Group Age Argument +d /mnt/scratchspace 0777 root root - +d /mnt/testarea 1777 root root - diff --git a/restraint.spec b/restraint.spec index 13c4c334..7ba290dd 100644 --- a/restraint.spec +++ b/restraint.spec @@ -22,6 +22,7 @@ Group: Applications/Internet License: GPLv3+ and MIT URL: https://github.com/beaker-project/%{name} Source0: https://github.com/beaker-project/restraint/archive/%{name}-%{version}.tar.gz +Source1: %{name}.conf %if 0%{?with_static:1} # Sources for bundled, statically linked libraries @@ -249,6 +250,12 @@ fi popd %endif +%if %{with_systemd} +mkdir -p $RPM_BUILD_ROOT/%{_tmpfilesdir} +install -m 0644 %{SOURCE1} $RPM_BUILD_ROOT/%{_tmpfilesdir}/%{name}.conf +%endif + + %post if [ "$1" -le "1" ] ; then # First install %if %{with_systemd} @@ -343,7 +350,12 @@ fi %{_datadir}/selinux/packages/%{name}/restraint.pp %endif +%if %{with_systemd} +# Don't package, systemd will create this on first instance +%exclude /var/lib/%{name} +%else %dir /var/lib/%{name} +%endif %files client %attr(0755, root, root)%{_bindir}/%{name} @@ -362,7 +374,8 @@ fi %attr(0755, root, root)%{_bindir}/rhts-lint %attr(0755, root, root)%{_bindir}/rhts-report-result %attr(0755, root, root)%{_bindir}/rhts-flush -%config(noreplace)/var/lib/%{name}/install_config +%dir %{_sysconfdir}/%{name} +%config(noreplace) %{_sysconfdir}/%{name}/install_config # Symlinks do not have attributes %{_bindir}/rhts-sync-set @@ -381,8 +394,12 @@ fi %{_bindir}/rhts_recipe_sync_block %{_bindir}/rhts-abort %{_datadir}/rhts/lib/rhts-make.include +%if %{with_systemd} +%config %{_tmpfilesdir}/%{name}.conf +%else /mnt/scratchspace %attr(1777,root,root)/mnt/testarea +%endif %if 0%{?rhel}%{?fedora} > 4 %{_datadir}/selinux/packages/%{name}/rhts.pp %endif diff --git a/src/utils.h b/src/utils.h index 23a1f547..dbfd0e5d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -24,7 +24,7 @@ #define CMD_ENV_DIR "/var/lib/restraint" #define CMD_ENV_FILE_FORMAT "%s/rstrnt-commands-env-%u.sh" -#define INSTALL_CONFIG_FILE "/var/lib/restraint/install_config" +#define INSTALL_CONFIG_FILE "/etc/restraint/install_config" #define INSTALL_DIR_VAR "INSTALL_DIR" #define INSTALL_DIR_DEFAULT "/var/lib/restraint/tests"