File postgresql-init.spec of Package postgresql-init.2794

#
# spec file for package postgresql-init
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Url:            http://www.postgresql.org/
Summary:        Init script and other infrastructure for PostgreSQL
License:        PostgreSQL
Group:          Productivity/Databases/Servers

Name:           postgresql-init
Version:        9.4
Release:        0
Source0:        postgresql-init
Source1:        postgresql-sysconfig
Source2:        postgresql-firewall
Source3:        postgresql-tmpfiles.conf
Source4:        postgresql.service
BuildRequires:  pwdutils
%if 0%{?suse_version} >= 1210
BuildRequires:  systemd-rpm-macros
%endif
%{?systemd_requires}
Requires(pre):  pwdutils
Requires(post): %fillup_prereq
Requires(postun): %insserv_prereq
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%if 0%{?suse_version} > 1100
    %define fwdir /etc/sysconfig/SuSEfirewall2.d/services
    %define fwname postgresql
%else
    %define fwdir /etc/sysconfig/scripts
    %define fwname SuSEfirewall2-postgresql
%endif

%description
This package contains the systemd service file, sysconfig template and
firewall service file for the PostgreSQL server. It was separated from
the postgresql*-server binary package to allow parallel installation
of several server versions.

%prep

%build

%install
install -m755 -d %buildroot/usr/lib
install -m755 %{S:0} %buildroot/usr/lib

install -m755 -d %buildroot/var/adm/fillup-templates
install -m644 %{S:1} %buildroot/var/adm/fillup-templates/sysconfig.postgresql

install -m755 -d %buildroot%fwdir
install -m644 %{S:2} %buildroot%fwdir/%fwname

install -m755 -d %buildroot/%_tmpfilesdir
install -m644 %{S:3} %buildroot%_tmpfilesdir/postgresql.conf

install -m755 -d %buildroot%_unitdir
install -m444 %{S:4} %buildroot%_unitdir

install -m755 -d %buildroot/usr/sbin
ln -sf %_sbindir/service %buildroot%_sbindir/rcpostgresql

%pre
%service_add_pre postgresql.service
groupadd -g 26 -o -r postgres >/dev/null 2>/dev/null || :
useradd -g postgres -o -r -d /var/lib/pgsql -s /bin/bash \
	-c "PostgreSQL Server" -u 26 postgres 2>/dev/null || :

%post
%fillup_only -n postgresql
%tmpfiles_create %_tmpfilesdir/postgresql.conf
%service_add_post postgresql.service

%preun
%service_del_preun postgresql.service

%postun
%service_del_postun postgresql.service

%files
%defattr(-,root,root,-)
%_unitdir/*
/usr/lib/*
%dir %fwdir
%config %fwdir/%fwname
/var/adm/fillup-templates/sysconfig.postgresql
/usr/sbin/rcpostgresql
%_tmpfilesdir/postgresql.conf

%changelog
openSUSE Build Service is sponsored by