From dec89882b3c346caa6f038e88d67f041c431dbe7 Mon Sep 17 00:00:00 2001 From: Nicolas MASSE Date: Sun, 30 May 2021 21:38:37 +0200 Subject: [PATCH] new service: wimip --- rpmbuild/SOURCES/wimip.env | 1 + rpmbuild/SOURCES/wimip.service | 13 ++++++++ rpmbuild/SPECS/wimip.spec | 58 ++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 rpmbuild/SOURCES/wimip.env create mode 100644 rpmbuild/SOURCES/wimip.service create mode 100644 rpmbuild/SPECS/wimip.spec diff --git a/rpmbuild/SOURCES/wimip.env b/rpmbuild/SOURCES/wimip.env new file mode 100644 index 0000000..5e6d553 --- /dev/null +++ b/rpmbuild/SOURCES/wimip.env @@ -0,0 +1 @@ +WIMIP_LISTENADDR=:8585 diff --git a/rpmbuild/SOURCES/wimip.service b/rpmbuild/SOURCES/wimip.service new file mode 100644 index 0000000..0b3d4cc --- /dev/null +++ b/rpmbuild/SOURCES/wimip.service @@ -0,0 +1,13 @@ +[Unit] +Description=What is my IP address? +Wants=network.target +After=network-online.target + +[Service] +Restart=always +Type=simple +EnvironmentFile=/opt/wimip/etc/wimip.env +ExecStart=/opt/wimip/bin/wimip + +[Install] +WantedBy=multi-user.target default.target diff --git a/rpmbuild/SPECS/wimip.spec b/rpmbuild/SPECS/wimip.spec new file mode 100644 index 0000000..450e19c --- /dev/null +++ b/rpmbuild/SPECS/wimip.spec @@ -0,0 +1,58 @@ +%global goipath github.com/nmasse-itix/wimip +Version: 0.0.2 + +%gometa + +%global common_description %{expand: What is my IP address?} + +Name: wimip +Release: itix1 +Summary: What is my IP address? +License: MIT +ExclusiveArch: x86_64 +URL: %{gourl} +Source0: %{gosource} +Source1: wimip.service +Source2: wimip.env +BuildRequires: systemd + +# Not (yet ?) in CentOS Stream 8... +#BuildRequires: go-rpm-macros + +%description +%{common_description} + +%global _missing_build_ids_terminate_build 0 +%global _build_id_links none +%global debug_package %{nil} + +%prep +%setup # CentOS Stream 8 does not (yet ?) have the %goprep macro +cp %{S:1} %{name}.service +cp %{S:2} %{name}.env + +%build +CGO_ENABLED=0 GO111MODULE=on go build -o %{gobuilddir}/wimip %{goipath} + +%install + +install -D %{gobuilddir}/wimip %{buildroot}/opt/wimip/bin/wimip +install -D -m 0644 %{name}.service %{buildroot}%{_unitdir}/%{name}.service +install -D -m 0644 %{name}.env %{buildroot}/opt/wimip/etc/%{name}.env + +%files +%attr(0755, root, root) /opt/wimip/bin/wimip +%defattr(0644, root, root, 0755) +%{_unitdir}/%{name}.service +%config(noreplace) /opt/wimip/etc/%{name}.env + +%post +%systemd_post %{name}.service + +%preun +%systemd_preun %{name}.service + +%postun +%systemd_postun_with_restart %{name}.service + +%changelog