netoik-cicd/netoik-cicd.spec

104 lines
3.1 KiB
Plaintext
Raw Permalink Normal View History

2023-02-18 12:49:35 +00:00
%define debug_package %{nil}
Name: %(make name)
2023-02-18 12:49:35 +00:00
Version: %(make version)
Release: 1%{?dist}
Summary: Netoik Continuous Integration & Deployment tool
2023-02-18 12:49:35 +00:00
License: GPLv3
Source0: %{name}-%{version}.tar.gz
BuildArch: x86_64
BuildRequires: make
2023-04-15 14:27:02 +00:00
Requires: bash,inotify-tools,jq,nmap-ncat,rpm-build,rpmdevtools,ShellCheck
2023-02-18 12:49:35 +00:00
%description
Netoik Continuous Deployment tool
%prep
%autosetup -v
%build
%make_build
%install
%make_install
%pre
# Create users runner and deployer.
if ! getent group %{name}-git-runner; then
groupadd %{name}-git-runner
usermod --append --groups %{name}-git-runner git
fi
if ! getent group %{name}-runner-deployer; then
groupadd %{name}-runner-deployer
fi
if ! id %{name}-runner; then
useradd --create-home \
--home-dir %{_var}/%{name}-runner \
--shell=%{_bindir}/rpmdev-setuptree \
--groups %{name}-git-runner,%{name}-runner-deployer \
--user-group \
%{name}-runner
runuser --login %{name}-runner
fi
if ! id %{name}-deployer; then
useradd --no-create-home \
--home-dir %{_var}/%{name}/deployer \
--shell=%{_sbindir}/nologin \
--groups %{name}-runner-deployer,wheel \
--user-group \
%{name}-deployer
fi
2023-02-18 12:49:35 +00:00
%post
# Reload systemctl daemon.
2023-02-18 12:49:35 +00:00
systemctl daemon-reload
# Restart deployer service.
systemctl stop %{name}-deployer.service
rm --force %{_rundir}/%{name}/deployer/deployer.sock
systemctl start %{name}-deployer.service
2023-02-18 12:49:35 +00:00
systemctl enable %{name}-deployer.service
# Restart runner service.
systemctl stop %{name}-runner.service
rm --force %{_rundir}/%{name}/runner/runner.sock
systemctl start %{name}-runner.service
systemctl enable %{name}-runner.service
2023-02-18 12:49:35 +00:00
%preun
# Stop service only if uninstalling.
if [ $1 -eq 0 ]; then
systemctl disable --now %{name}-deployer.service
rm --force %{_rundir}/%{name}/deployer/deployer.sock
systemctl disable --now %{name}-runner.service
rm --force %{_rundir}/%{name}/runner/runner.sock
2023-02-18 12:49:35 +00:00
fi
%postun
# Reload systemctl daemon only and remove users if uninstalling.
2023-02-18 12:49:35 +00:00
if [ $1 -eq 0 ]; then
systemctl daemon-reload
userdel %{name}-deployer || true
userdel --remove %{name}-runner || true
groupdel %{name}-git-runner || true
groupdel %{name}-runner-deployer || true
2023-02-18 12:49:35 +00:00
fi
%files
%attr(755, root, root) %dir %{_sysconfdir}/%{name}
%attr(644, root, root) %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%attr(644, root, root) %{_sysconfdir}/%{name}/%{name}.conf.sample
%attr(644, root, root) %config(noreplace) %{_sysconfdir}/%{name}/errors.conf
%attr(644, root, root) %{_sysconfdir}/%{name}/errors.conf.sample
2023-02-18 12:49:35 +00:00
%attr(644, root, root) %{_unitdir}/%{name}-deployer.service
%attr(644, root, root) %{_unitdir}/%{name}-runner.service
2023-02-18 12:49:35 +00:00
%attr(755, root, root) %{_bindir}/%{name}-deployer
%attr(755, root, root) %{_bindir}/%{name}-runner
%attr(755, root, root) %{_bindir}/%{name}-pipeline
%attr(755, root, root) %dir %{_rundir}/%{name}
%attr(755, %{name}-deployer, %{name}-deployer) %dir %{_rundir}/%{name}/deployer
%attr(755, git, git) %dir %{_rundir}/%{name}/pipeline
%attr(755, %{name}-runner, %{name}-runner) %dir %{_rundir}/%{name}/runner
2023-02-18 12:49:35 +00:00
%attr(755, root, root) %dir %{_tmppath}/%{name}
%attr(755, %{name}-runner, %{name}-runner) %dir %{_tmppath}/%{name}/repositories