xref: /freebsd/libexec/rc/rc.d/ldconfig (revision 643ac419fafba89f5adda0e0ea75b538727453fb)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: ldconfig
7# REQUIRE: FILESYSTEMS
8# BEFORE:  DAEMON
9
10. /etc/rc.subr
11
12name="ldconfig"
13desc="Configure the shared library cache"
14ldconfig_command="/sbin/ldconfig"
15start_cmd="ldconfig_start"
16stop_cmd=":"
17
18ldconfig_start()
19{
20	local _files _ins
21
22	_ins=
23	ldconfig=${ldconfig_command}
24	checkyesno ldconfig_insecure && _ins="-i"
25	if [ -x "${ldconfig_command}" ]; then
26		_LDC="/lib /usr/lib"
27		for i in ${ldconfig_local_dirs}; do
28			if [ -d "${i}" ]; then
29				_files=`find ${i} -type f`
30				if [ -n "${_files}" ]; then
31					ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`"
32				fi
33			fi
34		done
35		for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
36			if [ -r "${i}" ]; then
37				_LDC="${_LDC} ${i}"
38			fi
39		done
40		startmsg 'ELF ldconfig path:' ${_LDC}
41		${ldconfig} -elf ${_ins} ${_LDC}
42
43		machine_arch=$(sysctl -n hw.machine_arch)
44
45		case ${machine_arch} in
46		amd64|mips64|powerpc64)
47			for i in ${ldconfig_local32_dirs}; do
48				if [ -d "${i}" ]; then
49					_files=`find ${i} -type f`
50					if [ -n "${_files}" ]; then
51						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
52					fi
53				fi
54			done
55			_LDC=""
56			for i in ${ldconfig32_paths}; do
57				if [ -r "${i}" ]; then
58					_LDC="${_LDC} ${i}"
59				fi
60			done
61			startmsg '32-bit compatibility ldconfig path:' ${_LDC}
62			${ldconfig} -32 ${_ins} ${_LDC}
63			;;
64		esac
65
66	fi
67}
68
69load_rc_config $name
70run_rc_command "$1"
71