ldconfig revision 240336
14887Schin#!/bin/sh
24887Schin#
34887Schin# $FreeBSD: head/etc/rc.d/ldconfig 240336 2012-09-11 05:04:59Z obrien $
412068SRoger.Faulkner@Oracle.COM#
54887Schin
64887Schin# PROVIDE: ldconfig
78462SApril.Chin@Sun.COM# REQUIRE: mountcritremote FILESYSTEMS
84887Schin# BEFORE:  DAEMON
94887Schin
104887Schin. /etc/rc.subr
114887Schin
124887Schinname="ldconfig"
134887Schinldconfig_command="/sbin/ldconfig"
144887Schinstart_cmd="ldconfig_start"
154887Schinstop_cmd=":"
164887Schin
174887Schinldconfig_start()
184887Schin{
194887Schin	local _files _ins
204887Schin
214887Schin	_ins=
224887Schin	ldconfig=${ldconfig_command}
234887Schin	checkyesno ldconfig_insecure && _ins="-i"
244887Schin	if [ -x "${ldconfig_command}" ]; then
254887Schin		_LDC="/lib /usr/lib"
264887Schin		for i in ${ldconfig_local_dirs}; do
274887Schin			if [ -d "${i}" ]; then
284887Schin				_files=`find ${i} -type f`
294887Schin				if [ -n "${_files}" ]; then
304887Schin					ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`"
314887Schin				fi
324887Schin			fi
334887Schin		done
344887Schin		for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
354887Schin			if [ -r "${i}" ]; then
364887Schin				_LDC="${_LDC} ${i}"
374887Schin			fi
384887Schin		done
394887Schin		check_startmsgs && echo 'ELF ldconfig path:' ${_LDC}
404887Schin		${ldconfig} -elf ${_ins} ${_LDC}
414887Schin
424887Schin		case `sysctl -n hw.machine_arch` in
434887Schin		amd64)
444887Schin			for i in ${ldconfig_local32_dirs}; do
454887Schin				if [ -d "${i}" ]; then
464887Schin					_files=`find ${i} -type f`
474887Schin					if [ -n "${_files}" ]; then
48						ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`"
49					fi
50				fi
51			done
52			_LDC=""
53			for i in ${ldconfig32_paths}; do
54				if [ -r "${i}" ]; then
55					_LDC="${_LDC} ${i}"
56				fi
57			done
58			check_startmsgs &&
59			    echo '32-bit compatibility ldconfig path:' ${_LDC}
60			${ldconfig} -32 -m ${_ins} ${_LDC}
61			;;
62		esac
63
64		# Legacy aout support for i386 only
65		case `sysctl -n hw.machine_arch` in
66		i386)
67			# Default the a.out ldconfig path.
68			: ${ldconfig_paths_aout=${ldconfig_paths}}
69			_LDC=""
70			for i in /usr/lib/aout ${ldconfig_paths_aout} /etc/ld.so.conf; do
71				if [ -r "${i}" ]; then
72					_LDC="${_LDC} ${i}"
73				fi
74			done
75			check_startmsgs && echo 'a.out ldconfig path:' ${_LDC}
76			${ldconfig} -aout ${_ins} ${_LDC}
77			;;
78		esac
79	fi
80}
81
82load_rc_config $name
83run_rc_command "$1"
84