xref: /freebsd/libexec/rc/rc.d/ldconfig (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
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="/lib /usr/lib"
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		machine_arch=$(sysctl -n hw.machine_arch)
43
44		case ${machine_arch} in
45		aarch64|amd64|powerpc64)
46			for i in ${ldconfig_local32_dirs}; do
47				if [ -d "${i}" ]; then
48					_files=`find ${i} -type f`
49					if [ -n "${_files}" ]; then
50						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
51					fi
52				fi
53			done
54			_LDC=""
55			for i in ${ldconfig32_paths}; do
56				if [ -r "${i}" ]; then
57					_LDC="${_LDC} ${i}"
58				fi
59			done
60			startmsg '32-bit compatibility ldconfig path:' ${_LDC}
61			${ldconfig} -32 ${_ins} ${_LDC}
62			;;
63		esac
64
65	fi
66}
67
68load_rc_config $name
69run_rc_command "$1"
70