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