edgelet/contrib/enterprise-linux/aziot-edge.spec (156 lines of code) (raw):

%define iotedge_user iotedge %define iotedge_group %{iotedge_user} %define iotedge_home %{_localstatedir}/lib/aziot/edged %define iotedge_logdir %{_localstatedir}/log/aziot/edged %define iotedge_socketdir %{_localstatedir}/run/iotedge %define aziot_confdir %{_sysconfdir}/aziot %define iotedge_confdir %{aziot_confdir}/edged %define iotedge_agent_user edgeagentuser %define iotedge_agent_uid 13622 %define iotedge_hub_user edgehubuser %define iotedge_hub_uid 13623 Name: aziot-edge Version: @version@ Release: @release@%{?dist} License: MIT Summary: Azure IoT Edge Module Runtime URL: https://github.com/azure/iotedge %{?systemd_requires} BuildRequires: systemd Requires(pre): shadow-utils Requires: (moby-engine or docker-ce) Requires: aziot-identity-service = 1.5.5-1%{?dist} Source0: aziot-edge-%{version}.tar.gz %description Azure IoT Edge Module Runtime Azure IoT Edge is a fully managed service that delivers cloud intelligence locally by deploying and running artificial intelligence (AI), Azure services, and custom logic directly on cross-platform IoT devices. Run your IoT solution securely and at scale—whether in the cloud or offline. This package contains the IoT Edge daemon and CLI tool. %prep %setup -q %build make \ CONNECT_MANAGEMENT_URI=unix://%{iotedge_socketdir}/mgmt.sock \ CONNECT_WORKLOAD_URI=unix://%{iotedge_socketdir}/workload.sock \ LISTEN_MANAGEMENT_URI=fd://aziot-edged.mgmt.socket \ LISTEN_WORKLOAD_URI=fd://aziot-edged.workload.socket \ release %install rm -rf $RPM_BUILD_ROOT make \ CONNECT_MANAGEMENT_URI=unix://%{iotedge_socketdir}/mgmt.sock \ CONNECT_WORKLOAD_URI=unix://%{iotedge_socketdir}/workload.sock \ LISTEN_MANAGEMENT_URI=fd://aziot-edged.mgmt.socket \ LISTEN_WORKLOAD_URI=fd://aziot-edged.workload.socket \ DESTDIR=$RPM_BUILD_ROOT \ unitdir=%{_unitdir} \ presetdir=%{_presetdir} \ docdir=%{_docdir}/%{name} \ install-rpm %clean rm -rf $RPM_BUILD_ROOT %pre # Create iotedge group if ! /usr/bin/getent group iotedge >/dev/null; then %{_sbindir}/groupadd -r %{iotedge_group} fi # Create iotedge user if ! /usr/bin/getent passwd iotedge >/dev/null; then %{_sbindir}/useradd -r -g %{iotedge_group} -c "iotedge user" -s /sbin/nologin -d %{iotedge_home} %{iotedge_user} fi # Create an edgeagentuser and add it to iotedge group if ! /usr/bin/getent passwd %{iotedge_agent_user} >/dev/null; then %{_sbindir}/useradd -r -g %{iotedge_group} -c "edgeAgent user" -s /sbin/nologin -u %{iotedge_agent_uid} %{iotedge_agent_user} || true fi # Create an edgehubuser if ! getent passwd edgehubuser >/dev/null; then %{_sbindir}/useradd -r -c "edgeHub user" -s /sbin/nologin -u %{iotedge_hub_uid} %{iotedge_hub_user} || true fi # Add iotedge user to aziot-identity-service groups if /usr/bin/getent group aziotcs >/dev/null; then %{_sbindir}/usermod -aG aziotcs %{iotedge_user} fi if /usr/bin/getent group aziotks >/dev/null; then %{_sbindir}/usermod -aG aziotks %{iotedge_user} fi if /usr/bin/getent group aziotid >/dev/null; then %{_sbindir}/usermod -aG aziotid %{iotedge_user} fi exit 0 %post # Check for container runtime if ! /usr/bin/getent group docker >/dev/null; then echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "" echo " ERROR: No container runtime detected." echo "" echo " Please install a container runtime and run this install again." echo "" echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" exit 1 fi # Add iotedge user to moby-engine group if /usr/bin/getent group docker >/dev/null; then %{_sbindir}/usermod -aG docker %{iotedge_user} fi # Add iotedge user to systemd-journal group so it can get system logs if /usr/bin/getent group systemd-journal >/dev/null; then %{_sbindir}/usermod -aG systemd-journal %{iotedge_user} fi if [ ! -f '/etc/aziot/config.toml' ]; then echo "===============================================================================" echo "" echo " Azure IoT Edge" echo "" echo " IMPORTANT: Please configure the device with provisioning information." echo "" if [ -f '/etc/iotedge/config.yaml' ]; then echo " Detected /etc/iotedge/config.yaml from a previously installed version of IoT Edge." echo " You can import the previous configuration using:" echo "" echo " iotedge config import" echo "" echo "Alternatively, copy the configuration file at /etc/aziot/config.toml.edge.template to /etc/aziot/config.toml," else echo "Copy the configuration file at /etc/aziot/config.toml.edge.template to /etc/aziot/config.toml," fi echo " update it with your device information, then apply your configuration changes with:" echo "" echo " iotedge config apply" echo "" echo " You may need to run iotedge config commands with sudo, depending on your environment." echo "" echo "===============================================================================" fi %systemd_post aziot-edged.service %preun %systemd_preun aziot-edged.service %postun %systemd_postun_with_restart aziot-edged.service %files %defattr(-, root, root, -) # bins %{_bindir}/iotedge %{_libexecdir}/aziot/aziot-edged # config %attr(600, root, root) %{aziot_confdir}/config.toml.edge.template %attr(400, %{iotedge_user}, %{iotedge_group}) %{iotedge_confdir}/config.toml.default %attr(700, %{iotedge_user}, %{iotedge_group}) %dir %{iotedge_confdir}/config.d %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} # man %{_mandir}/man1/iotedge.1.gz %{_mandir}/man8/aziot-edged.8.gz # systemd %{_unitdir}/aziot-edged.mgmt.socket %{_unitdir}/aziot-edged.workload.socket %{_unitdir}/aziot-edged.service %{_presetdir}/00-aziot-edged.preset # dirs %attr(-, %{iotedge_user}, %{iotedge_group}) %dir %{iotedge_home} %attr(-, %{iotedge_user}, %{iotedge_group}) %dir %{iotedge_logdir} %doc %{_docdir}/%{name}/LICENSE.gz %doc %{_docdir}/%{name}/ThirdPartyNotices.gz %doc %{_docdir}/%{name}/trademark %changelog