Your Name 1 year ago
parent
commit
069d82d05b
1 changed files with 32 additions and 19 deletions
  1. 32 19
      automated_tools/install_hotspot.sh

+ 32 - 19
automated_tools/install_hotspot.sh

@@ -9,25 +9,27 @@ fi
 
 
 echo "
-$(tput setaf 2)              .~~.   .~~.
-$(tput setaf 6)   /         $(tput setaf 2)'. \ ' ' / .'$(tput setaf 6)         \ 
-$(tput setaf 6)  |   /       $(tput setaf 1).~ .~~~..~.$(tput setaf 6)       \   |
-$(tput setaf 6) |   |   /  $(tput setaf 1) : .~.'~'.~. :$(tput setaf 6)   \   |   |
-$(tput setaf 6)|   |   |   $(tput setaf 1)~ (   ) (   ) ~$(tput setaf 6)   |   |   |
-$(tput setaf 6)|   |  |   $(tput setaf 1)( : '~'.~.'~' : )$(tput setaf 6)   |  |   |
-$(tput setaf 6)|   |   |   $(tput setaf 1)~ .~ (   ) ~. ~ $(tput setaf 6)  |   |   |
-$(tput setaf 6) |   |   \   $(tput setaf 1)(  : '~' :  )$(tput setaf 6)   /   |   |
-$(tput setaf 6)  |   \       $(tput setaf 1)'~ .~~~. ~'$(tput setaf 6)       /   |
-$(tput setaf 6)   \              $(tput setaf 1)'~'$(tput setaf 6)              / 
+$(tput setaf 2)              .~~.   .~~.
+$(tput setaf 6)   /         $(tput setaf 2)'. \ ' ' / .'$(tput setaf 6)         \ 
+$(tput setaf 6)  |   /       $(tput setaf 1).~ .~~~..~.$(tput setaf 6)       \   |
+$(tput setaf 6) |   |   /  $(tput setaf 1) : .~.'~'.~. :$(tput setaf 6)   \   |   |
+$(tput setaf 6)|   |   |   $(tput setaf 1)~ (   ) (   ) ~$(tput setaf 6)   |   |   |
+$(tput setaf 6)|   |  |   $(tput setaf 1)( : '~'.~.'~' : )$(tput setaf 6)   |  |   |
+$(tput setaf 6)|   |   |   $(tput setaf 1)~ .~ (   ) ~. ~ $(tput setaf 6)  |   |   |
+$(tput setaf 6) |   |   \   $(tput setaf 1)(  : '~' :  )$(tput setaf 6)   /   |   |
+$(tput setaf 6)  |   \       $(tput setaf 1)'~ .~~~. ~'$(tput setaf 6)       /   |
+$(tput setaf 6)   \              $(tput setaf 1)'~'$(tput setaf 6)              / 
 
 "
 
 echo "$(tput setaf 6)This script will configure your Raspberry Pi as a wireless access point.$(tput sgr0)"
+read -p "$(tput bold ; tput setaf 2)Press [Enter] to begin, [Ctrl-C] to abort...$(tput sgr0)"
 
 echo "$(tput setaf 6)Updating packages...$(tput sgr0)"
+apt-get update -y
 
 echo "Installing dnsmasq"
-apt install dnsmasq iptables -y
+apt install dnsmasq -y
 systemctl stop dnsmasq
 
 echo "Configuring Wlan0 static IP for 192.168.42.1/24"
@@ -41,8 +43,7 @@ service dhcpcd restart
 echo "Configuring dnsmasq..."
 mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
 echo "interface=wlan0      # Use the require wireless interface - usually wlan0
-dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
-address=/freedompi.local/192.168.4.1" > /etc/dnsmasq.conf
+dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h" > /etc/dnsmasq.conf
 
 echo "Enabling dnsmasq and restart..."
 systemctl unmask dnsmasq
@@ -52,7 +53,8 @@ systemctl restart dnsmasq
 
 
 echo "Unlock wlan soft lock with rfkill..."
-if ! command -v rfkill &> /dev/null; then
+if command -v rfkill &> /dev/null
+then
     rfkill unblock wlan
 fi
 
@@ -61,16 +63,27 @@ apt-get install hostapd -y
 systemctl unmask hostapd
 systemctl enable hostapd
 
+echo "Configuring Hostapd !"
+echo "Choose the hostname for your new network (1-32 char, try to privilege ASCII chars) :"
+read ssid
+
+echo "Choose the password for your new network (minimum 8 char):"
+read passphrase
+
 echo "interface=wlan0
 driver=nl80211
-ssid=Open freedompi.local
+ssid=$ssid
 hw_mode=g
 channel=7
 wmm_enabled=0
 macaddr_acl=0
 auth_algs=1
 ignore_broadcast_ssid=0
-wpa=0
+wpa=2
+wpa_passphrase=$passphrase
+wpa_key_mgmt=WPA-PSK
+wpa_pairwise=TKIP
+rsn_pairwise=CCMP
 " > /etc/hostapd/hostapd.conf
 
 echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' >> /etc/default/hostapd
@@ -99,7 +112,7 @@ sh -c "iptables-save > /etc/iptables.ipv4.nat"
 echo "Add auto start on startup the Raspberry Pi."
 sed -i '/exit 0/ i iptables-restore < /etc/iptables.ipv4.nat' /etc/rc.local
 
-# echo "$(tput setaf 6)Rebooting...$(tput sgr0)"
-# reboot
+echo "$(tput setaf 6)Rebooting...$(tput sgr0)"
+reboot
 
-exit 0
+exit 0