2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-02 11:37:07 +00:00
Gᴏɴɢ Jie 91e34bf84a Fix Ubuntu 18.04 postscript problem (#5356)
* Reformat post.ubuntu.common

* Revise post.ubuntu.common
2018-07-02 17:06:38 +08:00

41 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
#
# Setup hostname
#
echo "post scripts" >/root/post.log
[ $XCATDEBUGMODE ] || export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#"
[ $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" ] || [ -z "$PRINIC" ]
then
export PRINIC='#GETPRINICMAC:THISNODE#'
fi
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="$(ip -o link | grep -i "$PRINIC" | awk '{print $2}' | sed 's/://')"
fi
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=$(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 ',' ' ')
do
echo "nameserver $i"
done >>/etc/resolv.conf