#!/bin/sh
#
# $NetBSD: ldconfig,v 1.5 2002/03/22 04:33:58 thorpej Exp $
# $FreeBSD: src/etc/rc.d/ldconfig,v 1.7 2003/06/30 15:02:05 trhodes Exp $
#

# PROVIDE: ldconfig
# REQUIRE: mountcritremote
# BEFORE:  SERVERS

. /etc/rc.subr

name="ldconfig"
ldconfig_command="/sbin/ldconfig"
start_cmd="ldconfig_start"
stop_cmd=":"

ldconfig_start()
{
	_ins=
	ldconfig=${ldconfig_command}
	checkyesno ldconfig_insecure && _ins="-i"
	if [ -x "${ldconfig_command}" ]; then
		_LDC=""
		for i in ${ldconfig_local_dirs}; do
			if [ -d "${i}" ]; then
				ldconfig_paths="${ldconfig_paths} `find ${i} -type f`"
			fi
		done
		for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
			if [ -r "${i}" ]; then
				_LDC="${_LDC} ${i}"
			fi
		done
		echo 'ELF ldconfig path:' ${_LDC}
		${ldconfig} -elf ${_ins} ${_LDC}
	fi
}

load_rc_config $name
run_rc_command "$1"
