Browse Source

Set the hostname for mesh peers

Bob Mottram 8 years ago
parent
commit
b3114fc58e
2 changed files with 16 additions and 0 deletions
  1. 1
    0
      src/freedombone-image-customise
  2. 15
    0
      src/freedombone-image-mesh

+ 1
- 0
src/freedombone-image-customise View File

@@ -1051,6 +1051,7 @@ chroot "$rootdir" apt-get install -y libnss-mdns libnss-myhostname libnss-gw-nam
1051 1051
 chroot "$rootdir" apt-get install -y locales locales-all debconf wireless-tools wpasupplicant
1052 1052
 
1053 1053
 sed -i "s|#host-name=.*|host-name=${PROJECT_NAME}|g" $rootdir/etc/avahi/avahi-daemon.conf
1054
+sed -i "s|host-name=.*|host-name=${PROJECT_NAME}|g" $rootdir/etc/avahi/avahi-daemon.conf
1054 1055
 
1055 1056
 chroot "$rootdir" /bin/bash -x <<EOF
1056 1057
 git clone $PROJECT_REPO /root/$PROJECT_NAME

+ 15
- 0
src/freedombone-image-mesh View File

@@ -42,11 +42,26 @@ TOX_NODES=
42 42
 #  '144.76.60.215,2a01:4f8:191:64d6::1,33445,04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F,sonOfRa,DE'
43 43
 #)
44 44
 
45
+function set_hostname {
46
+	DEFAULT_DOMAIN_NAME="$1"
47
+
48
+	echo "$DEFAULT_DOMAIN_NAME" > /etc/hostname
49
+	hostname $DEFAULT_DOMAIN_NAME
50
+
51
+	if grep -q "127.0.1.1" /etc/hosts; then
52
+		sed -i "s/127.0.1.1.*/127.0.1.1       $DEFAULT_DOMAIN_NAME/g" /etc/hosts
53
+	else
54
+		echo "127.0.1.1  $DEFAULT_DOMAIN_NAME" >> /etc/hosts
55
+	fi
56
+}
57
+
45 58
 function change_avahi_name {
46 59
 	decarray=( 1 2 3 4 5 6 7 8 9 0 )
47 60
 	PEER_ID=${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}
48 61
 	sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" /etc/avahi/avahi-daemon.conf
49 62
 	sed -i "s|host-name=.*|host-name=P$PEER_ID|g" /etc/avahi/avahi-daemon.conf
63
+	set_hostname P$PEER_ID
64
+
50 65
 	echo "New avahi name for this peer is P$PEER_ID"
51 66
 	toilet "mesh-$PEER_ID"
52 67
 	echo $"avahi name changed to P${PEER_ID}.local" >> $INSTALL_LOG