From 9a91491affa594c77d0da0ce8e2657b333b549dc Mon Sep 17 00:00:00 2001 From: yujian Date: Thu, 15 Dec 2005 12:16:40 +0000 Subject: [PATCH] A shell script to add lnet options line to modprobe.conf or modules.conf --- lustre/utils/add_lnet_options.sh | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 lustre/utils/add_lnet_options.sh diff --git a/lustre/utils/add_lnet_options.sh b/lustre/utils/add_lnet_options.sh new file mode 100755 index 0000000..9f845ba --- /dev/null +++ b/lustre/utils/add_lnet_options.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# add_lnet_options.sh - add lnet options lines 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} + 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