summaryrefslogtreecommitdiffstats
path: root/kernel/filesystems/nfs/connectathon/hostnamefix.patch
blob: 344d3564caad88ab0776190cec12f49f628e27dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- cthon04/server.orig	2011-11-25 04:39:45.000000000 -0500
+++ cthon04/server	2011-11-25 04:43:57.000000000 -0500
@@ -121,8 +121,32 @@
 
 # mount doesn't always return error code if it fails, so lets
 # ask here just in case
-HOSTNAME=`hostname`
-HOSTNAME=`expr $HOSTNAME : '\([^.]*\)'`
+#HOSTNAME=`hostname`
+#HOSTNAME=`expr $HOSTNAME : '\([^.]*\)'`
+
+my_hostname=`hostname --fqdn`
+fqdn_dots=`echo $my_hostname | grep -o "\." | wc -l`
+
+if [ "$fqdn_dots" -eq 0 ]; then
+    echo dots: $fqdn_dots
+    # borrowed this from virtinstall
+    def_line=$(ip route list | grep ^default)
+    defnum=$(perl -e 'for ($i=0; $i<$#ARGV; $i++ ) { if ($ARGV[$i] eq "dev" ) { $_ = $ARGV[ $i + 1 ]; if ( /^(\w*)(\d+)/ ) { print "$_ $2"; } } }' ${def_line} )
+    actnum=$(echo ${defnum} | awk '{print $2}')
+    netdev=$(echo ${defnum} | awk '{print $1}')
+
+    random=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8`
+    mac=`ip link show ${netdev} | grep 'link\/ether' | head -1 | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
+    if [ -n "mac" ]; then
+        my_hostname=`echo "mac-$mac-$random" | sed 's/:/-/g'`
+    else
+        my_hostname="random-$random"
+    fi
+fi
+
+HOSTNAME="$my_hostname"
+
+
 NFSTESTDIR=$MNTPOINT/$HOSTNAME.test
 export NFSTESTDIR
 echo $DASHN "Start tests on path $NFSTESTDIR [y/n]?" "$BLC"