瀏覽代碼

force password

Bob Mottram 10 年之前
父節點
當前提交
73f1d58411
共有 1 個檔案被更改,包括 16 行新增30 行删除
  1. 16
    30
      install-freedombone.sh

+ 16
- 30
install-freedombone.sh 查看文件

319
 WIFI_INTERFACE="wlan0"
319
 WIFI_INTERFACE="wlan0"
320
 
320
 
321
 # Whether to always force there to exist a wifi password
321
 # Whether to always force there to exist a wifi password
322
-WIFI_FORCE_PASSWORD="no"
322
+WIFI_FORCE_PASSWORD="yes"
323
 
323
 
324
 # Channel number for wifi hotspot
324
 # Channel number for wifi hotspot
325
 WIFI_HOTSPOT_CHANNEL=7
325
 WIFI_HOTSPOT_CHANNEL=7
326
 
326
 
327
+# Mode such as "g" or "n"
328
+WIFI_HOTSPOT_MODE="g"
329
+
327
 # message if something fails to install
330
 # message if something fails to install
328
 CHECK_MESSAGE="Check your internet connection, /etc/network/interfaces and /etc/resolv.conf, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list."
331
 CHECK_MESSAGE="Check your internet connection, /etc/network/interfaces and /etc/resolv.conf, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list."
329
 
332
 
409
       if grep -q "WIFI_INTERFACE" $CONFIGURATION_FILE; then
412
       if grep -q "WIFI_INTERFACE" $CONFIGURATION_FILE; then
410
           WIFI_INTERFACE=$(grep "WIFI_INTERFACE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
413
           WIFI_INTERFACE=$(grep "WIFI_INTERFACE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
411
       fi
414
       fi
415
+      if grep -q "WIFI_HOTSPOT_MODE" $CONFIGURATION_FILE; then
416
+          WIFI_HOTSPOT_MODE=$(grep "WIFI_HOTSPOT_MODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
417
+      fi
412
       if grep -q "WIFI_HOTSPOT_CHANNEL" $CONFIGURATION_FILE; then
418
       if grep -q "WIFI_HOTSPOT_CHANNEL" $CONFIGURATION_FILE; then
413
           WIFI_HOTSPOT_CHANNEL=$(grep "WIFI_HOTSPOT_CHANNEL" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
419
           WIFI_HOTSPOT_CHANNEL=$(grep "WIFI_HOTSPOT_CHANNEL" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
414
       fi
420
       fi
7192
   echo '' >> /etc/hostapd/hostapd.conf
7198
   echo '' >> /etc/hostapd/hostapd.conf
7193
   echo "hw_mode=$WIFI_HOTSPOT_MODE" >> /etc/hostapd/hostapd.conf
7199
   echo "hw_mode=$WIFI_HOTSPOT_MODE" >> /etc/hostapd/hostapd.conf
7194
   echo '' >> /etc/hostapd/hostapd.conf
7200
   echo '' >> /etc/hostapd/hostapd.conf
7195
-  echo '# # Static WPA2 key configuration' >> /etc/hostapd/hostapd.conf
7196
-  echo '# #1=wpa1, 2=wpa2, 3=both' >> /etc/hostapd/hostapd.conf
7197
-  echo 'wpa=2' >> /etc/hostapd/hostapd.conf
7198
-  echo '' >> /etc/hostapd/hostapd.conf
7199
-  echo "wpa_passphrase=$WIFI_PASSWORD" >> /etc/hostapd/hostapd.conf
7200
-  echo '' >> /etc/hostapd/hostapd.conf
7201
-  echo '## Key management algorithms ##' >> /etc/hostapd/hostapd.conf
7202
   if [ ! $WIFI_PASSWORD ]; then
7201
   if [ ! $WIFI_PASSWORD ]; then
7202
+      echo 'auth_algs=0' >> /etc/hostapd/hostapd.conf
7203
       echo 'wpa_key_mgmt=WPA-NONE' >> /etc/hostapd/hostapd.conf
7203
       echo 'wpa_key_mgmt=WPA-NONE' >> /etc/hostapd/hostapd.conf
7204
   else
7204
   else
7205
+      echo '' >> /etc/hostapd/hostapd.conf
7206
+      echo '# # Static WPA2 key configuration' >> /etc/hostapd/hostapd.conf
7207
+      echo '# #1=wpa1, 2=wpa2, 3=both' >> /etc/hostapd/hostapd.conf
7208
+      echo 'wpa=2' >> /etc/hostapd/hostapd.conf
7209
+      echo '' >> /etc/hostapd/hostapd.conf
7210
+      echo "wpa_passphrase=$WIFI_PASSWORD" >> /etc/hostapd/hostapd.conf
7205
       echo 'wpa_key_mgmt=WPA-PSK' >> /etc/hostapd/hostapd.conf
7211
       echo 'wpa_key_mgmt=WPA-PSK' >> /etc/hostapd/hostapd.conf
7206
-  fi
7207
-  echo '#' >> /etc/hostapd/hostapd.conf
7208
-  echo '## Set cipher suites (encryption algorithms) ##' >> /etc/hostapd/hostapd.conf
7209
-  echo '## TKIP = Temporal Key Integrity Protocol' >> /etc/hostapd/hostapd.conf
7210
-  echo '## CCMP = AES in Counter mode with CBC-MAC' >> /etc/hostapd/hostapd.conf
7211
-  if [ ! $WIFI_PASSWORD ]; then
7212
-      echo 'wpa_pairwise=NONE' >> /etc/hostapd/hostapd.conf
7213
-  else
7214
       echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf
7212
       echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf
7213
+      echo 'auth_algs=1' >> /etc/hostapd/hostapd.conf
7215
   fi
7214
   fi
7216
-  echo '#rsn_pairwise=CCMP' >> /etc/hostapd/hostapd.conf
7217
-  echo '#' >> /etc/hostapd/hostapd.conf
7218
-  echo '## Shared Key Authentication ##' >> /etc/hostapd/hostapd.conf
7219
-  echo 'auth_algs=1' >> /etc/hostapd/hostapd.conf
7220
   echo '## Accept all MAC address ###' >> /etc/hostapd/hostapd.conf
7215
   echo '## Accept all MAC address ###' >> /etc/hostapd/hostapd.conf
7221
   echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
7216
   echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
7222
   echo '#enables/disables broadcasting the ssid' >> /etc/hostapd/hostapd.conf
7217
   echo '#enables/disables broadcasting the ssid' >> /etc/hostapd/hostapd.conf
7225
   echo 'eapol_key_index_workaround=0' >> /etc/hostapd/hostapd.conf
7220
   echo 'eapol_key_index_workaround=0' >> /etc/hostapd/hostapd.conf
7226
 
7221
 
7227
   service hostapd restart
7222
   service hostapd restart
7228
-  if [ ! "$?" = "0" ]; then
7229
-      echo 'Unable to restart hostapd'
7230
-      systemctl status hostapd.service
7231
-      exit 854
7232
-  fi
7223
+  systemctl daemon-reload
7233
 
7224
 
7234
   if ! grep -q "subnet 192.168.4.0 netmask 255.255.255.0" /etc/dhcp/dhcpd.conf; then
7225
   if ! grep -q "subnet 192.168.4.0 netmask 255.255.255.0" /etc/dhcp/dhcpd.conf; then
7235
       echo '' >> /etc/dhcp/dhcpd.conf
7226
       echo '' >> /etc/dhcp/dhcpd.conf
7241
   sed -i "s/INTERFACES=.*/INTERFACES='$WIFI_INTERFACE'/g" /etc/default/isc-dhcp-server
7232
   sed -i "s/INTERFACES=.*/INTERFACES='$WIFI_INTERFACE'/g" /etc/default/isc-dhcp-server
7242
 
7233
 
7243
   service isc-dhcp-server restart
7234
   service isc-dhcp-server restart
7244
-  if [ ! "$?" = "0" ]; then
7245
-      echo 'Unable to restart isc-dhcp-server'
7246
-      systemctl status isc-dhcp-server.service
7247
-      exit 856
7248
-  fi
7249
 
7235
 
7250
   # Add details to the README file
7236
   # Add details to the README file
7251
   if ! grep -q "Wifi Hotspot" /home/$MY_USERNAME/README; then
7237
   if ! grep -q "Wifi Hotspot" /home/$MY_USERNAME/README; then