From eada465223602b5a73da9474330795131b565bcf Mon Sep 17 00:00:00 2001 From: Morris Zuss Date: May 20 2022 18:14:45 +0000 Subject: openldap-openrc --- diff --git a/nonsystemd/openldap-openrc/PKGBUILD b/nonsystemd/openldap-openrc/PKGBUILD new file mode 100644 index 0000000..3a85d56 --- /dev/null +++ b/nonsystemd/openldap-openrc/PKGBUILD @@ -0,0 +1,22 @@ +# Maintainer: artoo + +pkgname=openldap-openrc +pkgver=20220520 +pkgrel=1 +pkgrel+=.nonsystemd1 +pkgdesc="OpenRC openldap init script" +arch=('any') +url="https://gitea.artixlinux.org/artixlinux/packages-openrc" +license=('GPL2') +depends=('openrc' 'openldap') +conflicts=('systemd-sysvcompat') +backup=('etc/conf.d/slapd') +source=("slapd.confd" + "slapd.initd") +sha512sums=('e4ae52d10294da787016cf39adfd68c6ad812ac1758b00845810ee7936d21734d2ef3793252b878d88f21788414071adffb5f484381d4dc6a29f71a8729486b7' + 'f3beac99fb79130f420caf169a18404b76bf55af83c9266bb8651a3e2a84fef72f2451554c59c3d008f6af6211a84cbab5904541b635e7bf1730ae6a8cdbedf8') + +package() { + install -Dm644 "${srcdir}"/slapd.confd "${pkgdir}"/etc/conf.d/slapd + install -Dm755 "${srcdir}"/slapd.initd "${pkgdir}"/etc/init.d/slapd +} diff --git a/nonsystemd/openldap-openrc/slapd.confd b/nonsystemd/openldap-openrc/slapd.confd new file mode 100644 index 0000000..28e9d23 --- /dev/null +++ b/nonsystemd/openldap-openrc/slapd.confd @@ -0,0 +1,14 @@ +# conf.d file for openldap +# +# To enable both the standard unciphered server and the ssl encrypted +# one uncomment this line or set any other server starting options +# you may desire. +# +# OPTS="-h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'" +# Uncomment the below to use the new slapd configuration for openldap 2.3 +#OPTS="-F /etc/openldap/slapd.d -h 'ldaps:// ldap:// ldapi://%2fvar%2frun%2fopenldap%2fslapd.sock'" +# +# If you change the above listen statement to bind on a specific IP for +# listening, you should ensure that interface is up here (change eth0 as +# needed). +#rc_need="net.eth0" diff --git a/nonsystemd/openldap-openrc/slapd.initd b/nonsystemd/openldap-openrc/slapd.initd new file mode 100644 index 0000000..16b112f --- /dev/null +++ b/nonsystemd/openldap-openrc/slapd.initd @@ -0,0 +1,64 @@ +#!/usr/bin/openrc-run +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="checkconfig" + +[ -z "$INSTANCE" ] && INSTANCE="openldap${SVCNAME#slapd}" +PIDDIR=/run/openldap +PIDFILE=$PIDDIR/$SVCNAME.pid + +depend() { + need net + before dbus hald avahi-daemon + provide ldap +} + +start() { + checkpath -q -d ${PIDDIR} -o ldap:ldap + if ! checkconfig -Q ; then + eerror "There is a problem with your slapd.conf!" + return 1 + fi + ebegin "Starting ldap-server" + [ -n "$KRB5_KTNAME" ] && export KRB5_KTNAME + eval start-stop-daemon --start --pidfile ${PIDFILE} --exec /usr/lib/openldap/slapd -- -u ldap -g ldap "${OPTS}" + eend $? +} + +stop() { + ebegin "Stopping ldap-server" + start-stop-daemon --stop --signal 2 --quiet --pidfile ${PIDFILE} + eend $? +} + +checkconfig() { + # checks requested by bug #502948 + # Step 1: extract the last valid config file or config dir + set -- $OPTS + while [ -n "$*" ]; do + opt=$1 ; shift + if [ "$opt" = "-f" -o "$opt" = "-F" ] ; then + CONF=$1 + shift + fi + done + set -- + # Fallback + CONF=${CONF-/etc/openldap/slapd.conf} + [ -d $CONF ] && CONF=${CONF}/* + DBDIRS=`eval awk '"/^(directory|olcDbDirectory:)/{print \\$2}"' $CONF` + for d in $DBDIRS; do + if [ ! -d $d ]; then + eerror "Directory $d in config does not exist!" + return 1 + fi + /usr/bin/find $d ! -name DB_CONFIG ! -user ldap -o ! -group ldap |grep -sq . + if [ $? -ne 0 ]; then + ewarn "You have files in $d not owned by the ldap user, you must ensure they are accessible to the slapd instance!" + fi + [ ! -e $d/DB_CONFIG ] && ewarn "$d/DB_CONFIG does not exist, slapd performance may be sub-optimal" + done + # now test the config fully + /usr/bin/slaptest -u "$@" ${OPTS_CONF} +}