Blame SPECS/redhat-cloud-client-configuration.spec

dfd011
Name:           redhat-cloud-client-configuration
dfd011
Version:        1
dfd011
Release:        10%{?dist}
dfd011
Summary:        Red Hat cloud client configuration
dfd011
License:        GPLv2+
dfd011
URL:            https://github.com/RedHatInsights/redhat-cloud-client-configuration
dfd011
dfd011
Source0: insights-register.path.in
dfd011
Source1: insights-register.service.in
dfd011
Source2: insights-unregister.path.in
dfd011
Source3: insights-unregister.service.in
dfd011
Source4: 80-insights-register.preset
dfd011
Source5: insights-unregistered.path.in
dfd011
Source6: insights-unregistered.service.in
dfd011
Source7: rhcd.path.in
dfd011
Source8: rhcd-stop.path.in
dfd011
Source9: rhcd-stop.service.in
dfd011
Source10: 80-rhcd-register.preset
dfd011
Source11: LICENSE
dfd011
dfd011
BuildArch:      noarch
dfd011
dfd011
Requires:      insights-client
dfd011
Requires:      subscription-manager
dfd011
dfd011
%if 0%{?rhel} >= 8
dfd011
Requires:      rhc
dfd011
%endif
dfd011
dfd011
BuildRequires: systemd
dfd011
dfd011
%description
dfd011
Configure client autoregistration for cloud environments
dfd011
dfd011
%prep
dfd011
# we have no source
dfd011
dfd011
dfd011
%build
dfd011
# insights-client
dfd011
sed -e 's|@sysconfdir@|%{_sysconfdir}|g' %{SOURCE0} > insights-register.path
dfd011
sed -e 's|@bindir@|%{_bindir}|g' %{SOURCE1} > insights-register.service
dfd011
sed -e 's|@sysconfdir@|%{_sysconfdir}|g' %{SOURCE2} > insights-unregister.path
dfd011
sed -e 's|@sysconfdir@|%{_sysconfdir}|g' -e 's|@bindir@|%{_bindir}|g' %{SOURCE3} > insights-unregister.service
dfd011
sed -e 's|@sysconfdir@|%{_sysconfdir}|g' %{SOURCE5} > insights-unregistered.path
dfd011
sed -e 's|@sysconfdir@|%{_sysconfdir}|g' %{SOURCE6} > insights-unregistered.service
dfd011
dfd011
%if 0%{?rhel} >= 8
dfd011
# rhcd
dfd011
sed -e 's|@sysconfdir@|%{_sysconfdir}|g' %{SOURCE7} > rhcd.path
dfd011
sed -e 's|@sysconfdir@|%{_sysconfdir}|g' %{SOURCE8} > rhcd-stop.path
dfd011
sed -e 's|@sysconfdir@|%{_sysconfdir}|g' %{SOURCE9} > rhcd-stop.service
dfd011
%endif
dfd011
dfd011
%install
dfd011
# insights-client
dfd011
install -d %{buildroot}%{_unitdir}
dfd011
install -m644 insights-register.path    %{buildroot}%{_unitdir}/
dfd011
install -m644 insights-register.service %{buildroot}%{_unitdir}/
dfd011
install -m644 insights-unregister.path    %{buildroot}%{_unitdir}/
dfd011
install -m644 insights-unregister.service %{buildroot}%{_unitdir}/
dfd011
install -m644 insights-unregistered.path %{buildroot}%{_unitdir}/
dfd011
install -m644 insights-unregistered.service %{buildroot}%{_unitdir}/
dfd011
install -d %{buildroot}%{_presetdir}
dfd011
install -m644 %{SOURCE4} -t %{buildroot}%{_presetdir}/
dfd011
dfd011
%if 0%{?rhel} >= 8
dfd011
# rhcd
dfd011
install -D -m644 rhcd.path %{buildroot}%{_unitdir}/
dfd011
install -D -m644 rhcd-stop.path %{buildroot}%{_unitdir}/
dfd011
install -D -m644 rhcd-stop.service %{buildroot}%{_unitdir}/
dfd011
install -m644 %{SOURCE10} -t %{buildroot}%{_presetdir}/
dfd011
%endif
dfd011
dfd011
%post
dfd011
# insights-client
dfd011
%systemd_post insights-register.path
dfd011
%systemd_post insights-unregister.path
dfd011
%systemd_post insights-unregistered.path
dfd011
#rhcd
dfd011
%if 0%{?rhel} >= 8
dfd011
%systemd_post rhcd.path
dfd011
%systemd_post rhcd-stop.path
dfd011
%endif
dfd011
dfd011
# Make sure that rhsmcertd.service is enabled and running
dfd011
%systemd_post rhsmcertd.service
dfd011
# Run following block only during installation (not during update)
dfd011
if [ $1 -eq 1 ]; then
dfd011
    # Try to get current value of auto-registration in rhsm.conf
dfd011
    subscription-manager config --list | grep -q '^[ \t]*auto_registration[ \t]*=[ \t]*1'
dfd011
    if [ $? -eq 0 ]; then
dfd011
        auto_reg_enabled=1
dfd011
    else
dfd011
        auto_reg_enabled=0
dfd011
    fi
dfd011
dfd011
    # Try to get current value of manage_repos
dfd011
    subscription-manager config --list | grep -q '^[ \t]*manage_repos[ \t]*=[ \t]*0'
dfd011
    if [ $? -eq 0 ]; then
dfd011
        manage_repos_enabled=0
dfd011
    else
dfd011
        manage_repos_enabled=1
dfd011
    fi
dfd011
dfd011
    # When we are going to change any configuration value, then save original rhsm.conf
dfd011
    if [ $auto_reg_enabled -eq 0 -o $manage_repos_enabled -eq 1 ]; then
dfd011
        echo -e "#\n# Automatic backup of rhsm.conf created by %{name} installation script\n#\n" \
dfd011
            > /etc/rhsm/rhsm.conf.cloud_save
dfd011
        cat /etc/rhsm/rhsm.conf >> /etc/rhsm/rhsm.conf.cloud_save
dfd011
    fi
dfd011
dfd011
    # Enable auto-registration in rhsm.conf
dfd011
    if [ $auto_reg_enabled -eq 0 ]; then
dfd011
        subscription-manager config --rhsmcertd.auto_registration=1
dfd011
    fi
dfd011
dfd011
    # Disable management of redhat.repo on systems running in
dfd011
    # public cloud, because content is provided by RHUI
dfd011
    if [ $manage_repos_enabled -eq 1 ]; then
dfd011
        subscription-manager config --rhsm.manage_repos=0
dfd011
    fi
dfd011
dfd011
    # Restart rhsmcertd to reload configuration file, when it is necessary
dfd011
    if [ $auto_reg_enabled -eq 0 -o $manage_repos_enabled -eq 1 ]; then
dfd011
        /bin/systemctl restart rhsmcertd.service
dfd011
    fi
dfd011
fi
dfd011
dfd011
%preun
dfd011
if [ $1 -eq 0 ]; then
dfd011
    # Packager removal, unmask register if exists
dfd011
    /bin/systemctl unmask --now insights-register.path > /dev/null 2>&1 || :
dfd011
%if 0%{?rhel} >= 8
dfd011
    /bin/systemctl unmask --now rhcd.path > /dev/null 2>&1 || :
dfd011
%endif
dfd011
fi
dfd011
%systemd_preun insights-register.path
dfd011
%systemd_preun insights-unregister.path
dfd011
%systemd_preun insights-unregistered.path
dfd011
dfd011
%if 0%{?rhel} >= 8
dfd011
%systemd_preun rhcd.path
dfd011
%systemd_preun rhcd-stop.path
dfd011
%endif
dfd011
dfd011
%postun
dfd011
%systemd_postun insights-register.path
dfd011
%systemd_postun insights-unregister.path
dfd011
%systemd_postun insights-unregistered.path
dfd011
dfd011
%if 0%{?rhel} >= 8
dfd011
%systemd_postun rhcd.path
dfd011
%systemd_postun rhcd-stop.path
dfd011
%endif
dfd011
dfd011
dfd011
if [ $1 -eq 0 ]; then
dfd011
    if [ -f /etc/rhsm/rhsm.conf.cloud_save ]; then
dfd011
        rhsmcertd_restart_required=0
dfd011
dfd011
        # When auto-registration was originally disabled and we had
dfd011
        # to enable it during installation of this RPM, then disable it
dfd011
        # again during removal of RPM package to restore original state.
dfd011
        grep -q '^[ \t]*auto_registration[ \t]*=[ \t]*0' /etc/rhsm/rhsm.conf.cloud_save
dfd011
        if [ $? -eq 0 ]; then
dfd011
            subscription-manager config --rhsmcertd.auto_registration=0
dfd011
            rhsmcertd_restart_required=1
dfd011
        fi
dfd011
dfd011
        # When managing was originally enabled, then enable it again
dfd011
        grep -q '^[ \t]*manage_repos[ \t]*=[ \t]*1' /etc/rhsm/rhsm.conf.cloud_save
dfd011
        if [ $? -eq 0 ]; then
dfd011
            subscription-manager config --rhsm.manage_repos=1
dfd011
            rhsmcertd_restart_required=1
dfd011
        fi
dfd011
dfd011
        # Restart rhsmcertd to propagate change in rhsm.conf
dfd011
        if [ $rhsmcertd_restart_required -eq 1 ]; then
dfd011
            %systemd_postun_with_restart rhsmcertd.service
dfd011
        fi
dfd011
dfd011
        # Script should clean up after itself
dfd011
        rm -f /etc/rhsm/rhsm.conf.cloud_save
dfd011
    fi
dfd011
fi
dfd011
dfd011
dfd011
%files
dfd011
%{_unitdir}/*
dfd011
%{_presetdir}/*
dfd011
dfd011
dfd011
%changelog
dfd011
* Fri Sep 16 2022 Gael Chamoulaud <gchamoul@redhat.com> - 1-10
dfd011
- Remove preset files from %post directive
dfd011
dfd011
* Wed Jul 06 2022 Gaël Chamoulaud <gchamoul@redhat.com> - 1-9
dfd011
- Add LICENSE file
dfd011
dfd011
* Mon Jul 04 2022 Gaël Chamoulaud <gchamoul@redhat.com> - 1-8
dfd011
- Fix bad date format in Changelog
dfd011
dfd011
* Mon Jul 04 2022 Gaël Chamoulaud <gchamoul@redhat.com> - 1-7
dfd011
- Remove conditional for rhcd sources
dfd011
- Fix: systemctl absolute path for rhel7
dfd011
dfd011
* Thu Jun 30 2022 Gaël Chamoulaud <gchamoul@redhat.com> - 1-6
dfd011
- Split preset insights-client and rhcd. RHEL7 compatibility.
dfd011
- Add autoregistration when insights-client manually unregister
dfd011
dfd011
* Thu Jun 30 2022 Gaël Chamoulaud <gchamoul@redhat.com> - 1-5
dfd011
- Disable RHSM config option manage_repos during installation
dfd011
- Enable rhcd auto-enablement only for RHEL>=8
dfd011
dfd011
* Thu Jun 23 2022 Gaël Chamoulaud <gchamoul@redhat.com> - 1-4
dfd011
- Add gating.yaml file
dfd011
dfd011
* Thu Jun 23 2022 Gaël Chamoulaud <gchamoul@redhat.com> - 1-3
dfd011
- Fix - Executable path is not absolute, ignoring: systemctl
dfd011
dfd011
* Thu Jun 16 2022 Gaël Chamoulaud <gchamoul@redhat.com> - 1-2
dfd011
- fix - remove .in suffix from rhcd unit files
dfd011
- remove rhcd-override.conf
dfd011
- add rhcd path files to monitor existence of cert file + add rhcd stop service file which can stop rhcd when system is unsubscribed
dfd011
dfd011
* Tue May 31 2022 Link Dupont <link@redhat.com> - 1-1
dfd011
- fix up some spec file descriptions
dfd011
- add override to automatically activate rhcd
dfd011
dfd011
* Tue May 17 2022 Alba Hita Catala <ahitacat@redhat.com> - 1-1
dfd011
- insights-client autoregistration