From 91e34bf84a01029b2553b988275eb0788e5d38be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=E1=B4=8F=C9=B4=C9=A2=20Jie?= Date: Mon, 2 Jul 2018 17:06:38 +0800 Subject: [PATCH] Fix Ubuntu 18.04 postscript problem (#5356) * Reformat post.ubuntu.common * Revise post.ubuntu.common --- .../xcat/install/scripts/post.ubuntu.common | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu.common b/xCAT-server/share/xcat/install/scripts/post.ubuntu.common index c937a7273..cd592757e 100755 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu.common +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu.common @@ -9,39 +9,32 @@ echo "post scripts" >/root/post.log [ $MASTER_IP ] || export MASTER_IP="#ENV:MASTER_IP#" #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib# -export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# -if [ "$PRINIC" == "mac" ] +export PRINIC="#TABLEBLANKOKAY:noderes:THISNODE:primarynic#" +if [ "$PRINIC" == "mac" ] || [ -z "$PRINIC" ] then export PRINIC='#GETPRINICMAC:THISNODE#' fi -if [ -z "$PRINIC" ] +if [ -n "$PRINIC" ] && [[ "$(echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?)" == "0" ]] then - export PRINIC=eth0 -elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then - #export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` - export PRINIC=`ip -o link|grep -i "$PRINIC" |awk '{print $2}'|sed s/://` + export PRINIC="$(ip -o link | grep -i "$PRINIC" | awk '{print $2}' | sed 's/://')" fi -#IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') -IP=$(ip -4 -o a sh dev $PRINIC | awk '/inet/{print $4}' | head -n 1 | awk -F '/' '{print $1}') -if [ -z $IP ] +IP="$(ip -4 -o a sh dev "$PRINIC" | awk '/inet/{print $4}' | head -n 1 | awk -F '/' '{print $1}')" +if [ -z "$IP" ] then - dhclient $PRINIC - #IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') - IP=$(ip -4 -o a sh dev $PRINIC | awk '/inet/{print $4}' | head -n 1 | awk -F '/' '{print $1}') + dhclient "$PRINIC" + IP=$(ip -4 -o a sh dev "$PRINIC" | awk '/inet/{print $4}' | head -n 1 | awk -F '/' '{print $1}') fi if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then msgutil_r "$MASTER_IP" "debug" "PRINIC=$PRINIC,IP=$IP" "/var/log/xcat/xcat.log" fi - - if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then msgutil_r "$MASTER_IP" "debug" "generating /etc/resolv.conf" "/var/log/xcat/xcat.log" fi echo "search #TABLE:site:key=domain:value#" >/etc/resolv.conf -for i in $(echo #TABLE:site:key=nameservers:value# | tr ',' ' ') +for i in $(echo "#TABLE:site:key=nameservers:value#" | tr ',' ' ') do echo "nameserver $i" done >>/etc/resolv.conf