Browse Source

Separate avahi configuration

Bob Mottram 10 years ago
parent
commit
5641cd3bc8
1 changed files with 24 additions and 2 deletions
  1. 24
    2
      src/freedombone

+ 24
- 2
src/freedombone View File

@@ -1637,6 +1637,27 @@ function install_atheros_wifi {
1637 1637
   echo 'install_atheros_wifi' >> $COMPLETION_FILE
1638 1638
 }
1639 1639
 
1640
+function configure_avahi {
1641
+  if grep -Fxq "configure_avahi" $COMPLETION_FILE; then
1642
+      return
1643
+  fi
1644
+  # only enable avahi if we're doing mesh networking
1645
+  if [[ $ENABLE_BABEL != "yes" && $ENABLE_BATMAN != "yes" && $ENABLE_CJDNS != "yes" ]]; then
1646
+      return
1647
+  fi
1648
+  apt-get -y install avahi-utils avahi-autoipd
1649
+
1650
+  if [ $DEFAULT_DOMAIN_NAME ]; then
1651
+      sed -i "s|#host-name=.*|host-name=$DEFAULT_DOMAIN_NAME|g" /etc/avahi/avahi-daemon.conf
1652
+  else
1653
+      decarray=( 1 2 3 4 5 6 7 8 9 0 )
1654
+      PEER_ID=${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}
1655
+      sed -i "s|#host-name=.*|host-name=freedombone-$PEER_ID|g" /etc/avahi/avahi-daemon.conf
1656
+  fi
1657
+  systemctl restart avahi-daemon
1658
+  echo 'configure_avahi' >> $COMPLETION_FILE
1659
+}
1660
+
1640 1661
 function mesh_babel {
1641 1662
   if grep -Fxq "mesh_babel" $COMPLETION_FILE; then
1642 1663
       return
@@ -1644,7 +1665,7 @@ function mesh_babel {
1644 1665
   if [[ $ENABLE_BABEL != "yes" ]]; then
1645 1666
       return
1646 1667
   fi
1647
-  apt-get -y install babeld avahi-utils avahi-autoipd
1668
+  apt-get -y install babeld
1648 1669
 
1649 1670
   numarray=( 1 2 3 4 5 6 7 8 9 0 )
1650 1671
   a=${numarray[$RANDOM%2]}${numarray[$RANDOM%10]}${numarray[$RANDOM%10]}
@@ -1678,7 +1699,7 @@ function mesh_batman_bridge {
1678 1699
 
1679 1700
   apt-get -y install iproute bridge-utils libnetfilter-conntrack3 batctl
1680 1701
   apt-get -y install python-dev libevent-dev ebtables python-pip git
1681
-  apt-get -y install avahi-utils avahi-autoipd wireless-tools
1702
+  apt-get -y install wireless-tools
1682 1703
 
1683 1704
   install_vpn_tunnel
1684 1705
 
@@ -9851,6 +9872,7 @@ set_your_domain_name
9851 9872
 time_synchronisation
9852 9873
 configure_internet_protocol
9853 9874
 create_git_project
9875
+configure_avahi
9854 9876
 install_atheros_wifi
9855 9877
 mesh_cjdns
9856 9878
 mesh_cjdns_tools