More wifi hotspot configuration

This commit is contained in:
Bob Mottram 2014-12-25 16:31:34 +00:00
parent ebe5d5096c
commit d220f35128
1 changed files with 34 additions and 17 deletions

View File

@ -7130,7 +7130,20 @@ function enable_wifi_hotspot {
echo 'enable_wifi_hotspot was called before the random number generator was initialised'
exit 853
fi
apt-get -y install hostapd dnsmasq
if ! grep -q "Wifi hotspot" $COMPLETION_FILE; then
echo '' >> /etc/network/interfaces
echo '# Wifi hotspot' >> /etc/network/interfaces
echo "auto $WIFI_INTERFACE" >> /etc/network/interfaces
echo "iface $WIFI_INTERFACE inet static" >> /etc/network/interfaces
echo ' address 192.168.4.1' >> /etc/network/interfaces
echo ' network 192.168.4.0' >> /etc/network/interfaces
echo ' netmask 255.255.255.0' >> /etc/network/interfaces
echo ' broadcast 192.168.4.255' >> /etc/network/interfaces
service networking restart
fi
apt-get -y install hostapd isc-dhcp-server
if [ ! -f /etc/default/hostapd ]; then
echo 'Unable to find /etc/default/hostapd. hostapd may not have installed correctly'
@ -7203,13 +7216,17 @@ function enable_wifi_hotspot {
exit 854
fi
sed -i "s/#interface=/interface=$WIFI_INTERFACE/" /etc/dnsmasq.conf
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
if ! grep -q "subnet 192.168.4.0 netmask 255.255.255.0" $COMPLETION_FILE; then
echo '' >> /etc/dhcp/dhcpd.conf
echo 'subnet 192.168.4.0 netmask 255.255.255.0 {' >> /etc/dhcp/dhcpd.conf
echo ' range 192.168.4.2 192.168.4.10;' >> /etc/dhcp/dhcpd.conf
echo '}' >> /etc/dhcp/dhcpd.conf
fi
service dnsmasq restart
service isc-dhcp-server restart
if [ ! "$?" = "0" ]; then
echo 'Unable to restart dnsmasq'
systemctl status dnsmasq.service
echo 'Unable to restart isc-dhcp-server'
systemctl status isc-dhcp-server.service
exit 856
fi
@ -7231,7 +7248,7 @@ function enable_wifi {
if grep -Fxq "enable_wifi" $COMPLETION_FILE; then
return
fi
if [[ $ENABLE_WIFI != "yes" || $ENABLE_WIFI_HOTSPOT != "yes" ]]; then
if [[ $ENABLE_WIFI != "yes" ]]; then
return
fi
if ! grep -Fxq "random_number_generator" $COMPLETION_FILE; then