File osem-service.spec of Package osem-service

#
# spec file for package osem-service
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define run_as_user   osem
%define run_as_group  users
Name:           osem-service
Version:        0.1
Release:        0
Summary:        Package for deploying event.opensuse.org
License:        GPL-2.0-only
Group:          Productivity/Networking/Web/Utilities
URL:            https://event.opensuse.org
Source0:        osem.service
Source1:        osem-dj.service
Source2:        vhost-osem.conf
Source4:        osem-service.logrotate
BuildRequires:  systemd-rpm-macros
# for paperclip
Requires:       ImageMagick
# as reverse proxy
Requires:       apache2-prefork
# used on the host
Requires:       curl
# for compiling gems
Requires:       gcc
Requires:       glibc-devel
Requires:       glibc-locale
Requires:       hostname
Requires:       krb5-devel
Requires:       libyaml-devel
# for building the database gems
Requires:       libmariadb-devel
# for building the nokogiri gem
Requires:       libxml2-devel
Requires:       libxslt-devel
Requires:       make
# as javascript engine
Requires:       nodejs14
Requires:       postgresql16-devel postgresql16-server-devel
Requires:       psmisc
Requires:       ruby3.3-devel
Requires:       sqlite3-devel
Requires:       sudo
Requires:       timezone
Requires:       vim
Requires:       vim-data
# FIXME: use proper Requires(pre/post/preun/...)
PreReq:         %{_sbindir}/groupadd
PreReq:         %{_sbindir}/useradd
BuildArch:      noarch

%description
This package includes the systemd service for the application and the apache
reverse proxy configuration.

%prep

%build

%install
mkdir -p %{buildroot}%{_unitdir}/
install -m 644 %{SOURCE0} %{buildroot}%{_unitdir}/
install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}/
mkdir -p %{buildroot}%{_sysconfdir}/apache2/vhosts.d
install -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/apache2/vhosts.d
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
install -m 600 %{SOURCE4} %{buildroot}%{_sysconfdir}/logrotate.d/osem-service

%pre
%{_sbindir}/groupadd -r %{run_as_group} &>/dev/null || :
%{_sbindir}/useradd -g %{run_as_group} -s /bin/sh -r -m -c "osem.suse.com" %{run_as_user} &>/dev/null || :
%service_add_pre osem.service
%service_add_pre osem-dj.service

%post
%service_add_post osem.service
%service_add_post osem-dj.service

%preun
%service_del_preun osem.service
%service_del_preun osem-dj.service

%postun
%restart_on_update osem.service
%restart_on_update osem-dj.service
%service_del_postun osem.service
%service_del_postun osem-dj.service

%files
%defattr(-,root,root)
%{_unitdir}/osem.service
%{_unitdir}/osem-dj.service
%dir %{_sysconfdir}/apache2
%dir %{_sysconfdir}/apache2/vhosts.d
%config(noreplace) %{_sysconfdir}/apache2/vhosts.d/vhost-osem.conf
%{_sysconfdir}/logrotate.d/osem-service

%changelog
openSUSE Build Service is sponsored by