From 260115ce1fa221469f1b584eebbebef14906f769 Mon Sep 17 00:00:00 2001 From: yujian Date: Fri, 2 Jun 2006 10:14:30 +0000 Subject: [PATCH] b=9853 Script to add lustre module options into modprobe.conf/modules.conf. --- lustre/scripts/lc_modprobe.sh | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 lustre/scripts/lc_modprobe.sh diff --git a/lustre/scripts/lc_modprobe.sh b/lustre/scripts/lc_modprobe.sh new file mode 100755 index 0000000..dc9f0bc --- /dev/null +++ b/lustre/scripts/lc_modprobe.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# lc_modprobe.sh - add lustre module options into modprobe.conf or +# modules.conf +# +################################################################################# + +# Check the kernel version +KERNEL_VERSION=`uname -r` +KERNEL_VERSION=${KERNEL_VERSION:0:3} + +if [ "${KERNEL_VERSION}" = "2.4" ]; then + MODULE_CONF=/etc/modules.conf +else + MODULE_CONF=/etc/modprobe.conf +fi + +read -r NETWORKS +MODLINES_FILE=/tmp/modlines$$.txt +START_MARKER=$"# start lustre config" +END_MARKER=$"# end lustre config" + +# Generate a temp file contains lnet options lines +generate_lnet_lines() { + local LNET_LINE TMP_LINE + + TMP_LINE="${NETWORKS}" + + echo ${START_MARKER} > ${MODLINES_FILE} + echo "# Lustre module options added automatically by `basename $0`" >> ${MODLINES_FILE} + echo "alias lustre llite" >> ${MODLINES_FILE} + while true; do + LNET_LINE=${TMP_LINE%%\\n*} + echo ${LNET_LINE} >> ${MODLINES_FILE} + + TMP_LINE=${TMP_LINE#*\\n} + + if [ "${TMP_LINE}" == "${LNET_LINE}" ]; then + break + fi + done + echo ${END_MARKER} >> ${MODLINES_FILE} + + #echo "--------------${MODLINES_FILE}--------------" + #cat ${MODLINES_FILE} + #echo -e "------------------------------------------\n" + + return 0 +} + +if ! generate_lnet_lines; then + exit 1 +fi + +# Add lnet options lines to the module configuration file +if [ -e ${MODULE_CONF} ]; then + # Delete the old options + sed -i "/${START_MARKER}/,/${END_MARKER}/d" ${MODULE_CONF} +fi + +cat ${MODLINES_FILE} >> ${MODULE_CONF} +rm -f ${MODLINES_FILE} +exit 0 -- 1.8.3.1