|
| 1 | +Summary: Package to deploy azurelinux-sysinfo service |
| 2 | +Name: azurelinux-sysinfo |
| 3 | +Version: 2.0 |
| 4 | +Release: 1%{?dist} |
| 5 | +License: MIT |
| 6 | +Vendor: Microsoft Corporation |
| 7 | +Distribution: Azure Linux |
| 8 | +Group: System Environment/Base |
| 9 | +URL: https://aka.ms/azurelinux |
| 10 | +Source0: collect-sysinfo |
| 11 | +Source1: sysinfo-schema-v1.json |
| 12 | +Source2: azurelinux-sysinfo.service |
| 13 | +Source3: sysinfo-selinuxpolicies.cil |
| 14 | +Requires: systemd |
| 15 | +Requires: python3-psutil |
| 16 | + |
| 17 | +%description |
| 18 | +Deploys a systemd service that gathers system information related to the device, operating system, cloud-init, boot |
| 19 | +time, resource utilization, installed packages, and SELinux mode. Collected information is written in JSON format to |
| 20 | +a log file on the user's system for easy access and analysis. The systemd service runs at boot time if installed during |
| 21 | +image creation. |
| 22 | + |
| 23 | +%install |
| 24 | +# Copy collection python script to /usr/bin/ |
| 25 | +mkdir -p %{buildroot}%{_bindir}/ |
| 26 | +install -m 755 %{SOURCE0} %{buildroot}%{_bindir}/ |
| 27 | + |
| 28 | +# Copy data schema to /usr/share/azurelinux-sysinfo/ |
| 29 | +mkdir -p %{buildroot}%{_datadir}/azurelinux-sysinfo/ |
| 30 | +install -m 755 %{SOURCE1} %{buildroot}%{_datadir}/azurelinux-sysinfo/ |
| 31 | + |
| 32 | +# Copy service to /etc/systemd/system/ |
| 33 | +mkdir -p %{buildroot}%{_sysconfdir}/systemd/system/ |
| 34 | +install -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/systemd/system/ |
| 35 | + |
| 36 | +# Copy the sysinfo-selinuxpolicies file to /usr/share/selinux/packages/ |
| 37 | +mkdir -p %{buildroot}%{_datadir}/selinux/packages/ |
| 38 | +install -m 755 %{SOURCE3} %{buildroot}%{_datadir}/selinux/packages/ |
| 39 | + |
| 40 | +%files |
| 41 | +%{_bindir}/collect-sysinfo |
| 42 | +%dir %{_datadir}/azurelinux-sysinfo/ |
| 43 | +%{_datadir}/azurelinux-sysinfo/sysinfo-schema-v1.json |
| 44 | +%{_sysconfdir}/systemd/system/azurelinux-sysinfo.service |
| 45 | +%{_datadir}/selinux/packages/sysinfo-selinuxpolicies.cil |
| 46 | + |
| 47 | +%post |
| 48 | +#!/bin/sh |
| 49 | +# Enable the systemd service |
| 50 | +systemctl enable azurelinux-sysinfo.service |
| 51 | + |
| 52 | +# Apply required SElinux policies only if selinux-policy is present |
| 53 | +if rpm -q selinux-policy &> /dev/null; then |
| 54 | + semodule -i %{_datadir}/selinux/packages/sysinfo-selinuxpolicies.cil |
| 55 | +fi |
| 56 | + |
| 57 | +%postun |
| 58 | +# If selinux-policy is present, remove the sysinfo-selinuxpolicies module |
| 59 | +if rpm -q selinux-policy &> /dev/null; then |
| 60 | + semodule -r sysinfo-selinuxpolicies |
| 61 | +fi |
| 62 | + |
| 63 | +%changelog |
| 64 | +* Thu Apr 04 2024 Amrita Kohli <amritakohli@microsoft.com> - 2.0-1 |
| 65 | +- License verified. |
| 66 | +- Implementation of package that deploys azurelinux-sysinfo service. |
| 67 | +- Original version for CBL-Mariner. |
| 68 | + |
| 69 | + |
0 commit comments