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 check_startmsgs && echo 'ELF ldconfig path:' ${_LDC} 41 ${ldconfig} -elf ${_ins} ${_LDC} 42 43 case `sysctl -n hw.machine_arch` in 44 amd64|mips64|powerpc64) 45 for i in ${ldconfig_local32_dirs}; do 46 if [ -d "${i}" ]; then 47 _files=`find ${i} -type f` 48 if [ -n "${_files}" ]; then 49 ldconfig32_paths="${ldconfig32_paths} `cat ${_files} | sort -u`" 50 fi 51 fi 52 done 53 _LDC="" 54 for i in ${ldconfig32_paths}; do 55 if [ -r "${i}" ]; then 56 _LDC="${_LDC} ${i}" 57 fi 58 done 59 check_startmsgs && 60 echo '32-bit compatibility ldconfig path:' ${_LDC} 61 ${ldconfig} -32 ${_ins} ${_LDC} 62 ;; 63 esac 64 65 case `sysctl -n hw.machine_arch` in 66 armv[67]) 67 for i in ${ldconfig_localsoft_dirs}; do 68 if [ -d "${i}" ]; then 69 _files=`find ${i} -type f` 70 if [ -n "${_files}" ]; then 71 ldconfigsoft_paths="${ldconfigsoft_paths} `cat ${_files} | sort -u`" 72 fi 73 fi 74 done 75 _LDC="" 76 for i in ${ldconfigsoft_paths}; do 77 if [ -r "${i}" ]; then 78 _LDC="${_LDC} ${i}" 79 fi 80 done 81 check_startmsgs && 82 echo 'Soft Float compatibility ldconfig path:' ${_LDC} 83 ${ldconfig} -soft ${_ins} ${_LDC} 84 ;; 85 esac 86 87 # Legacy aout support for i386 only 88 case `sysctl -n hw.machine_arch` in 89 i386) 90 # Default the a.out ldconfig path. 91 : ${ldconfig_paths_aout=${ldconfig_paths}} 92 _LDC="" 93 for i in /usr/lib/aout ${ldconfig_paths_aout} /etc/ld.so.conf; do 94 if [ -r "${i}" ]; then 95 _LDC="${_LDC} ${i}" 96 fi 97 done 98 check_startmsgs && echo 'a.out ldconfig path:' ${_LDC} 99 ${ldconfig} -aout ${_ins} ${_LDC} 100 ;; 101 esac 102 fi 103} 104 105load_rc_config $name 106run_rc_command "$1" 107