Sophie

Sophie

distrib > Fedora > 14 > i386 > media > os > by-pkgid > ef8ed2523944ced8e1b310e7a3c7fe05 > scriptlet

nss-pam-ldapd-0.7.7-1.fc14.i686.rpm

PREIN

/bin/sh
getent group  ldap  > /dev/null || \
/usr/sbin/groupadd -r -g 55 ldap
getent passwd nslcd > /dev/null || \
/usr/sbin/useradd -r -g ldap -c 'LDAP Client User' \
    -u 65 -d / -s /sbin/nologin nslcd 2> /dev/null || :

PREUN

/bin/sh
if [ "$1" -eq "0" ]; then
	/sbin/service nslcd stop >/dev/null 2>&1
	/sbin/chkconfig --del nslcd
fi
exit 0

POSTIN

/bin/sh
# The usual stuff.
/sbin/chkconfig --add nslcd
/sbin/ldconfig
# Import important non-default settings from nss_ldap or pam_ldap configuration
# files, but only the first time this package is installed.
comment="This comment prevents repeated auto-migration of settings."
if test -s /etc/nss-ldapd.conf ; then
	source=/etc/nss-ldapd.conf
elif test -s /etc/nss_ldap.conf ; then
	source=/etc/nss_ldap.conf
elif test -s /etc/pam_ldap.conf ; then
	source=/etc/pam_ldap.conf
else
	source=/etc/ldap.conf
fi
target=/etc/nslcd.conf
if ! grep -q -F "# $comment" $target 2> /dev/null ; then
	# Try to make sure we only do this the first time.
	echo "# $comment" >> $target
	if egrep -q '^uri[[:blank:]]' $source 2> /dev/null ; then
		# Comment out the packaged default host/uri and replace it...
		sed -i -r -e 's,^((host|uri)[[:blank:]].*),# \1,g' $target
		# ... with the uri.
		egrep '^uri[[:blank:]]' $source >> $target
	elif egrep -q '^host[[:blank:]]' $source 2> /dev/null ; then
		# Comment out the packaged default host/uri and replace it...
		sed -i -r -e 's,^((host|uri)[[:blank:]].*),# \1,g' $target
		# ... with the "host" reformatted as a URI.
		scheme=ldap
		# check for 'ssl on', which means we want to use ldaps://
		if egrep -q '^ssl[[:blank:]]+on$' $source 2> /dev/null ; then
			scheme=ldaps
		fi
		egrep '^host[[:blank:]]' $source |\
		sed -r -e "s,^host[[:blank:]](.*),uri ${scheme}://\1/,g" >> $target
	fi
	# Base doesn't require any special logic.
	if egrep -q '^base[[:blank:]]' $source 2> /dev/null ; then
		# Comment out the packaged default base and replace it.
		sed -i -r -e 's,^(base[[:blank:]].*),# \1,g' $target
		egrep '^base[[:blank:]]' $source >> $target
	fi
	# Pull in these settings, if they're set, directly.
	egrep '^(binddn|bindpw|port|scope|ssl|pagesize)[[:blank:]]' $source 2> /dev/null >> $target
	egrep '^(tls_)' $source 2> /dev/null >> $target
	egrep '^(timelimit|bind_timelimit|idle_timelimit)[[:blank:]]' $source 2> /dev/null >> $target
fi
# If this is the first time we're being installed, and the system is already
# configured to use LDAP as a naming service, enable the daemon, but don't
# start it since we can never know if that's a safe thing to do.  If this
# is an upgrade, leave the user's runlevel selections alone.
if [ "$1" -eq "1" ]; then
	if egrep -q '^USELDAP=yes$' /etc/sysconfig/authconfig 2> /dev/null ; then
		/sbin/chkconfig nslcd on
	fi
fi
# Earlier versions of 0.7.6 of this package would have included both 'gid
# nslcd' (a group which doesn't exist) and 'gid ldap' (which we ensure exists).
# If we detect both, fix the configuration.
if grep -q '^gid nslcd' $target ; then
	if grep -q '^gid ldap' $target ; then
		sed -i -e 's,^gid nslcd$,# gid nslcd,g' $target
	fi
fi
exit 0

POSTUN

/bin/sh
/sbin/ldconfig
if [ "$1" -ge "1" ]; then
	/etc/rc.d/init.d/nslcd condrestart >/dev/null 2>&1
fi
exit 0