%define debug_package %{nil} Name: %(make name) Version: %(make version) Release: 1%{?dist} Summary: Netoik Continuous Integration & Deployment tool License: GPLv3 Source0: %{name}-%{version}.tar.gz BuildArch: x86_64 BuildRequires: make Requires: bash,inotify-tools,jq,nmap-ncat,rpm-build,rpmdevtools,ShellCheck,shfmt %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 /home/%{name}-runner \ --shell=%{_bindir}/rpmdev-setuptree \ --groups %{name}-git-runner,%{name}-runner-deployer \ --gid %{name}-runner-deployer \ %{name}-runner runuser --login %{name}-runner runuser --login %{name}-runner -- git \ --global user.email %{name}-runner@netoik.io runuser --login %{name}-runner -- git \ --global user.name %{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 %post # Reload systemctl daemon. systemctl daemon-reload # Restart deployer service. systemctl restart %{name}-deployer.service 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 %preun # Stop service only if uninstalling. if [ $1 -eq 0 ]; then systemctl disable --now %{name}-deployer.service systemctl disable --now %{name}-runner.service rm --force %{_rundir}/%{name}/runner/runner.sock fi %postun # Reload systemctl daemon only and remove users if uninstalling. 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 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 %attr(644, root, root) %{_unitdir}/%{name}-deployer.service %attr(644, root, root) %{_unitdir}/%{name}-runner.service %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 %attr(775, %{name}-deployer, %{name}-runner-deployer) %dir %{_rundir}/%{name}/pids %attr(755, root, root) %dir %{_tmppath}/%{name} %attr(755, %{name}-runner, root) %dir %{_tmppath}/%{name}/repositories