⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 install.sh

📁 ISCSI user client software.Client would be used to access the IPSAN server.
💻 SH
字号:
#! /bin/sh## Install the iSCSI driver# root directory for the system we're installing for.# May not be / for diskless clients.if [ "$ROOT" ] ; then    export ROOTfi# base dir relative to ROOT into which relocatable files should be installedBASEDIR=${BASEDIR:=/}export BASEDIR# save the path to be used by the clientCLIENT_BASEDIR=$BASEDIRexport CLIENT_BASEDIR# make the BASEDIR the full pathBASEDIR=${ROOT}${CLIENT_BASEDIR}export BASEDIRKVER=`uname -r`# the Makefile passes the object dirs, put default them # in case someone calls the script by hand.OBJDIR=${OBJDIR:=`uname`-`uname -m`/obj}KOBJDIR=${KOBJDIR:=`pwd`}/driverSCRIPT_DIR="misc/scripts"MAN_DIR="man"MISC_DIR="misc"UTILS_DIR="utils"if [ `whoami` != root ]; then	echo "You must be root to install the iSCSI distribution"	exit 1fiPATH="/usr/bin:/bin:/usr/sbin:/sbin:$PATH"export PATH## figure out where to install the init.d script and symlinks#INITDIR=RCROOT=RELDIR=if [ -d ${ROOT}/etc/rc.d/init.d ] ; then    INITDIR=${ROOT}/etc/rc.d/init.d    if [ -d ${ROOT}/etc/rc.d/init.d/rc2.d ] ; then	RCROOT=${ROOT}/etc/rc.d/init.d	RELDIR=..    elif [ -d ${ROOT}/etc/rc.d/rc2.d ] ; then	RCROOT=${ROOT}/etc/rc.d	RELDIR=../init.d    elif [ -d ${ROOT}/etc/rc2.d ] ; then	RCROOT=${ROOT}/etc	RELDIR=../rc.d/init.d    fielif [ -d ${ROOT}/etc/init.d ] ; then    INITDIR=${ROOT}/etc/init.d    if [ -d ${ROOT}/etc/init.d/rc2.d ]; then 	RCROOT=${ROOT}/etc/init.d	RELDIR=..    elif [ -d ${ROOT}/etc/rc.d/rc2.d ] ; then	RCROOT=${ROOT}/etc/rc.d	RELDIR=../../init.d    elif [ -d ${ROOT}/etc/rc2.d ] ; then	RCROOT=${ROOT}/etc	RELDIR=../init.d    fifiprintf "Installing iSCSI driver for Linux $KVER\n\n"# try to remove the module, in case one is installed and loaded already.# we try to unload it here and in remove.sh, so that people updating drivers# don't end up running a new daemon against an old driver.rmmod iscsi_sfnet > /dev/null 2>&1# If old device links still persists, remove them forever.if [ -d /dev/iscsi ]; then    rm -rf /dev/iscsifi# delete any existing iSCSI kernel modules, since we don't want# modprobe loading the wrong one, and some distributions now ship# older modules that we may need to replace.  Since the module subdir# varies, use find to look in every module dir for this kernel.find ${ROOT}/lib/modules/$KVER -name 'iscsi\.ko.*' -exec rm {} \;# install filesif [ ! -d $BASEDIR/sbin ] ; then    mkdir -p $BASEDIR/sbinfiinstall -b -s ${OBJDIR}/iscsid ${OBJDIR}/${UTILS_DIR}/iscsi-device ${OBJDIR}/${UTILS_DIR}/iscsi-iname $BASEDIR/sbininstall -D -b -m 644 ${MAN_DIR}/iscsid.8 $BASEDIR/man/man8/iscsid.8install -D -b -m 644 ${MAN_DIR}/iscsi.conf.5 $BASEDIR/man/man5/iscsi.conf.5install -b -m 755 ${SCRIPT_DIR}/iscsi-ls $BASEDIR/sbin# update scripts with the proper BASEDIRcd ${SCRIPT_DIR}for util in iscsi-umountall iscsi-mountall do    sed -e "s|^BASEDIR=.*|BASEDIR=$CLIENT_BASEDIR|" < $util > $BASEDIR/sbin/$util    chmod 744 $BASEDIR/sbin/$utildoneif [ "$INITDIR" != "" ] ; then    # update the BASEDIR in the rc file based on the BASEDIR we're actually installing to.    sed -e "s|^BASEDIR=.*|BASEDIR=$CLIENT_BASEDIR|" < rc.iscsi > $INITDIR/iscsi    chmod 744 $INITDIR/iscsi    echo "The initialization script has been installed as $INITDIR/iscsi." | fmt -    echo else    # Couldn't find an init.d dir to put the script in    INITDIR=${ROOT}/etc/rc.d    if [ ! -f ${INITDIR}/iscsi ]; then	echo "The initialization script has been installed as ${INITDIR}/iscsi."	echo	if [ ! -d $INITDIR ]; then 	    mkdir -p $INITDIR	fi	# update the BASEDIR in the rc file based on the BASEDIR we're actually installing to.	sed -e "s|^BASEDIR=.*|BASEDIR=$CLIENT_BASEDIR|" < rc.iscsi > $INITDIR/iscsi	chmod 744 $INITDIR/iscsi    fifiif [ "$RCROOT" != "" ] ; then    # usually make it start automatically at boot    if [ ! -f ./.iscsi.no.autostart ] ; then        if [ -f /etc/SuSE-release ]; then            # For SuSE, insserv program provides both start/stop links            # based on the information provided in rc.iscsi            /sbin/insserv iscsi        else            ln -sf $RELDIR/iscsi $RCROOT/rc2.d/S11iscsi            ln -sf $RELDIR/iscsi $RCROOT/rc3.d/S11iscsi            ln -sf $RELDIR/iscsi $RCROOT/rc4.d/S11iscsi            ln -sf $RELDIR/iscsi $RCROOT/rc5.d/S11iscsi        fi	echo "iSCSI has been set up to run automatically when you reboot."	echo    fi    # always make is stop automatically    if [ ! -f /etc/SuSE-release ]; then        ln -sf $RELDIR/iscsi $RCROOT/rc0.d/K20iscsi        ln -sf $RELDIR/iscsi $RCROOT/rc1.d/K20iscsi        ln -sf $RELDIR/iscsi $RCROOT/rc6.d/K20iscsi    fielse    echo "You will need to edit your rc files to run"    echo "$INITDIR/iscsi when you reboot."    echo ficd -# iSCSI requires a unique InitiatorName.  Since it may be used for# access control, it should never change once created.  We store it in# a separate file, and check for it in the iSCSI daemon.  if [ "$ROOT" ] ; then    if ! grep -q "^GenerateName=yes" /etc/initiatorname.iscsi 2> /dev/null ; then	# the installer is running on a different machine than	# the one that needs the file.	# the init.d file will create it on that machine later.	echo "GenerateName=yes" > ${ROOT}/etc/initiatorname.iscsi	chmod 600 ${ROOT}/etc/initiatorname.iscsi    fielse    if ! grep -q "^InitiatorName=[^ \t\n]" /etc/initiatorname.iscsi 2>/dev/null ; then	# Make sure we have the iname utility	if [ ! -x $BASEDIR/sbin/iscsi-iname ] ; then	    echo "Error: $BASEDIR/sbin/iscsi-iname does not exist, driver not successfully installed"	    exit 1;	fi 	# Generate a unique InitiatorName and save it	INAME=`$BASEDIR/sbin/iscsi-iname`	if [ "$INAME" != "" ] ; then	    echo "## DO NOT EDIT OR REMOVE THIS FILE!" > /etc/initiatorname.iscsi	    echo "## If you remove this file, the iSCSI daemon will not start." >> /etc/initiatorname.iscsi	    echo "## If you change the InitiatorName, existing access control lists" >> /etc/initiatorname.iscsi	    echo "## may reject this initiator.  The InitiatorName must be unique">> /etc/initiatorname.iscsi	    echo "## for each iSCSI initiator.  Do NOT duplicate iSCSI InitiatorNames." >> /etc/initiatorname.iscsi	    printf "InitiatorName=$INAME\n"  >> /etc/initiatorname.iscsi	    chmod 600 /etc/initiatorname.iscsi	    printf "InitiatorName $INAME was generated and written to /etc/initiatorname.iscsi.\n\n" | fmt -	else	    echo "Error: couldn't generate an iSCSI InitiatorName"	    exit 1;	fi    else	INAME=`awk -F= '/^InitiatorName=/ { print $2} ' < /etc/initiatorname.iscsi`        printf "InitiatorName $INAME has already been generated and written to /etc/initiatorname.iscsi.\n\n" | fmt -    fificonfig_file="iscsi.conf"if [ -e ${ROOT}/etc/iscsi.conf ]; then    egrep -q -v '^[ \t]*([#].*)?$' ${ROOT}/etc/iscsi.conf    if [ $? -eq 1 ] ; then	# the existing config file has only whitespace and comments, replace it	echo "Reinstalling configuration file ${ROOT}/etc/iscsi.conf";	rm -f ${ROOT}/etc/iscsi.conf	install -m 600 ${MISC_DIR}/iscsi.conf ${ROOT}/etc	echo "Make sure you check and edit the ${ROOT}/etc/iscsi.conf file!"    else	if [ -e ./iscsi-version.h ]; then	    # don't overwrite the existing config, just make a new one for the user to compare to	    drv_ver=`grep ISCSI_DRIVER_VERSION iscsi-version.h |awk -F " " '{print $3}'`	    if [ $drv_ver ]; then		drv_ver=`echo $drv_ver | tr -d \"`		config_file="${config_file}.$drv_ver"	    fi	else	    config_file="${config_file}.new" 	fi	install -m 600 ${MISC_DIR}/iscsi.conf ${ROOT}/etc/${config_file}	chmod 600 ${ROOT}/etc/${config_file}	echo "The config file ${ROOT}/etc/iscsi.conf already exists."	echo "*************************************************************"	echo "NOTE: Portalfailover, PreferredPortal, PreferredSubnet are no"	echo "      longer supported. Please refer iscsi.conf man page and "        echo "      README for a description of available features.        "	echo "*************************************************************"	echo "A new config file ${ROOT}/etc/${config_file} was installed."	echo "Check this file for any new options you may wish to use."	echo    fielse    install -m 600 ${MISC_DIR}/iscsi.conf ${ROOT}/etc    echo "Make sure you check and edit the ${ROOT}/etc/iscsi.conf file!"    echofi# Udev package needs to be installed for installation to progress.if [ ! -d /etc/udev ]; then    echo "Udev package need to be installed prior to driver installtion"    echo "Aborting iSCSI installtion process"    exit 2fi# /etc/fstab.iscsi needs to contain an entry to automount sysfs filesystem# if it is not already present.if [ -f /etc/fstab ]; then    found=0    while read dev mountp fstype options dummy1 dummy2       do       case $dev           in           \#*) continue ;; #  ignore comments           '')  continue ;; # ignore empty lines       esac           if [ $mountp = "/sys" ]; then           found=1           break       fi     done < /etc/fstab    if [ $found -eq 0 ]; then        mkdir -p /sys        echo "none                    /sys                   sysfs    defaults        0 0" >> /etc/fstab    fifiif [ ! -f ${ROOT}/etc/fstab.iscsi ]; then    echo "# /etc/fstab.iscsi file for filesystems built on iscsi devices." > ${ROOT}/etc/fstab.iscsi    echo "#" >> ${ROOT}/etc/fstab.iscsi    echo "# A typical entry here would look like:" >> ${ROOT}/etc/fstab.iscsi    echo "# /dev/sda /mnt ext2 defaults 0 0" >> ${ROOT}/etc/fstab.iscsi    echo "#" >> ${ROOT}/etc/fstab.iscsi    echo "# See fstab(5) for further details on configuring devices." >> ${ROOT}/etc/fstab.iscsi     echo "#" >> ${ROOT}/etc/fstab.iscsielse    count=0    while read line    do        echo $line |grep udev > /dev/null        if [ $? -eq 0 ]; then           count=1           break;        fi    done < ${ROOT}/etc/fstab.iscsi    if [ $count -eq 1 ]; then        echo "# ${ROOT}/etc/fstab.iscsi file for filesystems built on iscsi devices." >> ${ROOT}/etc/fstab.iscsi.tmp        echo "#" >> ${ROOT}/etc/fstab.iscsi.tmp        echo "# A typical entry here would look like:" >> ${ROOT}/etc/fstab.iscsi.tmp        echo "# /dev/sda /mnt ext2 defaults 0 0" >> ${ROOT}/etc/fstab.iscsi.tmp        echo "#" >> ${ROOT}/etc/fstab.iscsi.tmp        echo "# See fstab(5) for further details on configuring devices." >> ${ROOT}/etc/fstab.iscsi.tmp        echo "#" >> ${ROOT}/etc/fstab.iscsi.tmp        echo " " >> ${ROOT}/etc/fstab.iscsi.tmp        while read check line        do            case $check            in             \#*) continue ;; #  ignore comments              '')  continue ;; # ignore empty lines            esac            echo $check $line >> ${ROOT}/etc/fstab.iscsi.tmp        done < ${ROOT}/etc/fstab.iscsi        mv ${ROOT}/etc/fstab.iscsi.tmp ${ROOT}/etc/fstab.iscsi        echo "The iSCSI filesystem entries in fstab.iscsi needs to be changed"        echo "The old device name format /udev/iscsib0t0l0 is not supported"        echo " "    fifi # this assumes that we're installing on this box, but that's usually # the case, and this is harmless if it's not.# ignore errors on anything  except our iscsi module.depmod -a 2>&1 | grep iscsi\.oexit 0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -