File qmail-skel.spec of Package qmail-skel

#
# spec file for package qmail-skel
#
# Copyright (c) 2024 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		qdir %{_localstatedir}/qmail
%define		vdir /home/vpopmail
Name:           qmail-skel
Version:        1.1
Release:        0
Summary:        Skeleton for building and running qmail Mail Transfer Agent
License:        GPL-2.0+
Group:          Productivity/Networking/Email/Servers
BuildRequires:  shadow
Requires:       shadow
BuildArch:      noarch

%description
This package installs users and directories as needed by Qmail.

Qmail is a small, fast, secure replacement for the sendmail package, which is
the program that actually receives, routes, and delivers electronic mail.

Vpopmail (vchkpw)  is a collection  of programs  and a library to automate
the creation and maintence of virtual domain email for qmail installations
using either a single UID/GID, or any valid  UID/GID in %{_sysconfdir}/passwd with a
home directory. All the  features  are  provided  in the library for other
applications which need to maintain virtual domain email accounts.

%package devel
Summary:        Development tools for %{name}
Group:          Development/Languages/C and C++
Requires:       %{name} = %{version}-%{release}

%description devel
This package Adds some dummy files to the qmail/vpopmail structure as needed
for compiling

%prep
%setup -q -T -c qmail-base


%build

%install
install -d -m755 %{buildroot}%{qdir}
install -d -m755 %{buildroot}%{qdir}/bin

for i in bin boot control users control/domainkeys; do
  install -d -m755 %{buildroot}%{qdir}/$i
done

install -d -m2755 %{buildroot}%{qdir}/alias

install -d -m750 %{buildroot}%{qdir}/queue
install -d -m750 %{buildroot}%{qdir}/queue/lock
install -d -m750 %{buildroot}%{qdir}/queue/todo

install -d -m700 %{buildroot}%{qdir}/queue/bounce
install -d -m700 %{buildroot}%{qdir}/queue/intd
install -d -m700 %{buildroot}%{qdir}/queue/pid

for d in info local mess remote; do
  for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22; do
    install -d %{buildroot}%{qdir}/queue/$d/$i
  done
done

touch %{buildroot}%{qdir}/queue/lock/sendmutex
touch %{buildroot}%{qdir}/queue/lock/tcpto

mkfifo -m 0622 %{buildroot}%{qdir}/queue/lock/trigger

## vpopmail related directories
install -d -m755 %{buildroot}%{vdir}
install -d -m700 %{buildroot}%{vdir}/domains

%pre
# Add users and groups as per Life With Qmail.
getent group nofiles >/dev/null		|| groupadd -g 2107 -r nofiles
getent group qmail >/dev/null		|| groupadd -g 2108 -r qmail
getent group vchkpw >/dev/null		|| groupadd -g 89   -r vchkpw

getent passwd alias >/dev/null		|| useradd -u 7790 -r -M -d %{qdir}/alias -s /sbin/nologin -c "qmail alias" -g qmail alias
getent passwd qmaild >/dev/null		|| useradd -u 7791 -r -M -d %{qdir} -s /sbin/nologin -c "qmail daemon" -g qmail qmaild
getent passwd qmaill >/dev/null		|| useradd -u 7792 -r -M -d %{qdir} -s /sbin/nologin -c "qmail logger" -g qmail qmaill
getent passwd qmailp >/dev/null		|| useradd -u 7793 -r -M -d %{qdir} -s /sbin/nologin -c "qmail passwd" -g qmail qmailp
getent passwd qmailq >/dev/null		|| useradd -u 7794 -r -M -d %{qdir} -s /sbin/nologin -c "qmail queue" -g qmail qmailq
getent passwd qmailr >/dev/null		|| useradd -u 7795 -r -M -d %{qdir} -s /sbin/nologin -c "qmail remote" -g qmail qmailr
getent passwd qmails >/dev/null		|| useradd -u 7796 -r -M -d %{qdir} -s /sbin/nologin -c "qmail send" -g qmail qmails
getent passwd vpopmail >/dev/null	|| useradd -u 89 -r -M -d %{vdir} -s /sbin/nologin -c "Vpopmail User" -g vchkpw vpopmail
exit 0

%post devel
## files, vpopmail needs to be built
pushd %{qdir}/bin 2>&1 > /dev/null
for TFILE in qmail-newu qmail-inject qmail-newmrh ; do
	if [ ! -e $TFILE ] ; then
		touch $TFILE
	fi
done
popd 2>&1 > /dev/null

%preun devel
## files, vpopmail needs to be built
if [ -d %{qdir}/bin ] ; then
	pushd %{qdir}/bin 2>&1 > /dev/null
	for TFILE in qmail-newu qmail-inject qmail-newmrh ; do
		if [ ! -x $TFILE ] ; then
			rm $TFILE
		fi
	done
	popd 2>&1 > /dev/null
fi

%files
# ### directories
%defattr(0755,root,qmail)
%dir %{qdir}
%dir %{qdir}/bin
%dir %{qdir}/boot
%dir %{qdir}/control
%dir %{qdir}/control/domainkeys
%dir %{qdir}/users

%attr(2755,alias,qmail) %dir %{qdir}/alias
%attr(0750,qmailq,qmail) %dir %{qdir}/queue

# ### qmail queue
%defattr(0700,qmails,qmail)
%dir %{qdir}/queue/bounce
%dir %{qdir}/queue/info
%dir %{qdir}/queue/local
%dir %{qdir}/queue/remote

%dir %{qdir}/queue/info/*
%dir %{qdir}/queue/local/*
%dir %{qdir}/queue/remote/*

%defattr(0700,qmailq,qmail)
%dir %{qdir}/queue/intd
%dir %{qdir}/queue/pid

%defattr(0750,qmailq,qmail)
%dir %{qdir}/queue/lock
%dir %{qdir}/queue/mess
%dir %{qdir}/queue/mess/*
%dir %{qdir}/queue/todo

# ### lock directory
%attr(0622,qmails,qmail)%{qdir}/queue/lock/trigger
%attr(0600,qmails,qmail) %{qdir}/queue/lock/sendmutex
%attr(0644,qmailr,qmail) %{qdir}/queue/lock/tcpto

# ### vpopmail directories
%defattr (0755,vpopmail,vchkpw)
%dir %{vdir}

%defattr (0700,vpopmail,vchkpw)
%dir %{vdir}/domains

%files devel

%changelog
openSUSE Build Service is sponsored by