#!/bin/sh # # This script is responsible doing the http node configuration. # This has been modified to allow the setting of the MTU for an interface # by Mike Hollowell of Arrowhead Systems Ltd # use at your own risk. # # EXTRAS: Configure multiple NICs # Ex. # cfg_NICs="eth2:dhcp eth1:1.1.1.1:255.255.255.0" # # space delimited list of eth<#>:dhcp # Original args OR eth<#>:: # Arrowhead modified args OR eth<#>::: # global_scriptName="${0##*\/}" global_argv=$@ global_argc=$# #echo $global_scriptName [ $global_argc : $global_argv ] #exit 0 if test $global_argc -ne 1 ; then echo "ERROR: $global_scriptName | bad num of args : $global_argc '$global_argv'" exit 111 fi final_pull_loc="$1" default_NIC_timeout=120 if [ -n "$extra_NIC_time" ]; then let default_NIC_timeout=$default_NIC_timeout+$extra_NIC_time fi . /etc/init.d/network_scripts/functions # for do_dhcp_config and do_staticIP_config log_file_path='/var/log/configure_node.log' NIC_config_success_file_path='/var/log/NIC_config_success.log' ########################################################################## logprnt() # { local echo_options='' if [ "$1" = '-e' ]; then shift echo_options="$echo_options -e" fi if [ "$1" = '-n' ]; then shift echo_options="$echo_options -n" fi echo $echo_options "$@" >> "$log_file_path" echo $echo_options "$@" } ########################################################################## pull_file() # { local file_to_pull="$1" local exit_status if [ -z "${file_to_pull%http://*}" ]; then log_execution "$log_file_path" /bin/wget "$file_to_pull" exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : pull failed : /bin/wget '$file_to_pull'" fi return $exit_status fi if [ -z "${file_to_pull%file:///*}" ]; then file_to_pull="${file_to_pull#file://}" logprnt "file: /bin/cp -f '$file_to_pull' './'" log_execution "$log_file_path" /bin/cp -f "$file_to_pull" "./" exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : pull failed : /bin/cp -f '$file_to_pull' './'" fi return $exit_status fi logprnt "ERROR : Bad pull directive '$file_to_pull'" return 111 } ########################################################################## logprnt "PULL ..." ###################################################### pull_loc="${final_pull_loc%/*}" pull_file "${pull_loc}/configure_node_late" pull_file "${pull_loc}/multipath.conf" pull_file "${pull_loc}/scsi_id.config" pull_file "${pull_loc}/iscsid.conf" pull_file "${pull_loc}/network_config_directives.xml" pull_file "${pull_loc}/initiatorname.iscsi" pull_file "${pull_loc}/iscsi_portal_list.xml" /bin/rm -rf /etc/init.d/default_node_config # No longer needed /bin/rm -rf /etc/init.d/http_node_config # No longer needed logprnt "INSTALL ..." ###################################################### log_execution "$log_file_path" chmod +x ./configure_node_late exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : chmod +x ./configure_node_late" fi log_execution "$log_file_path" /bin/cp -f ./multipath.conf /etc/ exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : /bin/cp -f ./multipath.conf /etc/" fi log_execution "$log_file_path" /bin/cp -f ./scsi_id.config /etc/ exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : /bin/cp -f ./scsi_id.config /etc/" fi log_execution "$log_file_path" /bin/cp -f ./iscsid.conf /etc/iscsi/ exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : /bin/cp -f ./iscsid.conf /etc/" fi log_execution "$log_file_path" /bin/cp -f ./configure_node_late /node_config_late/ exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : /bin/cp -f ./configure_node_late /node_config_late/" fi log_execution "$log_file_path" /bin/cp -f ./initiatorname.iscsi /node_config_late/ exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : /bin/cp -f ./initiatorname.iscsi /node_config_late/" fi log_execution "$log_file_path" /bin/cp -f ./iscsi_portal_list.xml /etc/ exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : /bin/cp -f ./iscsi_portal_list.xml /etc/" fi log_execution "$log_file_path" /bin/cp -f ./network_config_directives.xml /etc/ exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : /bin/cp -f ./network_config_directives.xml /etc/" fi ########################################################################## iSCSI_initiatorname_file='/etc/iscsi/initiatorname.iscsi' iSCSI_initiatorname='' ########################################################################## # Get the list of available QLogic iSCSI HBAs as their host number ql_iscsi_HBA_host_num_list=$(/opt/QLogic_Corporation/SANsurferiCLI/iscli -i 2>/dev/null \ | grep '[[:space:]][[:space:]]*Instance[[:space:]]#:[[:space:]][[:space:]]*[[:digit:]][[:digit:]]*[[:space:]]*$' \ | sed -e 's/^.*[[:space:]][[:space:]]*Instance[[:space:]]#:[[:space:]][[:space:]]*//' -e 's/[[:space:]]*//g' \ ) ql_iscsi_HBA_MAC_list='' for ql_iscsi_HBA_host_num in $ql_iscsi_HBA_host_num_list do ql_iscsi_HBA_MAC_addr=$(/opt/QLogic_Corporation/SANsurferiCLI/iscli -pinfo $ql_iscsi_HBA_host_num 2>/dev/null \ | grep '^MAC Address[[:space:]]*:[[:space:]]' | sed -e 's/^MAC Address[[:space:]]*:[[:space:]]*//' -e 's/-/:/g') if [ "$?" != '0' ]; then logprnt "ERROR: BEG: QLogic host [$$ql_iscsi_HBA_host_num] failed -pinfo" /opt/QLogic_Corporation/SANsurferiCLI/iscli -i 2>&1 | tee -a $log_file_path logprnt "ERROR: END: QLogic host [$$ql_iscsi_HBA_host_num] failed -pinfo" continue; fi if [ -n "$ql_iscsi_HBA_MAC_list" ]; then ql_iscsi_HBA_MAC_list="$ql_iscsi_HBA_MAC_list\nqlishba${ql_iscsi_HBA_host_num}|${ql_iscsi_HBA_MAC_addr}" else ql_iscsi_HBA_MAC_list="qlishba${ql_iscsi_HBA_host_num}|${ql_iscsi_HBA_MAC_addr}" fi done ########################################################################## generate_iscsi_initiatorname_file() # { local configed_eth="$1" local output_file_path="$2" local iSCSI_MS_eth_endAddr=$(ifconfig "$configed_eth" | grep "inet addr:" | sed 's/^.*inet addr://' | sed 's/ .*$//' | sed 's/^.*\.//g') local iSCSI_MS_eth_MAC=$( ifconfig "$configed_eth" | grep " HWaddr " | sed 's/^.* HWaddr //' | sed 's/ .*$//' | sed 's/\://g') local iSCSI_initiatorDomain='2007-01.com.virtualiron' local iSCSI_initiatorNum='01' local iSCSI_uniqueInitVal="${iSCSI_MS_eth_MAC}-${iSCSI_MS_eth_endAddr}" iSCSI_initiatorname_preamble=' ## DO NOT EDIT OR REMOVE THIS FILE! ## If you remove this file, the iSCSI daemon will not start. ## If you change the InitiatorName, existing access control lists ## may reject this initiator. The InitiatorName must be unique ## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames.' rm -f "$output_file_path" echo "$iSCSI_initiatorname_preamble" >> "$output_file_path" echo -n "InitiatorName=iqn.${iSCSI_initiatorDomain}:" >> "$output_file_path" echo -n "${iSCSI_initiatorNum}:${iSCSI_uniqueInitVal}" >> "$output_file_path" } ########################################################################## configure_NIC() # { local exit_status local exe_output local NIC_to_cfg="$1" local NIC_timeout=$2 local interface local interfaceMAC local interfaceIP logprnt "Bringing up : $NIC_to_cfg [$NIC_timeout]" interface="${NIC_to_cfg#MAC(}" if [ "$interface" != "$NIC_to_cfg" ]; then interface="${interface%%)*}" local avail_eth_MAC_list=$(ifconfig -a 2> /dev/null | grep '^eth.*HWaddr[[:space:]].*$' | sed 's/[[:space:]][[:space:]]*.*HWaddr[[:space:]]*/|/;s/[[:space:]]*$//') local eth_MAC_found=$(echo -e "$avail_eth_MAC_list" | grep -i "|$interface$") if [ -z "$eth_MAC_found" ]; then eth_MAC_found=$(echo -e "$ql_iscsi_HBA_MAC_list" | grep -i "|$interface$") if [ -z "$eth_MAC_found" ]; then logprnt "ERROR : bad given MAC to cfg : '$NIC_to_cfg' '$interface'" return 1 fi fi NIC_to_cfg="${eth_MAC_found%%|*}:${NIC_to_cfg#*):}" logprnt "Translated : $NIC_to_cfg" fi interface=${NIC_to_cfg%%:*} if [ "${NIC_to_cfg#*:}" = "dhcp" ]; then echo "$interface" | grep -q '^qlishba[[:digit:]][[:digit:]]*$' if [ "$?" = '0' ]; then ql_iscsi_HBA_host_num=${interface#qlishba} interfaceMAC=$(/opt/QLogic_Corporation/SANsurferiCLI/iscli -pinfo $ql_iscsi_HBA_host_num 2>/dev/null \ | grep '^MAC Address[[:space:]][[:space:]]*:[[:space:]]' \ | sed -e 's/^MAC Address[[:space:]][[:space:]]*:[[:space:]]//' -e 's/-/:/g' \ ) if [ -z "$interfaceMAC" ]; then logprnt "ERROR : bad interface [$interface]" return 1 fi /opt/QLogic_Corporation/SANsurferiCLI/iscli -c $ql_iscsi_HBA_host_num \ | egrep "(^TCP_DHCP[[:space:]]*:[[:space:]]*on$|^iSCSI_Name[[:space:]]*:[[:space:]]*$iSCSI_initiatorname$)" \ | wc -l | grep -q '[[:space:]]*2[[:space:]]*' if [ "$?" != '0' ]; then log_execution "$log_file_path" /opt/QLogic_Corporation/SANsurferiCLI/iscli -ipdhcp $ql_iscsi_HBA_host_num exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : iscli_dhcp($interface) failed [$exit_status]" return 1 fi # /opt/QLogic_Corporation/SANsurferiCLI/iscli -n $ql_iscsi_HBA_host_num IP_Gateway 0.0.0.0 iSCSI_Name "$iSCSI_initiatorname" 2>&1 | tee -a $log_file_path /opt/QLogic_Corporation/SANsurferiCLI/iscli -n $ql_iscsi_HBA_host_num iSCSI_Name "$iSCSI_initiatorname" 2>&1 | tee -a $log_file_path fi echo '' | tee -a $log_file_path /opt/QLogic_Corporation/SANsurferiCLI/iscli -c $ql_iscsi_HBA_host_num | egrep '(^U.*IP Address|^IP Address|^Gateway|^Subnet Mask)' 2>&1 | tee -a $log_file_path echo '' | tee -a $log_file_path interfaceIP=$(/opt/QLogic_Corporation/SANsurferiCLI/iscli -c $ql_iscsi_HBA_host_num \ | grep '^IP Address[[:space:]][[:space:]]*:[[:space:]]*' \ | sed -e 's/^IP Address[[:space:]][[:space:]]*:[[:space:]]*//' \ ) else interfaceMAC=$(net_MAC_of_interface "$interface") if [ -z "$interfaceMAC" ]; then logprnt "ERROR : bad interface [$interface]" return 1 fi exe_output=$(do_dhcp_config "$interface" $NIC_timeout) exit_status=$? echo "$exe_output" >> "$log_file_path" echo "$exe_output" if [ "$exit_status" != "0" ]; then logprnt "ERROR : do_dhcp_config($interface)[$dhcp_timeout] failed [$exit_status]" return 1 fi ifconfig "$interface" 2>&1 | head -3 | tee -a $log_file_path echo '' | tee -a $log_file_path interfaceIP=$(net_ip_of_interface "$interface") fi else local eth_staticIP_andMask="${NIC_to_cfg#*:}" local eth_staticIP="${eth_staticIP_andMask%%:*}" local eth_staticIPmask="${eth_staticIP_andMask#*:}" # changed by Mike Hollowelll Arrowhead systems Ltd Oct 2007 local eth_staticIPmask="${eth_staticIPmask%%:*}" local eth_staticIPmtu="${eth_staticIP_andMask#*:*:}" # end echo "$interface" | grep -q '^qlishba[[:digit:]][[:digit:]]*$' if [ "$?" = '0' ]; then ql_iscsi_HBA_host_num=${interface#qlishba} interfaceMAC=$(/opt/QLogic_Corporation/SANsurferiCLI/iscli -pinfo $ql_iscsi_HBA_host_num 2>/dev/null \ | grep '^MAC Address[[:space:]][[:space:]]*:[[:space:]]' \ | sed -e 's/^MAC Address[[:space:]][[:space:]]*:[[:space:]]//' -e 's/-/:/g' \ ) if [ -z "$interfaceMAC" ]; then logprnt "ERROR : bad interface [$interface]" return 1 fi /opt/QLogic_Corporation/SANsurferiCLI/iscli -c $ql_iscsi_HBA_host_num \ | egrep "(^IP_Address[[:space:]]*:[[:space:]]*$eth_staticIP$|^IP_Subnet_Mask[[:space:]]*:[[:space:]]*$eth_staticIPmask$|^IP_Gateway[[:space:]]*:[[:space:]]*0.0.0.0$|^iSCSI_Name[[:space:]]*:[[:space:]]*$iSCSI_initiatorname$)" \ | wc -l | grep -q '[[:space:]]*4[[:space:]]*' if [ "$?" != '0' ]; then log_execution "$log_file_path" /opt/QLogic_Corporation/SANsurferiCLI/iscli -netconf $ql_iscsi_HBA_host_num -IP $eth_staticIP -IPNM "$eth_staticIPmask" -IPGW 0.0.0.0 exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : iscli_static($interface) failed [$exit_status]" return 1 fi /opt/QLogic_Corporation/SANsurferiCLI/iscli -n $ql_iscsi_HBA_host_num iSCSI_Name "$iSCSI_initiatorname" 2>&1 | tee -a $log_file_path fi echo '' | tee -a $log_file_path /opt/QLogic_Corporation/SANsurferiCLI/iscli -c $ql_iscsi_HBA_host_num | egrep '(^U.*IP Address|^IP Address|^Gateway|^Subnet Mask)' 2>&1 | tee -a $log_file_path echo '' | tee -a $log_file_path interfaceIP=$(/opt/QLogic_Corporation/SANsurferiCLI/iscli -c $ql_iscsi_HBA_host_num \ | grep '^IP Address[[:space:]][[:space:]]*:[[:space:]]*' \ | sed -e 's/^IP Address[[:space:]][[:space:]]*:[[:space:]]*//' \ ) else interfaceMAC=$(net_MAC_of_interface "$interface") if [ -z "$interfaceMAC" ]; then logprnt "ERROR : bad interface [$interface]" return 1 fi # changed by Mike Hollowelll Arrowhead systems Ltd Oct 2007 # exe_output=$(do_staticIP_config "$interface" $NIC_timeout "$eth_staticIP" "$eth_staticIPmask") exe_output=$(do_staticIPandMTU_config "$interface" $NIC_timeout "$eth_staticIP" "$eth_staticIPmask" "$eth_staticIPmtu") # end exit_status=$? echo "$exe_output" >> "$log_file_path" echo "$exe_output" if [ "$exit_status" != "0" ]; then logprnt "ERROR : do_staticIP_config($interface) failed [$exit_status]" return 1 fi ifconfig "$interface" 2>&1 | head -3 | tee -a $log_file_path echo '' | tee -a $log_file_path interfaceIP=$(net_ip_of_interface "$interface") fi fi echo "$interface[$interfaceMAC]($interfaceIP)" >> "$NIC_config_success_file_path" logprnt "configure_NIC__SUCCESS__$interface[$interfaceMAC]($interfaceIP)" return 0 } ########################################################################## # Returns 0 if the setting interface to staticIP was successful do_staticIPandMTU_config() # { local exit_status local interface="$1" local timeout_in_secs=$2 local staticIP="$3" local staticIPmask="$4" local interfaceMAC local staticIP_log_file local is_specifier_bad local itrCntr local interfaceState local interfaceState # changed by Mike Hollowelll Arrowhead systems Ltd Oct 2007 local getMTU=$5 local interfaceMTU=${getMTU:=1500} # end interfaceMAC=$(net_MAC_of_interface "$interface") if [ -z "$interfaceMAC" ]; then echo "ERROR__staticIP_given_interface_bad![$interface]" return 1 fi staticIP_log_file=$(get_NIC_config_log_file_path "$interface") if [ "$?" != '0' ]; then echo "ERROR__staticIP_given_interface_bad?[$interface]" exit 1 fi echo "" >> "$staticIP_log_file" echo '> "$staticIP_log_file" echo '' >> "$staticIP_log_file" while true do if [ "$timeout_in_secs" -lt 30 ]; then gvnlogprnt "$staticIP_log_file" "ERROR__staticIP_given_timeout_too_small[$timeout_in_secs]" exit_status=113 break fi echo "$staticIP" | grep -q \ '^[[:digit:]][[:digit:]]*[.][[:digit:]][[:digit:]]*[.][[:digit:]][[:digit:]]*[.][[:digit:]][[:digit:]]*$' if [ "$?" != '0' ]; then gvnlogprnt "$staticIP_log_file" "ERROR__staticIP_given_IP_bad[$staticIP]" exit_status=111 break fi echo "$staticIPmask" | grep -q \ '^[[:digit:]][[:digit:]]*[.][[:digit:]][[:digit:]]*[.][[:digit:]][[:digit:]]*[.][[:digit:]][[:digit:]]*$' if [ "$?" != '0' ]; then gvnlogprnt "$staticIP_log_file" "ERROR__staticIP_given_IPmask_bad[$staticIPmask]" exit_status=109 break fi # changed by Mike Hollowelll Arrowhead systems Ltd Oct 2007 echo "$interfaceMTU" | grep -q \ '^[[:digit:]][[:digit:]]*$' if [ "$?" != '0' ]; then gvnlogprnt "$staticIP_log_file" "ERROR__staticIP_given_MTU_bad[$interfaceMTU]" exit_status=109 break fi # end ifconfig "$interface" inet 0 2> /dev/null 1> /dev/null ifconfig "$interface" up 2> /dev/null 1> /dev/null exit_status=$? if [ "$exit_status" != '0' ]; then gvnlogprnt "$staticIP_log_file" "ERROR__staticIP_up_failed[$interface]" break fi sleep 2 itrCntr=0 while true do interfaceState=$(ifconfig "$interface" 2>/dev/null | grep 'MTU:[[:digit:]][[:digit:]]*[[:space:]][[:space:]]*Metric:[[:digit:]][[:digit:]]*$' | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //') interfaceState=" $interfaceState " echo "$interfaceState" | grep -q ' UP ' if [ "$?" = '0' ]; then echo "$interfaceState" | grep -q ' RUNNING ' if [ "$?" = '0' ]; then break; else gvnlogprnt "$staticIP_log_file" "WARNING__staticIP_pre_NIC_UP_but_not_RUNNING[$interface]($itrCntr)" fi else gvnlogprnt "$staticIP_log_file" "WARNING__staticIP_pre_NIC_not_UP[$interface]($itrCntr)" fi if [ $itrCntr -gt $timeout_in_secs ]; then gvnlogprnt "$staticIP_log_file" "ERROR__staticIP_pre_NIC_unresponsive[$interface]($itrCntr)" exit_status=107 break fi sleep 10 let itrCntr="$itrCntr+10" done if [ "$exit_status" != '0' ]; then break fi # added by Mike Hollowelll Arrowhead systems Ltd Oct 2007 # ifconfig "$interface" "$staticIP" netmask "$staticIPmask" ifconfig "$interface" "$staticIP" netmask "$staticIPmask" mtu $interfaceMTU # end of add exit_status=$? if [ "$exit_status" != '0' ]; then gvnlogprnt "$staticIP_log_file" "ERROR__staticIP_ifconfig_failed[$interface_$staticIP_$staticIPmask_MTU_$interfaceMTU]($exit_status)" ifconfig "$interface" inet 0 2> /dev/null 1> /dev/null break fi sleep 2 itrCntr=0 while true do interfaceState=$(ifconfig "$interface" 2>/dev/null | grep 'MTU:[[:digit:]][[:digit:]]*[[:space:]][[:space:]]*Metric:[[:digit:]][[:digit:]]*$' | sed -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ //') interfaceState=" $interfaceState " echo "$interfaceState" | grep -q ' UP ' if [ "$?" = '0' ]; then echo "$interfaceState" | grep -q ' RUNNING ' if [ "$?" = '0' ]; then break; else gvnlogprnt "$staticIP_log_file" "WARNING__staticIP_pst_NIC_UP_but_not_RUNNING[$interface]($itrCntr)" fi else gvnlogprnt "$staticIP_log_file" "WARNING__staticIP_pst_NIC_not_UP[$interface]($itrCntr)" fi if [ $itrCntr -gt $timeout_in_secs ]; then gvnlogprnt "$staticIP_log_file" "ERROR__staticIP_pst_NIC_unresponsive[$interface]($itrCntr)" exit_status=105 break fi sleep 10 let itrCntr="$itrCntr+10" done if [ "$exit_status" != '0' ]; then break fi ifconfig "$interface" | head -3 >> "$staticIP_log_file" echo '' >> "$staticIP_log_file" echo ']]>' >> "$staticIP_log_file" echo 'SUCCESS' >> "$staticIP_log_file" echo '' >> "$staticIP_log_file" return 0 done echo '' >> "$staticIP_log_file" echo ']]>' >> "$staticIP_log_file" echo 'FAILURE' >> "$staticIP_log_file" echo '' >> "$staticIP_log_file" return $exit_status } ########################################################################## configure_route() # { local exit_status local route_args="$1" logprnt "/sbin/route $route_args" log_execution "$log_file_path" /sbin/route $route_args exit_status=$? /sbin/route 2>&1 | tee -a $log_file_path return $exit_status } ########################################################################## expected_tag_search() # { local expected_tag="$1" local raw_line local line expected_tag_contents="" # global while read raw_line do # Remove leading and trailing whitespace and XML comment lines line=$(echo "$raw_line" | sed 's/[[:space:]]*[[:space:]]*//g;s/^[[:space:]]*//;s/[[:space:]]*$//') if [ -z "$line" ]; then continue fi is_expected=$(echo "$line" | sed "s/^<$expected_tag>.*<\/$expected_tag>$//") if [ -z "$is_expected" ]; then expected_tag_contents=$(echo "$line" | sed "s/^<$expected_tag>[[:space:]]*//;s/[[:space:]]*<\/$expected_tag>$//") return fi done } ########################################################################## if [ -f ./initiatorname.iscsi ]; then iSCSI_initiatorname=$(cat ./initiatorname.iscsi | grep '^InitiatorName=' | sed 's/^InitiatorName=//') if [ -n "$iSCSI_initiatorname" ]; then if [ "$iSCSI_initiatorname" != "${iSCSI_initiatorname#iqn.}" ]; then log_execution "$log_file_path" /bin/cp -f ./initiatorname.iscsi "$iSCSI_initiatorname_file" exit_status=$? if [ "$exit_status" != "0" ]; then logprnt "ERROR : install failed : /bin/cp -f ./initiatorname.iscsi $iSCSI_initiatorname_file" fi iSCSI_initiatorname=$(cat "$iSCSI_initiatorname_file" | grep '^InitiatorName=' | sed 's/^InitiatorName=//') else if [ "$iSCSI_initiatorname" = "<<<>>>" ]; then logprnt 'Generating iSCSI initiator name' mgmt_server_iface=$(net_primary_interface) generate_iscsi_initiatorname_file "$mgmt_server_iface" "$iSCSI_initiatorname_file" iSCSI_initiatorname=$(cat "$iSCSI_initiatorname_file" | grep '^InitiatorName=' | sed 's/^InitiatorName=//') else logprnt "ERROR : bad given initiatorname.iscsi [$iSCSI_initiatorname]" cat ./initiatorname.iscsi 2>&1 | tee -a $log_file_path iSCSI_initiatorname='' fi fi fi logprnt "iSCSI Initiator Name = $iSCSI_initiatorname" fi logprnt "Processing network config directives : default_NIC_timeout = $default_NIC_timeout" cat ./network_config_directives.xml | \ ( is_expected="false" while read raw_line do # Remove leading and trailing whitespace and XML comment lines line=$(echo "$raw_line" | sed 's/[[:space:]]*[[:space:]]*//g;s/^[[:space:]]*//;s/[[:space:]]*$//') if [ -z "$line" ]; then continue fi is_expected=$(echo "$line" | sed 's/^$//') if [ -z "$is_expected" ]; then break fi done if [ -z "$is_expected" ]; then # Zero any temporary CfgNICopts temporaryExtraTime=0 while read raw_line do # Remove leading and trailing whitespace and XML comment lines line=$(echo "$raw_line" | sed 's/[[:space:]]*[[:space:]]*//g;s/^[[:space:]]*//;s/[[:space:]]*$//') if [ -z "$line" ]; then continue fi is_expected=$(echo "$line" | sed 's/^<\/NetworkCfgDirectives>$//') if [ -z "$is_expected" ]; then break fi is_expected=$(echo "$line" | sed 's/^.*<\/CfgNICopt>$//') if [ -z "$is_expected" ]; then theNICopt=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*<\/CfgNICopt>$//') echo "$theNICopt" | grep -q '^extraTime=[[:digit:]][[:digit:]]*$' if [ "$?" = '0' ]; then temporaryExtraTime=$(echo "$theNICopt" | sed 's/^extraTime=//') let the_NIC_timeout="$default_NIC_timeout+$temporaryExtraTime" logprnt "CfgNICopt: $theNICopt : Accepted = $the_NIC_timeout" continue fi logprnt "ERROR : unknown option '$theNICopt'" continue fi let the_NIC_timeout="$default_NIC_timeout+$temporaryExtraTime" temporaryExtraTime=0 is_expected=$(echo "$line" | sed 's/^.*<\/CfgNICdhcp>$//') if [ -z "$is_expected" ]; then netw_cfg_interface=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*<\/CfgNICdhcp>$//') if [ "${netw_cfg_interface#eth}" = "$netw_cfg_interface" ]; then netw_cfg_interface="MAC($netw_cfg_interface)" fi # logprnt "DCHP |||| ${netw_cfg_interface}:dhcp" configure_NIC "${netw_cfg_interface}:dhcp" $the_NIC_timeout continue fi is_expected=$(echo "$line" | sed 's/^.*<\/CfgRoute>$//') if [ -z "$is_expected" ]; then netw_cfg_route_args=$(echo "$line" | sed 's/^[[:space:]]*//;s/[[:space:]]*<\/CfgRoute>$//') # logprnt "ROUTE ||| '$netw_cfg_route_args'" configure_route "$netw_cfg_route_args" continue fi if [ -n "${line%}" ]; then logprnt "ERROR : bad network_config_directives.xml line '$line' raw '$raw_line'" continue fi expected_tag_search "Interface" # sets expected_tag_contents netw_cfg_interface="$expected_tag_contents" if [ -z "$netw_cfg_interface" ]; then logprnt "ERROR : unexpected EOF while searching for '...' group" break fi expected_tag_search "StaticIP" # sets expected_tag_contents netw_cfg_staticIP="$expected_tag_contents" if [ -z "$netw_cfg_staticIP" ]; then logprnt "ERROR : unexpected EOF while searching for '...' group" break fi expected_tag_search "StaticIPmask" # sets expected_tag_contents netw_cfg_staticIPmask="$expected_tag_contents" if [ -z "$netw_cfg_staticIPmask" ]; then logprnt "ERROR : unexpected EOF while searching for '...' group" break fi # changed by Mike Hollowelll Arrowhead systems Ltd Oct 2007 expected_tag_search "StaticIPmtu" # sets expected_tag_contents netw_cfg_staticIPmtu="$expected_tag_contents" if [ -z "$netw_cfg_staticIPmtu" ]; then logprnt "No Setting MTU to 1500" netw_cfg_staticIPmtu=1500 line="" else while read raw_line do # Remove leading and trailing whitespace and XML comment lines line=$(echo "$raw_line" | sed 's/[[:space:]]*[:space:]]*//g;s/^[[:space:]]*//;s/[[:space:]]*$//') if [ -z "$line" ]; then continue fi break; done fi # end logprnt "" logprnt "end section line $line" is_expected=$(echo "$line" | sed "s/^<\/CfgNICstatic>$//") if [ -n "$is_expected" ]; then logprnt "ERROR : unexpected EOF while searching for closing ''" logprnt "ERROR: line=$line" break fi if [ "${netw_cfg_interface#eth}" = "$netw_cfg_interface" ]; then netw_cfg_interface="MAC($netw_cfg_interface)" fi # logprnt "STATIC || ${netw_cfg_interface}:${netw_cfg_staticIP}:${netw_cfg_staticIPmask}" # configure_NIC "${netw_cfg_interface}:${netw_cfg_staticIP}:${netw_cfg_staticIPmask}" $the_NIC_timeout # changed by Mike Hollowelll Arrowhead systems Ltd Oct 2007 configure_NIC "${netw_cfg_interface}:${netw_cfg_staticIP}:${netw_cfg_staticIPmask}:${netw_cfg_staticIPmtu}" $the_NIC_timeout # end done fi ) ########################################################################## if [ -n "$cfg_NICs" ]; then logprnt "cfg_NICs '$cfg_NICs'" for NIC_to_cfg in $cfg_NICs do configure_NIC "$NIC_to_cfg" done fi ########################################################################## logprnt "http: configure_node done" exit 0 # Delete node config contents