3 # lc_modprobe - add lustre module options into modprobe.conf or
6 #################################################################################
8 # Get the library of functions
9 . @scriptlibdir@/lc_common
11 # Check the kernel version
12 KERNEL_VERSION=`uname -r`
13 KERNEL_VERSION=${KERNEL_VERSION:0:3}
15 if [ "${KERNEL_VERSION}" = "2.4" ]; then
16 MODULE_CONF=/etc/modules.conf
18 MODULE_CONF=/etc/modprobe.conf
22 MODLINES_FILE=/tmp/modlines$$.txt
23 START_MARKER=$"# start lustre config"
24 END_MARKER=$"# end lustre config"
26 # Generate a temp file contains lnet options lines
27 generate_lnet_lines() {
28 local LNET_LINE TMP_LINE
30 TMP_LINE="${NETWORKS}"
32 echo ${START_MARKER} > ${MODLINES_FILE}
33 echo "# Lustre module options added automatically by `basename $0`" >> ${MODLINES_FILE}
35 LNET_LINE=${TMP_LINE%%\\n*}
36 echo ${LNET_LINE} >> ${MODLINES_FILE}
38 TMP_LINE=${TMP_LINE#*\\n}
40 if [ "${TMP_LINE}" == "${LNET_LINE}" ]; then
44 echo ${END_MARKER} >> ${MODLINES_FILE}
46 #echo "--------------${MODLINES_FILE}--------------"
48 #echo -e "------------------------------------------\n"
53 if ! generate_lnet_lines; then
57 MODULE_CONF=$(fcanon ${MODULE_CONF})
58 # Add lnet options lines to the module configuration file
59 if [ -e ${MODULE_CONF} ]; then
60 # Delete the old options
61 sed -i "/${START_MARKER}/,/${END_MARKER}/d" ${MODULE_CONF}
64 cat ${MODLINES_FILE} >> ${MODULE_CONF}
65 rm -f ${MODLINES_FILE}