File postgresql-init.spec of Package postgresql-init

#
# spec file for package postgresql-init
#
# Copyright (c) 2015 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
BuildRequires:  pwdutils
BuildRequires:  systemd
%{?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 init script, 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/etc/init.d
install -m755 %{S:0} %buildroot/etc/init.d/postgresql

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/usr/sbin
ln -sf /etc/init.d/postgresql %buildroot/usr/sbin/rcpostgresql

%pre
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
systemd-tmpfiles --create postgresql.conf
test -x /bin/systemctl && /bin/systemctl daemon-reload || :

%preun
%stop_on_removal postgresql

%postun
%insserv_cleanup
test -x /bin/systemctl && /bin/systemctl daemon-reload || :

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

%changelog
openSUSE Build Service is sponsored by