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,15 +7130,28 @@ function enable_wifi_hotspot {
echo 'enable_wifi_hotspot was called before the random number generator was initialised' echo 'enable_wifi_hotspot was called before the random number generator was initialised'
exit 853 exit 853
fi 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 if [ ! -f /etc/default/hostapd ]; then
echo 'Unable to find /etc/default/hostapd. hostapd may not have installed correctly' echo 'Unable to find /etc/default/hostapd. hostapd may not have installed correctly'
exit 490 exit 490
fi fi
if [ ! -f /etc/dnsmasq.conf ]; then if [ ! -f /etc/dnsmasq.conf ]; then
echo 'Unable to find /etc/dnsmasq.conf. dnsmasq may not have installed correctly' echo 'Unable to find /etc/dnsmasq.conf. dnsmasq may not have installed correctly'
exit 492 exit 492
fi fi
get_wifi_essid get_wifi_essid
@ -7198,19 +7211,23 @@ function enable_wifi_hotspot {
service hostapd restart service hostapd restart
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo 'Unable to restart hostapd' echo 'Unable to restart hostapd'
systemctl status hostapd.service systemctl status hostapd.service
exit 854 exit 854
fi fi
sed -i "s/#interface=/interface=$WIFI_INTERFACE/" /etc/dnsmasq.conf if ! grep -q "subnet 192.168.4.0 netmask 255.255.255.0" $COMPLETION_FILE; then
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 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 if [ ! "$?" = "0" ]; then
echo 'Unable to restart dnsmasq' echo 'Unable to restart isc-dhcp-server'
systemctl status dnsmasq.service systemctl status isc-dhcp-server.service
exit 856 exit 856
fi fi
# Add details to the README file # Add details to the README file
@ -7231,7 +7248,7 @@ function enable_wifi {
if grep -Fxq "enable_wifi" $COMPLETION_FILE; then if grep -Fxq "enable_wifi" $COMPLETION_FILE; then
return return
fi fi
if [[ $ENABLE_WIFI != "yes" || $ENABLE_WIFI_HOTSPOT != "yes" ]]; then if [[ $ENABLE_WIFI != "yes" ]]; then
return return
fi fi
if ! grep -Fxq "random_number_generator" $COMPLETION_FILE; then if ! grep -Fxq "random_number_generator" $COMPLETION_FILE; then
@ -7260,8 +7277,8 @@ function enable_wifi {
service networking restart service networking restart
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo 'Unable to restart networking' echo 'Unable to restart networking'
exit 855 exit 855
fi fi
# Add details to the README file # Add details to the README file