Bläddra i källkod

More wifi hotspot configuration

Bob Mottram 10 år sedan
förälder
incheckning
d220f35128
1 ändrade filer med 34 tillägg och 17 borttagningar
  1. 34
    17
      install-freedombone.sh

+ 34
- 17
install-freedombone.sh Visa fil

7130
       echo 'enable_wifi_hotspot was called before the random number generator was initialised'
7130
       echo 'enable_wifi_hotspot was called before the random number generator was initialised'
7131
       exit 853
7131
       exit 853
7132
   fi
7132
   fi
7133
-  apt-get -y install hostapd dnsmasq
7133
+
7134
+  if ! grep -q "Wifi hotspot" $COMPLETION_FILE; then
7135
+      echo '' >> /etc/network/interfaces
7136
+      echo '# Wifi hotspot' >> /etc/network/interfaces
7137
+      echo "auto $WIFI_INTERFACE" >> /etc/network/interfaces
7138
+      echo "iface $WIFI_INTERFACE inet static" >> /etc/network/interfaces
7139
+      echo '        address 192.168.4.1' >> /etc/network/interfaces
7140
+      echo '        network 192.168.4.0' >> /etc/network/interfaces
7141
+      echo '        netmask 255.255.255.0' >> /etc/network/interfaces
7142
+      echo '        broadcast 192.168.4.255' >> /etc/network/interfaces
7143
+      service networking restart
7144
+  fi
7145
+
7146
+  apt-get -y install hostapd isc-dhcp-server
7134
 
7147
 
7135
   if [ ! -f /etc/default/hostapd ]; then
7148
   if [ ! -f /etc/default/hostapd ]; then
7136
-	  echo 'Unable to find /etc/default/hostapd. hostapd may not have installed correctly'
7137
-	  exit 490
7149
+      echo 'Unable to find /etc/default/hostapd. hostapd may not have installed correctly'
7150
+      exit 490
7138
   fi
7151
   fi
7139
   if [ ! -f /etc/dnsmasq.conf ]; then
7152
   if [ ! -f /etc/dnsmasq.conf ]; then
7140
-	  echo 'Unable to find /etc/dnsmasq.conf. dnsmasq may not have installed correctly'
7141
-	  exit 492
7153
+      echo 'Unable to find /etc/dnsmasq.conf. dnsmasq may not have installed correctly'
7154
+      exit 492
7142
   fi
7155
   fi
7143
 
7156
 
7144
   get_wifi_essid
7157
   get_wifi_essid
7198
 
7211
 
7199
   service hostapd restart
7212
   service hostapd restart
7200
   if [ ! "$?" = "0" ]; then
7213
   if [ ! "$?" = "0" ]; then
7201
-	  echo 'Unable to restart hostapd'
7202
-	  systemctl status hostapd.service
7203
-	  exit 854
7214
+      echo 'Unable to restart hostapd'
7215
+      systemctl status hostapd.service
7216
+      exit 854
7204
   fi
7217
   fi
7205
 
7218
 
7206
-  sed -i "s/#interface=/interface=$WIFI_INTERFACE/" /etc/dnsmasq.conf
7207
-  sed -i 's/#dhcp-range=192.168.0.50,192.168.0.150,12h/dhcp-range=192.168.1.1,192.168.1.50,12h/g' /etc/dnsmasq.conf
7219
+  if ! grep -q "subnet 192.168.4.0 netmask 255.255.255.0" $COMPLETION_FILE; then
7220
+      echo '' >> /etc/dhcp/dhcpd.conf
7221
+      echo 'subnet 192.168.4.0 netmask 255.255.255.0 {' >> /etc/dhcp/dhcpd.conf
7222
+      echo '  range 192.168.4.2 192.168.4.10;' >> /etc/dhcp/dhcpd.conf
7223
+      echo '}' >> /etc/dhcp/dhcpd.conf
7224
+  fi
7208
 
7225
 
7209
-  service dnsmasq restart
7226
+  service isc-dhcp-server restart
7210
   if [ ! "$?" = "0" ]; then
7227
   if [ ! "$?" = "0" ]; then
7211
-	  echo 'Unable to restart dnsmasq'
7212
-	  systemctl status dnsmasq.service
7213
-	  exit 856
7228
+      echo 'Unable to restart isc-dhcp-server'
7229
+      systemctl status isc-dhcp-server.service
7230
+      exit 856
7214
   fi
7231
   fi
7215
 
7232
 
7216
   # Add details to the README file
7233
   # Add details to the README file
7231
   if grep -Fxq "enable_wifi" $COMPLETION_FILE; then
7248
   if grep -Fxq "enable_wifi" $COMPLETION_FILE; then
7232
       return
7249
       return
7233
   fi
7250
   fi
7234
-  if [[ $ENABLE_WIFI != "yes" || $ENABLE_WIFI_HOTSPOT != "yes" ]]; then
7251
+  if [[ $ENABLE_WIFI != "yes" ]]; then
7235
       return
7252
       return
7236
   fi
7253
   fi
7237
   if ! grep -Fxq "random_number_generator" $COMPLETION_FILE; then
7254
   if ! grep -Fxq "random_number_generator" $COMPLETION_FILE; then
7260
 
7277
 
7261
   service networking restart
7278
   service networking restart
7262
   if [ ! "$?" = "0" ]; then
7279
   if [ ! "$?" = "0" ]; then
7263
-	  echo 'Unable to restart networking'
7264
-	  exit 855
7280
+      echo 'Unable to restart networking'
7281
+      exit 855
7265
   fi
7282
   fi
7266
 
7283
 
7267
   # Add details to the README file
7284
   # Add details to the README file