├── AutoHotspot-Setup.tar.xz ├── AutoHotspot-Setup └── Autohotspot │ ├── ChangeLog-Autohotspot-Setup.txt │ ├── ChangeLog-Autohotspot.txt │ ├── ReadMe.txt │ ├── autohotspot-setup.sh │ └── config │ ├── Checklist.md5 │ ├── autohotspot-Net.service │ ├── autohotspot-direct │ ├── autohotspot-direct.service │ ├── autohotspotN │ ├── dhcpcd-SHS.conf │ ├── dhcpcd-SHSN.conf │ ├── dhcpcd-autohs.conf │ ├── dhcpcd-default.conf │ ├── dhcpcd-remove.conf │ ├── dnsmasqAHS.conf │ ├── dnsmasqAHSN.conf │ ├── dnsmasqSHS.conf │ ├── hostapd │ ├── hostapd.conf │ ├── hs-iptables.service │ ├── interfaces │ ├── iptables-hs.txt │ └── nft-stat-ap.txt ├── LICENSE └── README.md /AutoHotspot-Setup.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RaspberryConnect/AutoHotspot-Installer/cff6c138ccbcb3f06703d99df1d0d3e13edcf10d/AutoHotspot-Setup.tar.xz -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/ChangeLog-Autohotspot-Setup.txt: -------------------------------------------------------------------------------- 1 | Change log for autohotspot-setup.sh 2 | 3 | 0.74-2 4 | if the OS image is installed with the "Raspberry pi Imager" then the country is not set in wpa_supplicant.conf. This was used to set the correct country in hostapd.conf for the hotspot setup. 5 | This has caused the hostapd country to be blank which will cause connection issues. 6 | The country will now be defaulted to GB if not found in wpa_supplicant.conf. 7 | Correct /etc/hostapd/hostapd.conf manually or uninstall the the access point with option 4, set the wifi localisation in raspberry pi configuration. (if it is correct change to another country, ok, then change back to your country to update wpa_supplicant.conf) 8 | then reinstall autohotspot. 9 | 10 | 0.74-1 11 | added a debian to the OS detection for PiOS 64, with detection for dhcpcd incase a non PiOS version of Debian is running. 12 | 13 | 0.74 14 | added nft table support for PiOS Bullseye 15 | fixed clipped country code in hostapd.conf if wpa_supplicant created on Windows 16 | code cleanup 17 | upated text and instructions 18 | 19 | 0.73 20 | Added indents to the child functions in the Forceswitch function. 21 | In dhcpcd.conf for the static Hostspot setup, moved nohooks below the interface wlan0 line 22 | Now only wlan0 is blocked from using wpa_supplicant.conf. Wlan1 can be used to connect to a network but will 23 | not give hotspot connected devices access to the internet. The pi will have wifi network access through wlan1. 24 | 25 | 0.72 26 | Updated improved handeling of Windows special characters for updating the SSID and Password 27 | Fixed issue where not all added comment lines were removed from dhcpcd.conf file on uninstall 28 | 29 | 0.71 First release 19 Apr 2020 30 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/ChangeLog-Autohotspot.txt: -------------------------------------------------------------------------------- 1 | Change log for autohotspot and autohotspotN scripts 2 | 3 | version 0.97-N/HS-I 4 | added nfttables support for PiOS 11 Bullseye or if nftables are used on Buster. 5 | 6 | 7 | version 0.961-N/HS-I & version 0.961-N/HS 8 | -Added improved handeling of windows end of line special characters in wpa_supplicant.conf from users who create the file on windows 9 | -Modify ssid handeling for checking. If the ssid contained bash command character treat them as a string and not a command. 10 | Thanks to neaxi for these updates 11 | 12 | 13 | version 0.96-N/HS-I & version 0.96-N/HS 14 | 15 | -Added error checking for status "Invalid exchange (-52) 16 | -If the wpa_supplicant.conf file was created in windows then it can contain Cr characters. These caused the ssid not to match so the hotspot was generated. 17 | SSID matching now filters the Cr. 18 | -Script output of local SSID's and BSS's in list to be read easier. 19 | -From Raspbian Buster hostapd is masked by default. If the Autohotspot setup has been done before the first system update, hostapd can get remasked. As this may happen in future updates the Autohotspot/N scripts check for Masked & enabled hostapd and dnsmasq services and disables/stops them before the script chooses network or hotspot. 20 | 21 | up to version 0.95 22 | -Various updates from initial release on Raspbian Jessie 23 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/ReadMe.txt: -------------------------------------------------------------------------------- 1 | RaspberryConnect.com 2 | This installer script and the autohotspot & autohotspotN scripts can be shared and modified but all references to RaspberryConnect.com must be kept in place. 3 | 4 | 5 | AutoHotspot Setups: 6 | This script is for installing a Raspberry Pi WiFi setup where the Pi will connect to a previously configured Wifi network when the Pi is in range of the router or Automatically setup a Raspberry Pi access point when a known wifi network is not in range. 7 | This can also be run manually or with a timer to switch between a WiFi network or a WifI access point without a reboot. 8 | 9 | There are two setups available: 10 | 1: Network/Internet access available for connected devices when an ethernet cable is connected for the Raspberry Pi's 3A,3B,3B+ & 4. For Rapberry Pi's A,B, B+,& 2 if an usb Wifi adapter is used. 11 | 2: No internet access for connected devices. Designed for the Raspberry Pi Zero W or other Raspberry PI's where only a direct connection to the PI from a phone, tablet or Laptop is required. 12 | 13 | There is also a setup for permanent access point with network/internet access from eth0 for WiFi connected devices. 14 | 15 | For more information and for the manual setup's see: 16 | https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/157-raspberry-pi-auto-wifi-hotspot-switch-internet 17 | https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/158-raspberry-pi-auto-wifi-hotspot-switch-direct-connection 18 | https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/168-raspberry-pi-hotspot-access-point-dhcpcd-method 19 | 20 | This script will install any of these three setups or allow you to change between setup types. 21 | In additionm the Access Point SSID and Password can be changed, new WiFi networks can be added to the Raspberry PI while in access point mode. The Pi can be forced between WiFi Network mode and Access Point mode without a reboot. Also there is an uninstaller. 22 | 23 | To use the installer: 24 | 25 | Download the AutoHotspot-Setup.tar.xz archive from 26 | curl "https://www.raspberryconnect.com/images/hsinstaller/AutoHotspot-Setup.tar.gz" -o AutoHotspot-Setup.tar.gz 27 | 28 | Unarchive the file to the curent folder using the command 29 | tar -xzvf AutoHotspot-Setup.tar.xz 30 | If you are using the Desktop then right click on the AutoHotspot-Setup.tar.xz and select Extract Here 31 | 32 | open a terminal window and navigate to the Autohotspot folder. If this is in your home directory then use 33 | cd Autohotspot 34 | if this is your desktop then use 35 | cd ./Desktop/Autohotspot 36 | Run the script with the command 37 | sudo ./autohotspot-setup.sh 38 | This script will fail if sudo is not used. 39 | 40 | You will presented with a menu with these options 41 | 42 | 1 = Install Autohotspot with eth0 access for Connected Devices 43 | 2 = Install Autohotspot with No eth0 for connected devices 44 | 3 = Install a Permanent Access Point with eth0 access for connected devices 45 | 4 = Uninstall Autohotspot or permanent access point 46 | 5 = Add a new wifi network to the Pi (SSID) or update the password for an existing one. 47 | 6 = Autohotspot: Force to an access point or connect to WiFi network if a known SSID is in range 48 | 7 = Change the access points SSID and password 49 | 8 = Exit 50 | 51 | Option 1: Install Autohotspot with eth0 access for Connected Devices 52 | Once installed and after a reboot the Raspberry Pi will connect to a router that has previously been connected to and is listed in /etc/wpa_supplicant/wpa_supplicant.conf. If no router is in range then it will generate a WiFi access point. 53 | This will have an SSID of RPiHotspot and password of 1234567890 54 | Use option 7 to change the access point password and also the SSID if required 55 | If an ethernet cable is connected to the Pi with access to the internet then it will allow devices connected to the access point to connect to the internet or local network. 56 | Once a connection to the access point has been made you can access the Raspberry Pi via ssh & VNC with 57 | ssh pi@192.168.50.5 58 | vnc: 192.168.50.5::5900 59 | for webservers use http://192.168.50.5/ 60 | 61 | Option 2: Install Autohotspot with No eth0 for connected devices 62 | This option is similar to option 1 but connected devices have no network/internet connection if an ethernet cable is connected. 63 | The Pi itself can use the eth0 connection and also be accessed from a device on the etho network. 64 | This has been designed so you can access only the Pi from a Laptop, tablet or phone. 65 | The access point SSID will be RPiHotspot with a password of 1234567890 66 | Once a connection to the access point has been made you can access the Raspberry Pi via ssh & VNC with 67 | ssh pi@10.0.0.5 68 | vnc: 10.0.0.5::5900 69 | for webservers use http://10.0.0.5/ 70 | 71 | Option 3: Install a Permanent Access Point with eth0 access for connected devices 72 | This is for a permanent WiFi access point with network/internet access for connected devices. 73 | The Raspberry Pi will only have network and internet access when an ethernet cable is connected. 74 | Once a connection to the access point has been made, you can access the Raspberry Pi via ssh & VNC with 75 | ssh pi@192.168.50.10 76 | vnc: 192.168.50.10::5900 77 | for webservers use http://192.168.50.10/ 78 | 79 | Additional setup is required if you wanted to use a second WiFi device to connect to a network or internet rather than a ethernet conection. 80 | This requires changing the references in the iptables or fftables files from eth0 to wlan1 81 | /etc/iptables-hs (PiOS version 10 or lower , Buster) 82 | /etc/nftables/nft-stat-ap.nft (PiOS version 11 or higher, Bullseye) 83 | 84 | Option 4: Uninstall Autohotspot or Permanent Access Point 85 | This will disable the setup of any of the three setups and return the Raspberry Pi to default Wifi settings. 86 | Hostapd & dnsmasq will not be uninstalled just disabled. 87 | 88 | Option 5: Add a new wifi network to the Pi (SSID) or update the password for an existing one. 89 | If you are using either of the autohotspot setups in access point mode and wish to connect to a local WiFi network. You will be unable to scan for any networks as the desktop wifi option will be disabled, shown as red crosses. You can manually add the details to /etc/wpa_supplicant/wpa_supplicant.conf if you know them. 90 | This option will allow you to scan for local WiFi networks and update the Pi. If you then reboot or use the Force... option 6 ,see below. 91 | This option only works for WiFi networks where only a password is required. If a username is required this will not work. 92 | 93 | Option 6: Autohotspot: Force to an access point or Force to WiFi network if a known SSID is in range 94 | This option is only for the Autohotspot setups. 95 | If you are at home and connected to your home network but would like to use the hotspot. This option will force the pi to access point mode and will ignore your home network untill the next reboot. If you use this option again while in access point mode, it will attempt to connect to a known WiFi network. This will go back to the access point if no valid WiFi network is found or there is a connection issue. 96 | 97 | Option 7: Change the Pi's access point SSID and Password 98 | By default the access point SSID is RPiHotSpot with a password of 1234567890. Use this option to change either or both SSID and Password. 99 | You will be prompted to change both but if you make no entry and press enter the existing setting will be kept. 100 | The password must be at least 8 characters. 101 | 102 | Option 8: Exit 103 | Exit the script. 104 | 105 | 106 | /etc/network/interfaces file: 107 | many older access points and network setup guides online add entries to the /etc/network/interfaces file. This file is depreciated in Raspbian & PiOS. Any entry in this file is not compatible with these setups. This installer backup and remove any entries found in this file. They will be restored if the uninstall option is used. 108 | 109 | RaspberryConnect.com 110 | 111 | Jan 29th 2022 112 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/autohotspot-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #RaspberryConnect.com - Graeme Richards 3 | #This installer can be shared but all references to RaspberryConnect.com in this file 4 | #and other files used by the installer should remain in place. 5 | 6 | #Installer version 0.74-2 (19 Jan 2025) 7 | #Installer for AutoHotspot, AutohotspotN scripts and Static Access Point setup. 8 | #Autohotspot: a script that allows the Raspberry Pi to switch between Network Wifi and 9 | #an access point either at bootup or with seperate timer without a reboot. 10 | 11 | #This installer script will alter network settings and may overwrite existing settings if allowed. 12 | #/etc/hostapd/hostapd.conf (backup old), /etc/dnsmasq.conf (backup old), modifies /etc/dhcpcd.conf (modifies) 13 | #/etc/sysctl.conf (modifies), /etc/network/interfaces (backup old & removes any network entries) 14 | #PiOS 10 Buster and older use ip tables, PiOS 11 Bullseye uses nftables. 15 | #If nftables are detected as installed on the older PiOS then it will be used. 16 | 17 | #Force Access Point or Network Wifi option will only work if either autohotspot is installed and active. 18 | 19 | 20 | #Check for PiOS or Raspbian and version. 21 | osver=($(cat /etc/issue)) 22 | cpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 23 | opt="X" 24 | vhostapd="N" vdnsmasq="N" autoH="N" 25 | autoserv="N" iptble="N" nftble="N" 26 | 27 | if [ "${osver[0]}" != 'Raspbian' ] && [ "${osver[0]}" != 'Debian' ]; then 28 | echo "This AutoHotspot installer is only for the PiOS & Raspbian on the Raspberry Pi" 29 | exit 1 30 | elif [ "${osver[2]}" -ge 10 ]; then 31 | echo 'OS Version' "${osver[2]}" 32 | elif [ "${osver[2]}" -lt 8 ];then 33 | echo "The version of PiOS or Raspbian is too old for the Autohotspot script" 34 | echo "Version 8 'Jessie' is the minimum requirement" 35 | fi 36 | if [ "${osver[0]}" == 'Debian' ]; then 37 | if ! systemctl -all list-unit-files dhcpcd.service | grep "dhcpcd.service enabled" >/dev/null 2>&1;then 38 | echo "Debian OS detected" 39 | echo "dhcpcd is not the default DHCP client" 40 | echo "This script is intended for the Raspberry Pi OS" 41 | echo "and requires dhcpcd to be the default DHCP client" 42 | exit 1 43 | fi 44 | fi 45 | 46 | check_installed() 47 | { 48 | #check if required software is already installed 49 | if dpkg -s "hostapd" | grep 'Status: install ok installed' >/dev/null 2>&1; then 50 | vhostapd="Y" 51 | fi 52 | if dpkg -s "dnsmasq" | grep 'Status: install ok installed' >/dev/null 2>&1; then 53 | vdnsmasq="Y" 54 | fi 55 | #Does an Autohotspot files exist 56 | if ls /usr/bin/ | grep "autohotspot*" >/dev/null 2>&1 ; then 57 | autoH="Y" 58 | fi 59 | if ls /etc/systemd/system/ | grep "autohotspot.service" >/dev/null 2>&1 ; then 60 | autoserv="Y" 61 | fi 62 | if dpkg -s "iptables" >/dev/null 2>&1 ; then 63 | iptble="Y" 64 | fi 65 | if dpkg -s "nftables" >/dev/null 2>&1 ; then 66 | nftble="Y" 67 | fi 68 | } 69 | 70 | check_reqfiles() 71 | { 72 | fstatus=0 73 | cd "${cpath}/config/" 74 | if test -f "Checklist.md5" ;then 75 | if ! md5sum -c --quiet Checklist.md5 ;then 76 | echo "one or more of the required files in the config folder are missing or have been altered" 77 | echo "please download the installer again from RaspberryConnect.com" 78 | exit 79 | fi 80 | else 81 | echo "The file Checklist.md5 is missing from Config folder" 82 | echo "Please download the installer again" 83 | echo "from RaspberryConnect.com" 84 | exit 85 | fi 86 | 87 | } 88 | 89 | check_wificountry() 90 | { 91 | #echo "Checking WiFi country" 92 | wpa=($(cat "/etc/wpa_supplicant/wpa_supplicant.conf" | tr -d '\r' | grep "country=")) 93 | if [ -z ${wpa: -2} ] || [[ ${wpa: -2} == *"="* ]];then 94 | echo "The WiFi country has not been set. This is required for the access point setup." 95 | echo "Please update PiOS with the wifi country using the command 'sudo raspi-config' and choose the localisation menu" 96 | echo "From the desktop this can be done in the menu Preferences - Raspberry Pi Configuration - Localisation" 97 | echo "Once done please try again." 98 | echo "" 99 | echo "press a key to continue" 100 | read 101 | fi 102 | } 103 | 104 | hostapd_config() 105 | { 106 | echo "hostapd Config" 107 | echo "Hostapd Status is " $vhostapd 108 | if [ "$vhostapd" = "N" ]; then 109 | echo "Hostapd not installed- now installing" 110 | apt -q install hostapd 111 | echo "Recheck install Status" 112 | check_installed 113 | if [ "$vhostapd" = "N" ]; then 114 | echo "" 115 | echo "" 116 | echo "Hostapd failed to install. Check there is internet access" 117 | echo "and try again" 118 | echo "Press a key to continue" 119 | read 120 | menu 121 | fi 122 | fi 123 | echo "Hostapd is installed" 124 | if ! grep -F "RaspberryConnect.com" "/etc/hostapd/hostapd.conf" ;then 125 | #not a autohotspot file, create backup 126 | mv "/etc/hostapd/hostapd.conf" "/etc/hostapd/hostapd-RCbackup.conf" 127 | fi 128 | cp "$cpath/config/hostapd.conf" /etc/hostapd/hostapd.conf 129 | if [ "${osver[2]}" -lt 10 ]; then 130 | cp "$cpath/config/hostapd" /etc/default/hostapd 131 | fi 132 | if [ "$opt" = "AHN" ] || [ "$opt" = "AHD" ]; then 133 | #For Autohotspots 134 | echo "Unmask & Disable Hostapd" 135 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service masked" >/dev/null 2>&1;then 136 | systemctl unmask hostapd.service >/dev/null 2>&1 137 | fi 138 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service enabled" >/dev/null 2>&1;then 139 | systemctl disable hostapd.service >/dev/null 2>&1 140 | fi 141 | elif [ "$opt" = "SHS" ]; then 142 | #for Static Hotspot 143 | echo "Unmask and enable hostapd" 144 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service masked" >/dev/null 2>&1; then 145 | systemctl unmask hostapd >/dev/null 2>&1 146 | fi 147 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service disabled" >/dev/null 2>&1; then 148 | systemctl enable hostapd >/dev/null 2>&1 149 | fi 150 | elif [ "$opt" = "REM" ]; then 151 | if [ -f "/etc/hostapd/hostapd-RCbackup.conf" ] ; then 152 | mv "/etc/hostapd/hostapd-RCbackup.conf" "/etc/hostapd/hostapd.conf" 153 | fi 154 | fi 155 | #check country code for hostapd.conf 156 | wpa=($(cat "/etc/wpa_supplicant/wpa_supplicant.conf" | tr -d '\r' | grep "country=")) 157 | hapd=($(cat "/etc/hostapd/hostapd.conf" | tr -d '\r' | grep "country_code=")) 158 | if [ -z ${wpa: -2} ] || [[ ${wpa: -2} == *"="* ]] ;then 159 | #if no country set in wpa_supplicant use the template country 160 | echo "wpa_supplicant.conf has no country code set." 161 | echo " Setting up country GB default in hostapd.conf" 162 | elif [[ ! ${wpa: -2} == ${hapd: -2} ]] ;then 163 | echo "Changing Hostapd Wifi country to " ${wpa: -2} 164 | sed -i -e "/country_code=/c\country_code=${wpa: -2}" /etc/hostapd/hostapd.conf 165 | fi 166 | } 167 | 168 | dnsmasq_config() 169 | { 170 | echo "Dnsmasq Config" 171 | if [ "$vdnsmasq" = "N" ]; then 172 | apt -q install dnsmasq 173 | check_installed 174 | if [ "$vdnsmasq" = "N" ]; then 175 | echo "" 176 | echo "" 177 | echo "dnsmasq failed to install. Check there is internet access" 178 | echo "and try again" 179 | echo "Press a key to continue" 180 | read 181 | menu 182 | fi 183 | fi 184 | if [ -f "/etc/dnsmasq.conf" ] ; then 185 | if ! grep -F "RaspberryConnect.com" "/etc/dnsmasq.conf" ;then 186 | #not a autohotspot file, create backup 187 | mv "/etc/dnsmasq.conf" "/etc/dnsmasq-RCbackup.conf" 188 | fi 189 | fi 190 | if [ "$opt" = "AHN" ] ; then 191 | echo "${cpath}/config/dnsmasqAHSN.conf" 192 | cp "${cpath}/config/dnsmasqAHSN.conf" "/etc/dnsmasq.conf" 193 | elif [ "$opt" = "AHD" ];then 194 | cp "${cpath}/config/dnsmasqAHS.conf" "/etc/dnsmasq.conf" 195 | elif [ "$opt" = "SHS" ] ;then 196 | cp "${cpath}/config/dnsmasqSHS.conf" "/etc/dnsmasq.conf" 197 | fi 198 | if [ "$opt" = "AHN" ] || [ "$opt" = "AHD" ]; then 199 | #For Autohotspots 200 | echo "Unmask & Disable Dnsmasq" 201 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service masked" ;then 202 | systemctl unmask dnsmasq >/dev/null 2>&1 203 | fi 204 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service enabled" ;then 205 | systemctl disable dnsmasq >/dev/null 2>&1 206 | fi 207 | elif [ "$opt" = "SHS" ]; then 208 | #for Static Hotspot 209 | echo "Unmask & Enable Dnsmasq" 210 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service masked" ;then 211 | systemctl unmask dnsmasq >/dev/null 2>&1 212 | fi 213 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service disabled" ;then 214 | systemctl enable dnsmasq >/dev/null 2>&1 215 | fi 216 | fi 217 | if [ "$opt" = "REM" ]; then 218 | if [ -f "/etc/dnsmasq-RCbackup.conf" ] ; then 219 | mv "/etc/dnsmasq-RCbackup.conf" "/etc/dnsmasq.conf" 220 | fi 221 | fi 222 | 223 | } 224 | dhcpcd_config() 225 | { 226 | #Make backup if not done 227 | if [ ! "/etc/dhcpcd-RCbackup.conf" ] ;then 228 | mv "/etc/dhcpcd.conf" "/etc/dhcpcd-RCbackup.conf" 229 | fi 230 | if [ "$opt" = "AHN" ] || [ "$opt" = "AHD" ] ;then 231 | #use backup for Auto scripts to retain any custon Network Config like static ip's 232 | if [ ! "/etc/dhcpcd-RCbackup.conf" ] ;then 233 | cp "/etc/dhcpcd-RCbackup.conf" "/etc/dhcpcd.conf" 234 | fi 235 | grep -vxf "${cpath}/config/dhcpcd-remove.conf" "/etc/dhcpcd.conf" > "${cpath}/config/Ndhcpcd.conf" 236 | cat "${cpath}/config/dhcpcd-autohs.conf" >> "${cpath}/config/Ndhcpcd.conf" 237 | mv "${cpath}/config/Ndhcpcd.conf" "/etc/dhcpcd.conf" 238 | elif [ "$opt" = "SHS" ]; then 239 | #use clean dhcpcd.conf for static hotspot, backup will be restored on removal /etc/dhcpcd-RCbackup.conf 240 | cp "${cpath}/config/dhcpcd-default.conf" "/etc/dhcpcd.conf" 241 | grep -vxf "${cpath}/config/dhcpcd-remove.conf" "/etc/dhcpcd.conf" > "${cpath}/config/Ndhcpcd.conf" 242 | cat "${cpath}/config/dhcpcd-SHSN.conf" >> "${cpath}/config/Ndhcpcd.conf" 243 | mv "${cpath}/config/Ndhcpcd.conf" "/etc/dhcpcd.conf" 244 | fi 245 | } 246 | 247 | sysctl() 248 | { 249 | if [ "$opt" = "AHN" ] || [ "$opt" = "SHS" ] ;then 250 | sed -i -e "/#net.ipv4.ip_forward=1/c\net.ipv4.ip_forward=1" /etc/sysctl.conf 251 | elif [ "$opt" = "AHD" ] || [ "$opt" = "REM" ] ;then 252 | sed -i -e "/net.ipv4.ip_forward=1/c\#net.ipv4.ip_forward=1" /etc/sysctl.conf 253 | fi 254 | } 255 | 256 | auto_service() 257 | { 258 | if [ "$opt" = "AHN" ] ;then 259 | cp "${cpath}/config/autohotspot-Net.service" "/etc/systemd/system/autohotspot.service" 260 | systemctl daemon-reload 261 | systemctl enable autohotspot 262 | elif [ "$opt" = "AHD" ] ;then 263 | cp "${cpath}/config/autohotspot-direct.service" "/etc/systemd/system/autohotspot.service" 264 | systemctl daemon-reload 265 | systemctl enable autohotspot 266 | fi 267 | if [ "$opt" = "REM" ] || [ "$opt" = "SHS" ]; then 268 | if systemctl -all list-unit-files autohotspot.service | grep "autohotspot.service enabled" ;then 269 | systemctl disable autohotspot.service 270 | fi 271 | if [ -f "/etc/systemd/system/autohotspot.service" ]; then 272 | rm /etc/systemd/system/autohotspot.service 273 | fi 274 | fi 275 | 276 | } 277 | hs_routing() 278 | { 279 | if [ "$opt" = "SHS" ] ;then 280 | if [ "$iptble" = "Y" ] ; then 281 | if [ ! -f "/etc/systemd/system/hs-iptables.service" ];then 282 | cp "${cpath}/config/hs-iptables.service" "/etc/systemd/system/hs-iptables.service" 283 | fi 284 | if systemctl -all list-unit-files hs-iptables.service | grep "hs-iptables.service enabled" ;then 285 | systemctl daemon-reload 286 | fi 287 | if systemctl -all list-unit-files hs-iptables.service | grep "hs-iptables.service disabled" ;then 288 | systemctl enable hs-iptables.service 289 | fi 290 | if [ ! -f "/etc/iptables-hs" ] ;then 291 | cp "${cpath}/config/iptables-hs.txt" "/etc/iptables-hs" 292 | chmod +x "/etc/iptables-hs" 293 | fi 294 | 295 | elif [ "$nftble" = "Y" ] ; then 296 | if [ ! -d '/etc/nftables' ] ; then 297 | mkdir /etc/nftables 298 | fi 299 | if ! cat '/etc/nftables.conf' | grep 'nft-stat-ap.nft' ; then 300 | cp "${cpath}/config/nft-stat-ap.txt" "/etc/nftables/nft-stat-ap.nft" 301 | chmod +x "/etc/nftables/nft-stat-ap.nft" 302 | sed -i '$ a include "/etc/nftables/nft-stat-ap.nft"' "/etc/nftables.conf" 303 | if systemctl -all list-unit-files nftables.service | grep "nftables.service disabled" ;then 304 | systemctl enable nftables >/dev/null 2>&1 305 | fi 306 | fi 307 | fi 308 | elif [ "$opt" = "REM" ] || [ "$opt" = "AHN" ] || [ "$opt" = "AHD" ] ; then 309 | if [ "$iptble" = "Y" ] ; then 310 | if systemctl is-active hs-iptables | grep -w "active" ;then 311 | systemctl disable hs-iptables.service 312 | fi 313 | if test -f "/etc/systemd/system/hs-iptables.service" ; then 314 | rm /etc/systemd/system/hs-iptables.service 315 | fi 316 | if test -f "/etc/iptables-hs" ; then 317 | rm /etc/iptables-hs 318 | fi 319 | elif [ "$nftble" = "Y" ] ; then 320 | sed -i '/nft-stat-ap/d' '/etc/nftables.conf' 321 | fi 322 | fi 323 | } 324 | 325 | auto_script() 326 | { 327 | if [ "$opt" = "AHN" ] ;then 328 | cp "${cpath}/config/autohotspotN" "/usr/bin/autohotspotN" 329 | chmod +x /usr/bin/autohotspotN 330 | elif [ "$opt" = "AHD" ] ;then 331 | cp "${cpath}/config/autohotspot-direct" "/usr/bin/autohotspot" 332 | chmod +x /usr/bin/autohotspot 333 | elif [ "$opt" = "REM" ] || [ "$opt" = "SHS" ] ;then 334 | if [ -f "/usr/bin/autohotspotN" ]; then 335 | rm /usr/bin/autohotspotN 336 | fi 337 | if [ -f "/usr/bin/autohotspot" ]; then 338 | rm /usr/bin/autohotspot 339 | fi 340 | fi 341 | } 342 | 343 | interface() 344 | { 345 | #if interfaces file contains network settings 346 | #backup and remove. 347 | if grep -vxf "${cpath}/config/interfaces" "/etc/network/interfaces" ;then 348 | mv "/etc/network/interfaces" "/etc/network/RCbackup-interfaces" 349 | cp "${cpath}/config/interfaces" "/etc/network/interfaces" 350 | fi 351 | if [ "$opt" = "REM" ] ;then 352 | if [ -f "/etc/network/RCbackup-interfaces" ] ;then 353 | mv "/etc/network/RCbackup-interfaces" "/etc/network/interfaces" 354 | fi 355 | fi 356 | } 357 | 358 | remove() 359 | { 360 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service enabled" ;then 361 | systemctl disable hostapd >/dev/null 2>&1 362 | fi 363 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service enabled" ;then 364 | systemctl disable dnsmasq >/dev/null 2>&1 365 | fi 366 | auto_script #Remove Autohotspot Scripts 367 | #Reset DHCPCD.conf 368 | if [ -f "/etc/dhcpcd-RCbackup.conf" ] ;then #restore backup 369 | mv "/etc/dhcpcd-RCbackup.conf" "/etc/dhcpcd.conf" 370 | else #or remove edits if no backup 371 | echo "Removing config from dhcpcd.conf" 372 | grep -vxf "${cpath}/config/dhcpcd-remove.conf" "/etc/dhcpcd.conf" > "${cpath}/config/Ndhcpcd.conf" 373 | mv "${cpath}/config/Ndhcpcd.conf" "/etc/dhcpcd.conf" 374 | fi 375 | hs_routing #remove routing for Static HS 376 | sysctl #remove port forwarding 377 | interface #restore backup of interfaces fle 378 | auto_service #remove autohotspot.service 379 | } 380 | 381 | Hotspotssid() 382 | { 383 | #Change the Default Hotspot SSID and Password 384 | if [ ! -f "/etc/hostapd/hostapd.conf" ] ;then 385 | echo "An Access Point is not installed. No Password to change" 386 | echo "press enter to continue" 387 | read 388 | menu 389 | fi 390 | HSssid=($(cat "/etc/hostapd/hostapd.conf" | grep '^ssid=')) 391 | HSpass=($(cat "/etc/hostapd/hostapd.conf" | grep '^wpa_passphrase=')) 392 | echo "Change the Access Point's SSID and Password. press enter to keep existing settings" 393 | echo "The current SSID is:" "${HSssid:5}" 394 | echo "The current SSID Password is:" "${HSpass:15}" 395 | echo "Enter the new Access Point SSID:" 396 | read ssname 397 | echo "Enter the hotspots new password. Minimum 8 characters" 398 | read sspwd 399 | if [ ! -z $ssname ] ;then 400 | echo "Changing Hotspot SSID to:" "$ssname" 401 | sed -i -e "/^ssid=/c\ssid=$ssname" /etc/hostapd/hostapd.conf 402 | else 403 | echo "The Hotspot SSID is" ${HSssid: 5} 404 | fi 405 | if [ ! -z $sspwd ] && [ ${#sspwd} -ge 8 ] ;then 406 | echo "Changing Access Point Password to:" "$sspwd" 407 | sed -i -e "/^wpa_passphrase=/c\wpa_passphrase=$sspwd" /etc/hostapd/hostapd.conf 408 | else 409 | echo "The Access Point Password is:" ${HSpass: 15} 410 | fi 411 | echo "" 412 | echo "The new setup will be available next time the hotspot is started" 413 | echo "Press a key to continue" 414 | read 415 | menu 416 | } 417 | 418 | setupssid() 419 | { 420 | echo "Searching for local WiFi connection" 421 | echo "Add a new WiFi network or change the password for an existing one in range" 422 | echo "For Wifi networks where only a password is required." 423 | echo "This will not work where a username and password is required" 424 | echo "" 425 | echo "If the Pi is currently in Access Point mode with a Autohotspot" 426 | echo "then use option 6 to Force the Pi to the newly added Wifi Network" 427 | ct=0; j=0 ; lp=0 428 | wfselect=() 429 | 430 | until [ $lp -eq 1 ] #wait for wifi if busy, usb wifi is slower. 431 | do 432 | IFS=$'\n:$\t' localwifi=($((iw dev wlan0 scan ap-force | egrep "SSID:") 2>&1)) >/dev/null 2>&1 433 | #if wifi device errors recheck 434 | if (($j >= 5)); then #if busy 5 times exit to menu 435 | echo "WiFi Device Unavailable, cannot scan for wifi devices at this time" 436 | echo "press a key to continue" 437 | menu 438 | break 439 | elif echo "${localwifi[1]}" | grep "No such device (-19)" >/dev/null 2>&1; then 440 | echo "No Device found,trying again" 441 | j=$((j + 1)) 442 | sleep 2 443 | elif echo "${localwifi[1]}" | grep "Network is down (-100)" >/dev/null 2>&1 ; then 444 | echo "Network Not available, trying again" 445 | j=$((j + 1)) 446 | sleep 2 447 | elif echo "${localwifi[1]}" | grep "Read-only file system (-30)" >/dev/null 2>&1 ; then 448 | echo "Temporary Read only file system, trying again" 449 | j=$((j + 1)) 450 | sleep 2 451 | elif echo "${localwifi[1]}" | grep "Invalid exchange (-52)" >/dev/null 2>&1 ; then 452 | echo "Temporary unavailable, trying again" 453 | j=$((j + 1)) 454 | sleep 2 455 | elif echo "${localwifi[1]}" | grep -v "Device or resource busy (-16)" >/dev/null 2>&1 ; then 456 | lp=1 457 | else #see if device not busy in 2 seconds 458 | echo "WiFi Device unavailable checking again" 459 | j=$((j + 1)) 460 | sleep 2 461 | fi 462 | done 463 | 464 | #Wifi Connections found - continue 465 | for x in "${localwifi[@]}" 466 | do 467 | if [ $x != "SSID" ]; then 468 | ct=$((ct + 1)) 469 | echo "$ct ${x/ /}" 470 | wfselect+=("${x/ /}") 471 | fi 472 | done 473 | ct=$((ct + 1)) 474 | echo "$ct To Cancel" 475 | wfselect+=("Cancel") 476 | if [ "${#wfselect[@]}" -eq 1 ] ;then 477 | echo "Unable to detect local WiFi devices. Maybe there is a temporary issue with your WiFi" 478 | echo "Try again in a minute" 479 | echo "press a enter to continue" 480 | read 481 | menu 482 | fi 483 | 484 | read wf 485 | if [[ $wf =~ ^[0-9]+$ ]]; then 486 | if [ $wf -ge 0 ] && [ $wf -le $ct ]; then 487 | updatessid "${wfselect[$wf-1]}" 488 | else 489 | echo -e "\nNot a Valid entry" 490 | setupssid 491 | fi 492 | else 493 | echo -e "\nNot a Valid entry" 494 | setupssid 495 | fi 496 | } 497 | 498 | updatessid() 499 | { 500 | #check for blank in return 501 | echo "$1" 502 | echo "" 503 | if [ "$1" = "Cancel" ] || [ "$1" = "" ] ; then 504 | menu 505 | exit 506 | fi 507 | 508 | IFS="," wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' | sed 's/\r//g'| awk 'BEGIN{ORS=","} {print}' | sed 's/\"/''/g' | sed 's/,$//') 509 | ssids=($wpassid) 510 | if [[ ! " ${ssids[@]} " =~ " $1 " ]]; then 511 | echo "Add New Wifi Network" 512 | echo "Selection SSID: $1" 513 | echo "" 514 | echo "Enter password for Wifi" 515 | read ssidpw 516 | echo -e "\nnetwork={\n\tssid=\x22$1\x22\n\tpsk=\x22$ssidpw\x22\n\tkey_mgmt=WPA-PSK\n}" >> /etc/wpa_supplicant/wpa_supplicant.conf 517 | else 518 | f=0 519 | echo "Change Password for Selected Wifi" 520 | while IFS= read -r ln || [[ -n "$ln" ]] <&3; do 521 | if [[ "$ln" == *"psk="* ]] && [ $f -eq 1 ] ;then 522 | break 523 | elif [[ "$ln" == *"$1"* ]] ; then 524 | f=1 525 | fi 526 | done < /etc/wpa_supplicant/wpa_supplicant.conf 527 | echo "Change Wifi Network Password" 528 | echo "Selected SSID: $1" 529 | echo "" 530 | echo "Enter password for Wifi" 531 | read chgpw 532 | newpsk=$'\tpsk=\x22'$chgpw$'\x22\n' 533 | echo "The entry will be" $newpsk 534 | echo "To be Replaced $ln" 535 | sed -i '/'"$ln"'/c\'"$newpsk" /etc/wpa_supplicant/wpa_supplicant.conf 536 | f=0 537 | fi 538 | } 539 | 540 | forceswitch() 541 | { 542 | if [ ! -f "/etc/systemd/system/autohotspot.service" ] ;then 543 | echo "No Autohotspot script installed, unable to continue" 544 | echo "press enter to continue" 545 | read 546 | menu 547 | fi 548 | #Create Hotspot or connect to valid wifi networks 549 | echo 0 > /proc/sys/net/ipv4/ip_forward #deactivate ip forwarding 550 | 551 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 552 | then 553 | echo "The access point is already active" 554 | echo "Switching to Network Wifi if it is available" 555 | echo "this takes about 20 seconds to complete checks" 556 | systemctl restart autohotspot.service 557 | menu 558 | elif { wpa_cli status | grep "$wifidev"; } >/dev/null 2>&1 559 | then 560 | echo "Cleaning wifi files and Activating Hotspot" 561 | wpa_cli terminate >/dev/null 2>&1 562 | ip addr flush "$wifidev" 563 | ip link set dev "$wifidev" down 564 | rm -r /var/run/wpa_supplicant >/dev/null 2>&1 565 | get_HS_IP 566 | else #Neither the Hotspot or Network is active 567 | get_HS_IP 568 | fi 569 | } 570 | ## 571 | createAdHocNetwork_N() #for Internet routed Hotspot for Force Switch 572 | { 573 | #receive IP as $1 574 | echo "Creating Hotspot with Internet" 575 | ip link set dev "$wifidev" down 576 | ip a add $1 brd + dev "$wifidev" 577 | ip link set dev "$wifidev" up 578 | dhcpcd -k "$wifidev" >/dev/null 2>&1 579 | if iptables 2>&1 | grep 'no command specified' >/dev/null 2>&1 ; then 580 | iptables -t nat -A POSTROUTING -o "$ethdev" -j MASQUERADE 581 | iptables -A FORWARD -i "$ethdev" -o "$wifidev" -m state --state RELATED,ESTABLISHED -j ACCEPT 582 | iptables -A FORWARD -i "$wifidev" -o "$ethdev" -j ACCEPT 583 | elif nft 2>&1 | grep 'no command specified' >/dev/null 2>&1 ; then 584 | nft add table inet ap 585 | nft add chain inet ap rthrough { type nat hook postrouting priority 0 \; policy accept \; } 586 | nft add rule inet ap rthrough oifname "$ethdev" masquerade 587 | nft add chain inet ap fward { type filter hook forward priority 0 \; policy accept \; } 588 | nft add rule inet ap fward iifname "$ethdev" oifname "$wifidev" ct state established,related accept 589 | nft add rule inet ap fward iifname "$wifidev" oifname "$ethdev" accept 590 | fi 591 | systemctl start dnsmasq 592 | systemctl start hostapd 593 | echo 1 > /proc/sys/net/ipv4/ip_forward 594 | } 595 | 596 | createAdHocNetwork_D() #For non Internet Routed Hotspot for Force Switch 597 | { 598 | echo "Creating WiFi access point with no network/internet for connected devices" 599 | echo "through eth0" 600 | ip link set dev "$wifidev" down 601 | ip a add $1 brd + dev "$wifidev" 602 | ip link set dev "$wifidev" up 603 | dhcpcd -k "$wifidev" >/dev/null 2>&1 604 | systemctl start dnsmasq 605 | systemctl start hostapd 606 | } 607 | 608 | get_HS_IP() #get ip address from current active hotspot script for Force Switch 609 | { 610 | if [ ${Aserv: -4} = "spot" ];then #Direct 611 | ipline=($(cat /usr/bin/autohotspot | grep "ip a add")) 612 | createAdHocNetwork_D "${ipline[3]}" 613 | elif [ ${Aserv: -4} = "potN" ];then #Internet 614 | ipline=($(cat /usr/bin/autohotspotN | grep "ip a add")) 615 | createAdHocNetwork_N "${ipline[3]}" 616 | else 617 | echo "The Autohotspot is disabled or not installed" 618 | echo "unable to force a switch." 619 | echo "Press enter to continue" 620 | read 621 | menu 622 | fi 623 | } 624 | 625 | display_HS_IP() #get ip address from current active hotspot script 626 | { 627 | Aserv=($(cat /etc/systemd/system/autohotspot.service 2>/dev/null| grep "ExecStart=")) #which hotspot is active? 628 | if [ ${Aserv: -4} = "spot" ] >/dev/null 2>&1 ;then #Direct 629 | ipline=($(cat /usr/bin/autohotspot | grep "ip a add")) 630 | echo "Access Point IP Address for SSH and VNC: ${ipline[3]: :-3}" 631 | elif [ ${Aserv: -4} = "potN" ] >/dev/null 2>&1 ;then #Internet 632 | ipline=($(cat /usr/bin/autohotspotN | grep "ip a add")) 633 | echo "Access Point IP Address for SSH and VNC: ${ipline[3]: :-3}" 634 | else #Static Hotspot default IP 635 | echo "Access Point IP Address for ssh and VNC: 192.168.50.10" 636 | fi 637 | } 638 | 639 | go() 640 | { 641 | opt="$1" 642 | #echo "Selected" "$opt" 643 | #echo "Action options" 644 | if [ "$opt" = "REM" ] ;then 645 | remove 646 | echo "Please reboot to complete the uninstall" 647 | elif [ "$opt" = "SSI" ] ;then 648 | setupssid 649 | echo "the new ssid will be used next time the autohotspot script is " 650 | echo "run at boot or manually otherwise use the Force to.... option" 651 | echo "if the hotspot is active" 652 | elif [ "$opt" = "FOR" ] ;then 653 | if [ ! -f "/etc/systemd/system/autohotspot.service" ] ;then 654 | echo "No Autohotspot script installed, unable to continue" 655 | echo "press enter to continue" 656 | read 657 | menu 658 | fi 659 | Aserv=($(cat /etc/systemd/system/autohotspot.service | grep "ExecStart=")) 660 | wi=($(cat ${Aserv: 10} | grep wifidev=)) 661 | eth=($(cat ${Aserv: 10} | grep ethdev=)) 662 | wifidev=${wi[0]: 9:-1} #wifi device name from active autohotspot/N script 663 | ethdev=${eth[0]: 8:-1} #Ethernet port to use with IP tables 664 | forceswitch 665 | elif [ "$opt" = "HSS" ] ;then 666 | Hotspotssid 667 | else 668 | hostapd_config 669 | dnsmasq_config 670 | interface 671 | sysctl 672 | dhcpcd_config 673 | auto_service 674 | hs_routing 675 | auto_script 676 | echo "" 677 | echo "The hotspot setup will be available after a reboot" 678 | HSssid=($(cat "/etc/hostapd/hostapd.conf" | grep '^ssid=')) 679 | HSpass=($(cat "/etc/hostapd/hostapd.conf" | grep '^wpa_passphrase=')) 680 | echo "The Hotspots WiFi SSID name is: ${HSssid: 5}" 681 | echo "The WiFi password is: ${HSpass: 15}" 682 | display_HS_IP 683 | fi 684 | echo "Press any key to continue" 685 | read 686 | 687 | } 688 | 689 | menu() 690 | { 691 | #selection menu 692 | clear 693 | until [ "$select" = "8" ]; do 694 | echo "Raspberryconnect.com Autohotspot installation and setup" 695 | echo "for installation or switching between access point types" 696 | echo "or uninstall the access point back to standard Pi wifi" 697 | echo "" 698 | echo "Autohotspot Net = connects to a known wifi network in range," 699 | echo "otherwise automatically creates a Raspberry Pi access point with network/internet access if an" 700 | echo "ethernet cable is connected. Uses wlan0, eth0. Pi's 3,3+,4" 701 | echo "" 702 | echo "Autohotspot NO Net = as above but connected devices to the access point" 703 | echo "will NOT get a network/internet connection if an ethernet cable is connected. Rpi Zero W & RPi Zero 2" 704 | echo "" 705 | echo "Permanent Access Point = permanent access point with network/internet access from eth0 for" 706 | echo "connected devices" 707 | echo "" 708 | echo " 1 = Install Autohotspot with eth0 access for Connected Devices" 709 | echo " 2 = Install Autohotspot with No eth0 for connected devices" 710 | echo " 3 = Install a Permanent Access Point with eth0 access for connected devices" 711 | echo " 4 = Uninstall Autohotspot or permanent access point" 712 | echo " 5 = Add a new wifi network to the Pi (SSID) or update the password for an existing one." 713 | echo " 6 = Autohotspot: Force to an access point or connect to WiFi network if a known SSID is in range" 714 | echo " 7 = Change the access points SSID and password" 715 | echo " 8 = Exit" 716 | echo "" 717 | echo -n "Select an Option:" 718 | read select 719 | case $select in 720 | 1) clear ; go "AHN" ;; #Autohospot Internet 721 | 2) clear ; go "AHD" ;; #Autohotspot Direct 722 | 3) clear ; go "SHS" ;; #Static Hotspot 723 | 4) clear ; go "REM" ;; #Remove Autohotspot or Static Hotspot 724 | 5) clear ; go "SSI" ;; #Change/Add Wifi Network 725 | 6) clear ; go "FOR" ;; #Force Hotspot <> Force Network 726 | 7) clear ; go "HSS" ;; #Change Hotspot SSID and Password 727 | 8) clear ; exit ;; 728 | *) clear; echo "Please select again";; 729 | esac 730 | done 731 | } 732 | 733 | check_reqfiles 734 | check_installed 735 | check_wificountry 736 | menu #show menu 737 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/Checklist.md5: -------------------------------------------------------------------------------- 1 | ee57146896654d47d720346fc80b8644 ./autohotspot-direct 2 | b87b8b6fa19445d0e65045d8e271f456 ./autohotspot-direct.service 3 | a7760cbb61be5f71fb9ee8a7605fddc3 ./autohotspotN 4 | bb7fd111c1baa11fdee18699041a2516 ./autohotspot-Net.service 5 | 557bfbf9d19f7d4a8d8fd19e40a435c5 ./dhcpcd-autohs.conf 6 | 00374ad1a5e6d4d7779380ed8e5a4a68 ./dhcpcd-default.conf 7 | 889cc706f9919532bf0f281b3ff54cc5 ./dhcpcd-remove.conf 8 | 77c4e9c1a5a8fdbbb3950f0f0428aabb ./dhcpcd-SHS.conf 9 | 604aaa184b142533198d310aae5fe1e1 ./dhcpcd-SHSN.conf 10 | 8789bd5d1674e65d18c21c3bcffdfb0a ./dnsmasqAHS.conf 11 | 807885886aa6a40f30d4c9d480b80c84 ./dnsmasqAHSN.conf 12 | 25e3152c11d0860428bcb51b25e33441 ./dnsmasqSHS.conf 13 | 50d80f635b02b8ce58bfa8f260eba7e7 ./hostapd 14 | 0d495cabd4ce6d63e0eea040cc435540 ./hostapd.conf 15 | d0f09b7f89ef821edaef58e7b91b313a ./hs-iptables.service 16 | c82e7473bb1490cf4702aaf7b669bb33 ./interfaces 17 | fbb31822a27f4acca55acdb8f52d538c ./iptables-hs.txt 18 | 2d22ed0842def19f724eeaa4e0b0646f ./nft-stat-ap.txt 19 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/autohotspot-Net.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Automatically generates a Hotspot when a valid SSID is not in range 3 | After=multi-user.target 4 | [Service] 5 | Type=oneshot 6 | RemainAfterExit=yes 7 | ExecStart=/usr/bin/autohotspotN 8 | [Install] 9 | WantedBy=multi-user.target 10 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/autohotspot-direct: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #version 0.961-N/HS 3 | 4 | #You may share this script on the condition all references to RaspberryConnect.com 5 | #must be included in copies or derivatives of this script. 6 | 7 | #A script to switch between a wifi network and a non internet routed Hotspot 8 | #Works at startup or with a seperate timer or manually without a reboot 9 | #Other setup required find out more at 10 | #http://www.raspberryconnect.com 11 | 12 | wifidev="wlan0" #device name to use. Default is wlan0. 13 | #use the command: iw dev ,to see wifi interface name 14 | 15 | IFSdef=$IFS 16 | cnt=0 17 | #These four lines capture the wifi networks the RPi is setup to use 18 | wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' | sed 's/\r//g'| awk 'BEGIN{ORS=","} {print}' | sed 's/\"/''/g' | sed 's/,$//') 19 | IFS="," 20 | ssids=($wpassid) 21 | IFS=$IFSdef #reset back to defaults 22 | 23 | 24 | #Note:If you only want to check for certain SSIDs 25 | #Remove the # in in front of ssids=('mySSID1'.... below and put a # infront of all four lines above 26 | # separated by a space, eg ('mySSID1' 'mySSID2') 27 | #ssids=('mySSID1' 'mySSID2' 'mySSID3') 28 | 29 | #Enter the Routers Mac Addresses for hidden SSIDs, seperated by spaces ie 30 | #( '11:22:33:44:55:66' 'aa:bb:cc:dd:ee:ff' ) 31 | mac=() 32 | 33 | ssidsmac=("${ssids[@]}" "${mac[@]}") #combines ssid and MAC for checking 34 | 35 | createAdHocNetwork() 36 | { 37 | echo "Autohotspot by RaspberryConnect.com" 38 | echo "Creating Hotspot" 39 | ip link set dev "$wifidev" down 40 | ip a add 10.0.0.5/24 brd + dev "$wifidev" 41 | ip link set dev "$wifidev" up 42 | dhcpcd -k "$wifidev" >/dev/null 2>&1 43 | systemctl start dnsmasq 44 | systemctl start hostapd 45 | } 46 | 47 | KillHotspot() 48 | { 49 | echo "Autohotspot by RaspberryConnect.com" 50 | echo "Shutting Down Hotspot" 51 | ip link set dev "$wifidev" down 52 | systemctl stop hostapd 53 | systemctl stop dnsmasq 54 | ip addr flush dev "$wifidev" 55 | ip link set dev "$wifidev" up 56 | dhcpcd -n "$wifidev" >/dev/null 2>&1 57 | } 58 | 59 | ChkWifiUp() 60 | { 61 | echo "Checking WiFi connection ok" 62 | sleep 20 #give time for connection to be completed to router 63 | if ! wpa_cli -i "$wifidev" status | grep 'ip_address' >/dev/null 2>&1 64 | then #Failed to connect to wifi (check your wifi settings, password etc) 65 | echo 'Wifi failed to connect, falling back to Hotspot.' 66 | wpa_cli terminate "$wifidev" >/dev/null 2>&1 67 | createAdHocNetwork 68 | fi 69 | } 70 | 71 | 72 | chksys() 73 | { 74 | #After some system updates hostapd gets masked using Raspbian Buster, and above. This checks and fixes 75 | #the issue and also checks dnsmasq is ok so the hotspot can be generated. 76 | #Check Hostapd is unmasked and disabled 77 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service masked" >/dev/null 2>&1 ;then 78 | systemctl unmask hostapd.service >/dev/null 2>&1 79 | fi 80 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service enabled" >/dev/null 2>&1 ;then 81 | systemctl disable hostapd.service >/dev/null 2>&1 82 | systemctl stop hostapd >/dev/null 2>&1 83 | fi 84 | #Check dnsmasq is disabled 85 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service masked" >/dev/null 2>&1 ;then 86 | systemctl unmask dnsmasq >/dev/null 2>&1 87 | fi 88 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service enabled" >/dev/null 2>&1 ;then 89 | systemctl disable dnsmasq >/dev/null 2>&1 90 | systemctl stop dnsmasq >/dev/null 2>&1 91 | fi 92 | } 93 | 94 | 95 | FindSSID() 96 | { 97 | #Check to see what SSID's and MAC addresses are in range 98 | ssidChk=('NoSSid') 99 | i=0; j=0 100 | until [ $i -eq 1 ] #wait for wifi if busy, usb wifi is slower. 101 | do 102 | ssidreply=$((iw dev "$wifidev" scan ap-force | egrep "^BSS|SSID:") 2>&1) >/dev/null 2>&1 103 | #echo "SSid's in range: " $ssidreply 104 | printf '%s\n' "${ssidreply[@]}" 105 | echo "Device Available Check try " $j 106 | if (($j >= 10)); then #if busy 10 times goto hotspot 107 | echo "Device busy or unavailable 10 times, going to Hotspot" 108 | ssidreply="" 109 | i=1 110 | elif echo "$ssidreply" | grep "No such device (-19)" >/dev/null 2>&1; then 111 | echo "No Device Reported, try " $j 112 | NoDevice 113 | elif echo "$ssidreply" | grep "Network is down (-100)" >/dev/null 2>&1 ; then 114 | echo "Network Not available, trying again" $j 115 | j=$((j + 1)) 116 | sleep 2 117 | elif echo "$ssidreply" | grep "Read-only file system (-30)" >/dev/null 2>&1 ; then 118 | echo "Temporary Read only file system, trying again" 119 | j=$((j + 1)) 120 | sleep 2 121 | elif echo "$ssidreply" | grep "Invalid exchange (-52)" >/dev/null 2>&1 ; then 122 | echo "Temporary unavailable, trying again" 123 | j=$((j + 1)) 124 | sleep 2 125 | elif echo "$ssidreply" | grep -v "resource busy (-16)" >/dev/null 2>&1 ; then 126 | echo "Device Available, checking SSid Results" 127 | i=1 128 | else #see if device not busy in 2 seconds 129 | echo "Device unavailable checking again, try " $j 130 | j=$((j + 1)) 131 | sleep 2 132 | fi 133 | done 134 | 135 | for ssid in "${ssidsmac[@]}" 136 | do 137 | if (echo "$ssidreply" | grep -F -- "$ssid") >/dev/null 2>&1 138 | then 139 | #Valid SSid found, passing to script 140 | echo "Valid SSID Detected, assesing Wifi status" 141 | ssidChk=$ssid 142 | return 0 143 | else 144 | #No Network found, NoSSid issued" 145 | echo "No SSid found, assessing WiFi status" 146 | ssidChk='NoSSid' 147 | fi 148 | done 149 | } 150 | 151 | NoDevice() 152 | { 153 | #if no wifi device,ie usb wifi removed, activate wifi so when it is 154 | #reconnected wifi to a router will be available 155 | echo "No wifi device connected" 156 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 157 | exit 1 158 | } 159 | 160 | chksys 161 | FindSSID 162 | 163 | #Create Hotspot or connect to valid wifi networks 164 | if [ "$ssidChk" != "NoSSid" ] 165 | then 166 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 167 | then #hotspot running and ssid in range 168 | KillHotspot 169 | echo "Hotspot Deactivated, Bringing Wifi Up" 170 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 171 | ChkWifiUp 172 | elif { wpa_cli -i "$wifidev" status | grep 'ip_address'; } >/dev/null 2>&1 173 | then #Already connected 174 | echo "Wifi already connected to a network" 175 | else #ssid exists and no hotspot running connect to wifi network 176 | echo "Connecting to the WiFi Network" 177 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 178 | ChkWifiUp 179 | fi 180 | else #ssid or MAC address not in range 181 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 182 | then 183 | echo "Hostspot already active" 184 | elif { wpa_cli status | grep "$wifidev"; } >/dev/null 2>&1 185 | then 186 | echo "Cleaning wifi files and Activating Hotspot" 187 | wpa_cli terminate >/dev/null 2>&1 188 | ip addr flush "$wifidev" 189 | ip link set dev "$wifidev" down 190 | rm -r /var/run/wpa_supplicant >/dev/null 2>&1 191 | createAdHocNetwork 192 | else #"No SSID, activating Hotspot" 193 | createAdHocNetwork 194 | fi 195 | fi 196 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/autohotspot-direct.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Automatically generates a Hotspot when a valid SSID is not in range 3 | After=multi-user.target 4 | [Service] 5 | Type=oneshot 6 | RemainAfterExit=yes 7 | ExecStart=/usr/bin/autohotspot 8 | [Install] 9 | WantedBy=multi-user.target 10 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/autohotspotN: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #version 0.97-N/HS-I 3 | 4 | #You may share this script on the condition a reference to RaspberryConnect.com 5 | #must be included in copies or derivatives of this script. 6 | 7 | #Network Wifi & Hotspot with Network/Internet 8 | #A script to switch between a wifi network and an Network/Internet routed Hotspot 9 | #A Raspberry Pi with a network port required for Internet in hotspot mode. 10 | #Works at startup or with a seperate timer or manually without a reboot 11 | #Other setup required find out more at 12 | #http://www.raspberryconnect.com 13 | 14 | wifidev="wlan0" #device name to use. Default is wlan0. 15 | ethdev="eth0" #Ethernet port to use with IP tables 16 | #use the command: iw dev ,to see wifi interface name 17 | 18 | IFSdef=$IFS 19 | cnt=0 20 | #These four lines capture the wifi networks the RPi is setup to use 21 | wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' | sed 's/\r//g'| awk 'BEGIN{ORS=","} {print}' | sed 's/\"/''/g' | sed 's/,$//') 22 | IFS="," 23 | ssids=($wpassid) 24 | IFS=$IFSdef #reset back to defaults 25 | 26 | 27 | #Note:If you only want to check for certain SSIDs 28 | #Remove the # in in front of ssids=('mySSID1'.... below and put a # infront of all four lines above 29 | # separated by a space, eg ('mySSID1' 'mySSID2') 30 | #ssids=('mySSID1' 'mySSID2' 'mySSID3') 31 | 32 | #Enter the Routers Mac Addresses for hidden SSIDs, seperated by spaces ie 33 | #( '11:22:33:44:55:66' 'aa:bb:cc:dd:ee:ff' ) 34 | mac=() 35 | 36 | ssidsmac=("${ssids[@]}" "${mac[@]}") #combines ssid and MAC for checking 37 | 38 | createAdHocNetwork() 39 | { 40 | echo "Autohotspot by RaspberryConnect.com" 41 | echo "Creating Hotspot" 42 | ip link set dev "$wifidev" down 43 | ip a add 192.168.50.5/24 brd + dev "$wifidev" 44 | ip link set dev "$wifidev" up 45 | dhcpcd -k "$wifidev" >/dev/null 2>&1 46 | if iptables 2>&1 | grep 'no command specified' ; then 47 | iptables -t nat -A POSTROUTING -o "$ethdev" -j MASQUERADE 48 | iptables -A FORWARD -i "$ethdev" -o "$wifidev" -m state --state RELATED,ESTABLISHED -j ACCEPT 49 | iptables -A FORWARD -i "$wifidev" -o "$ethdev" -j ACCEPT 50 | elif nft 2>&1 | grep 'no command specified' ; then 51 | nft add table inet ap 52 | nft add chain inet ap rthrough { type nat hook postrouting priority 0 \; policy accept \; } 53 | nft add rule inet ap rthrough oifname "$ethdev" masquerade 54 | nft add chain inet ap fward { type filter hook forward priority 0 \; policy accept \; } 55 | nft add rule inet ap fward iifname "$ethdev" oifname "$wifidev" ct state established,related accept 56 | nft add rule inet ap fward iifname "$wifidev" oifname "$ethdev" accept 57 | fi 58 | systemctl start dnsmasq 59 | systemctl start hostapd 60 | echo 1 > /proc/sys/net/ipv4/ip_forward 61 | } 62 | 63 | KillHotspot() 64 | { 65 | echo "Autohotspot by RaspberryConnect.com" 66 | echo "Shutting Down Hotspot" 67 | ip link set dev "$wifidev" down 68 | systemctl stop hostapd 69 | systemctl stop dnsmasq 70 | if iptables 2>&1 | grep 'no command specified' ; then 71 | iptables -D FORWARD -i "$ethdev" -o "$wifidev" -m state --state RELATED,ESTABLISHED -j ACCEPT 72 | iptables -D FORWARD -i "$wifidev" -o "$ethdev" -j ACCEPT 73 | elif nft 2>&1 | grep 'no command specified' ; then 74 | nft delete table inet ap 75 | fi 76 | echo 0 > /proc/sys/net/ipv4/ip_forward 77 | ip addr flush dev "$wifidev" 78 | ip link set dev "$wifidev" up 79 | dhcpcd -n "$wifidev" >/dev/null 2>&1 80 | } 81 | 82 | ChkWifiUp() 83 | { 84 | echo "Checking WiFi connection ok" 85 | sleep 20 #give time for connection to be completed to router 86 | if ! wpa_cli -i "$wifidev" status | grep 'ip_address' >/dev/null 2>&1 87 | then #Failed to connect to wifi (check your wifi settings, password etc) 88 | echo 'Wifi failed to connect, falling back to Hotspot.' 89 | wpa_cli terminate "$wifidev" >/dev/null 2>&1 90 | createAdHocNetwork 91 | fi 92 | } 93 | 94 | chksys() 95 | { 96 | #After some system updates hostapd gets masked using Raspbian Buster, and above. This checks and fixes 97 | #the issue and also checks dnsmasq is ok so the hotspot can be generated. 98 | #Check Hostapd is unmasked and disabled 99 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service masked" >/dev/null 2>&1 ;then 100 | systemctl unmask hostapd.service >/dev/null 2>&1 101 | fi 102 | if systemctl -all list-unit-files hostapd.service | grep "hostapd.service enabled" >/dev/null 2>&1 ;then 103 | systemctl disable hostapd.service >/dev/null 2>&1 104 | systemctl stop hostapd >/dev/null 2>&1 105 | fi 106 | #Check dnsmasq is disabled 107 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service masked" >/dev/null 2>&1 ;then 108 | systemctl unmask dnsmasq >/dev/null 2>&1 109 | fi 110 | if systemctl -all list-unit-files dnsmasq.service | grep "dnsmasq.service enabled" >/dev/null 2>&1 ;then 111 | systemctl disable dnsmasq >/dev/null 2>&1 112 | systemctl stop dnsmasq >/dev/null 2>&1 113 | fi 114 | } 115 | 116 | 117 | FindSSID() 118 | { 119 | #Check to see what SSID's and MAC addresses are in range 120 | ssidChk=('NoSSid') 121 | i=0; j=0 122 | until [ $i -eq 1 ] #wait for wifi if busy, usb wifi is slower. 123 | do 124 | ssidreply=$((iw dev "$wifidev" scan ap-force | egrep "^BSS|SSID:") 2>&1) >/dev/null 2>&1 125 | #echo "SSid's in range: " $ssidreply 126 | printf '%s\n' "${ssidreply[@]}" 127 | echo "Device Available Check try " $j 128 | if (($j >= 10)); then #if busy 10 times goto hotspot 129 | echo "Device busy or unavailable 10 times, going to Hotspot" 130 | ssidreply="" 131 | i=1 132 | elif echo "$ssidreply" | grep "No such device (-19)" >/dev/null 2>&1; then 133 | echo "No Device Reported, try " $j 134 | NoDevice 135 | elif echo "$ssidreply" | grep "Network is down (-100)" >/dev/null 2>&1 ; then 136 | echo "Network Not available, trying again" $j 137 | j=$((j + 1)) 138 | sleep 2 139 | elif echo "$ssidreply" | grep "Read-only file system (-30)" >/dev/null 2>&1 ; then 140 | echo "Temporary Read only file system, trying again" 141 | j=$((j + 1)) 142 | sleep 2 143 | elif echo "$ssidreply" | grep "Invalid exchange (-52)" >/dev/null 2>&1 ; then 144 | echo "Temporary unavailable, trying again" 145 | j=$((j + 1)) 146 | sleep 2 147 | elif echo "$ssidreply" | grep -v "resource busy (-16)" >/dev/null 2>&1 ; then 148 | echo "Device Available, checking SSid Results" 149 | i=1 150 | else #see if device not busy in 2 seconds 151 | echo "Device unavailable checking again, try " $j 152 | j=$((j + 1)) 153 | sleep 2 154 | fi 155 | done 156 | 157 | for ssid in "${ssidsmac[@]}" 158 | do 159 | if (echo "$ssidreply" | grep -F -- "$ssid") >/dev/null 2>&1 160 | then 161 | #Valid SSid found, passing to script 162 | echo "Valid SSID Detected, assesing Wifi status" 163 | ssidChk=$ssid 164 | return 0 165 | else 166 | #No Network found, NoSSid issued" 167 | echo "No SSid found, assessing WiFi status" 168 | ssidChk='NoSSid' 169 | fi 170 | done 171 | } 172 | 173 | NoDevice() 174 | { 175 | #if no wifi device,ie usb wifi removed, activate wifi so when it is 176 | #reconnected wifi to a router will be available 177 | echo "No wifi device connected" 178 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 179 | exit 1 180 | } 181 | 182 | chksys 183 | FindSSID 184 | 185 | #Create Hotspot or connect to valid wifi networks 186 | if [ "$ssidChk" != "NoSSid" ] 187 | then 188 | echo 0 > /proc/sys/net/ipv4/ip_forward #deactivate ip forwarding 189 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 190 | then #hotspot running and ssid in range 191 | KillHotspot 192 | echo "Hotspot Deactivated, Bringing Wifi Up" 193 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 194 | ChkWifiUp 195 | elif { wpa_cli -i "$wifidev" status | grep 'ip_address'; } >/dev/null 2>&1 196 | then #Already connected 197 | echo "Wifi already connected to a network" 198 | else #ssid exists and no hotspot running connect to wifi network 199 | echo "Connecting to the WiFi Network" 200 | wpa_supplicant -B -i "$wifidev" -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1 201 | ChkWifiUp 202 | fi 203 | else #ssid or MAC address not in range 204 | if systemctl status hostapd | grep "(running)" >/dev/null 2>&1 205 | then 206 | echo "Hostspot already active" 207 | elif { wpa_cli status | grep "$wifidev"; } >/dev/null 2>&1 208 | then 209 | echo "Cleaning wifi files and Activating Hotspot" 210 | wpa_cli terminate >/dev/null 2>&1 211 | ip addr flush "$wifidev" 212 | ip link set dev "$wifidev" down 213 | rm -r /var/run/wpa_supplicant >/dev/null 2>&1 214 | createAdHocNetwork 215 | else #"No SSID, activating Hotspot" 216 | createAdHocNetwork 217 | fi 218 | fi 219 | 220 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/dhcpcd-SHS.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #Static Hotspot without Net 3 | interface wlan0 4 | nohook wpa_supplicant 5 | static ip_address=192.168.50.10/24 6 | static routers=192.168.50.1 7 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/dhcpcd-SHSN.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #Static Hotspot with Net 3 | interface wlan0 4 | nohook wpa_supplicant 5 | static ip_address=192.168.50.10/24 6 | static routers=192.168.50.1 7 | static domain_name_servers=8.8.8.8 8 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/dhcpcd-autohs.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #Autohotspots 3 | nohook wpa_supplicant -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/dhcpcd-default.conf: -------------------------------------------------------------------------------- 1 | # A sample configuration for dhcpcd. 2 | # See dhcpcd.conf(5) for details. 3 | 4 | # Allow users of this group to interact with dhcpcd via the control socket. 5 | #controlgroup wheel 6 | 7 | # Inform the DHCP server of our hostname for DDNS. 8 | hostname 9 | 10 | # Use the hardware address of the interface for the Client ID. 11 | clientid 12 | # or 13 | # Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361. 14 | # Some non-RFC compliant DHCP servers do not reply with this set. 15 | # In this case, comment out duid and enable clientid above. 16 | #duid 17 | 18 | # Persist interface configuration when dhcpcd exits. 19 | persistent 20 | 21 | # Rapid commit support. 22 | # Safe to enable by default because it requires the equivalent option set 23 | # on the server to actually work. 24 | option rapid_commit 25 | 26 | # A list of options to request from the DHCP server. 27 | option domain_name_servers, domain_name, domain_search, host_name 28 | option classless_static_routes 29 | # Respect the network MTU. This is applied to DHCP routes. 30 | option interface_mtu 31 | 32 | # Most distributions have NTP support. 33 | #option ntp_servers 34 | 35 | # A ServerID is required by RFC2131. 36 | require dhcp_server_identifier 37 | 38 | # Generate SLAAC address using the Hardware Address of the interface 39 | #slaac hwaddr 40 | # OR generate Stable Private IPv6 Addresses based from the DUID 41 | slaac private 42 | 43 | # Example static IP configuration: 44 | #interface eth0 45 | #static ip_address=192.168.0.10/24 46 | #static ip6_address=fd51:42f8:caae:d92e::ff/64 47 | #static routers=192.168.0.1 48 | #static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1 49 | 50 | # It is possible to fall back to a static IP if DHCP fails: 51 | # define static profile 52 | #profile static_eth0 53 | #static ip_address=192.168.1.23/24 54 | #static routers=192.168.1.1 55 | #static domain_name_servers=192.168.1.1 56 | 57 | # fallback to static profile on eth0 58 | #interface eth0 59 | #fallback static_eth0 60 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/dhcpcd-remove.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #Autohotspots 3 | #If you make changes to this file please back it up. 4 | #Option 3 of the installer will replace this file. 5 | #A backup was taken on the inital install. /etc/dhcpcd-RCbackup.conf 6 | nohook wpa_supplicant 7 | #Static Hotspot without Net 8 | interface wlan0 9 | static ip_address=192.168.50.10/24 10 | static routers=192.168.50.1 11 | #Static Hotspot with Net 12 | static domain_name_servers=8.8.8.8 13 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/dnsmasqAHS.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #AutoHotspot Config 3 | interface=wlan0 4 | no-resolv 5 | bind-interfaces 6 | dhcp-range=10.0.0.50,10.0.0.100,12h 7 | 8 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/dnsmasqAHSN.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com Autohotspot 2 | #AutoHotspotN config 3 | interface=wlan0 4 | bind-dynamic 5 | server=8.8.8.8 6 | domain-needed 7 | bogus-priv 8 | dhcp-range=192.168.50.150,192.168.50.200,72h 9 | 10 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/dnsmasqSHS.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com 2 | #RPiHotspot config - Internet 3 | interface=wlan0 4 | bind-dynamic 5 | domain-needed 6 | bogus-priv 7 | server=8.8.8.8 8 | dhcp-range=192.168.50.150,192.168.50.200,255.255.255.0,12h 9 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/hostapd: -------------------------------------------------------------------------------- 1 | # Defaults for hostapd initscript 2 | # 3 | # WARNING: The DAEMON_CONF setting has been deprecated and will be removed 4 | # in future package releases. 5 | # 6 | # See /usr/share/doc/hostapd/README.Debian for information about alternative 7 | # methods of managing hostapd. 8 | # 9 | # Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration 10 | # file and hostapd will be started during system boot. An example configuration 11 | # file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz 12 | # 13 | DAEMON_CONF="/etc/hostapd/hostapd.conf" 14 | 15 | # Additional daemon options to be appended to hostapd command:- 16 | # -d show more debug messages (-dd for even more) 17 | # -K include key data in debug messages 18 | # -t include timestamps in some debug messages 19 | # 20 | # Note that -B (daemon mode) and -P (pidfile) options are automatically 21 | # configured by the init.d script and must not be added to DAEMON_OPTS. 22 | # 23 | #DAEMON_OPTS="" 24 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/hostapd.conf: -------------------------------------------------------------------------------- 1 | #RaspberryConnect.com - Autohotspot 2 | #2.4GHz setup wifi 80211 b,g,n 3 | interface=wlan0 4 | driver=nl80211 5 | ssid=RPiHotspot 6 | hw_mode=g 7 | channel=8 8 | wmm_enabled=0 9 | macaddr_acl=0 10 | auth_algs=1 11 | ignore_broadcast_ssid=0 12 | wpa=2 13 | wpa_passphrase=1234567890 14 | wpa_key_mgmt=WPA-PSK 15 | wpa_pairwise=CCMP 16 | rsn_pairwise=CCMP 17 | 18 | #80211n - Change GB to your WiFi country code 19 | country_code=GB 20 | ieee80211n=1 21 | ieee80211d=1 22 | 23 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/hs-iptables.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Activate IPtables for Hotspot 3 | After=network-pre.target 4 | Before=network-online.target 5 | 6 | [Service] 7 | Type=simple 8 | ExecStart=/etc/iptables-hs 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/interfaces: -------------------------------------------------------------------------------- 1 | # interfaces(5) file used by ifup(8) and ifdown(8) 2 | 3 | # Please note that this file is written to be used with dhcpcd 4 | # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' 5 | 6 | # Include files from /etc/network/interfaces.d: 7 | source-directory /etc/network/interfaces.d 8 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/iptables-hs.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 3 | iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT 4 | iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT 5 | 6 | -------------------------------------------------------------------------------- /AutoHotspot-Setup/Autohotspot/config/nft-stat-ap.txt: -------------------------------------------------------------------------------- 1 | flush ruleset 2 | 3 | table inet ap { 4 | chain routethrough { 5 | type nat hook postrouting priority filter; policy accept; 6 | oifname "eth0" masquerade 7 | } 8 | 9 | chain fward { 10 | type filter hook forward priority filter; policy accept; 11 | iifname "eth0" oifname "wlan0" ct state established,related accept 12 | iifname "wlan0" oifname "eth0" accept 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | RaspberryConnect.com 2 | This installer script and the autohotspot & autohotspotN scripts can be shared and modified but all references to RaspberryConnect.com must be kept in place. 3 | 4 | For use with PiOS 11 Bullseye and lower. 5 | Not compatible with PiOS 12 Bookworm. The Bookworm version is currently available at 6 | https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/203-automated-switching-accesspoint-wifi-network 7 | 8 | # AutoHotspot Setups 9 | 10 | This script is for installing a Raspberry Pi WiFi setup where the Pi will connect to a previously configured Wifi network when the Pi is in range of the router or Automatically setup a Raspberry Pi access point when a known wifi network is not in range. 11 | This can also be run manually or with a timer to switch between a WiFi network or a WifI access point without a reboot. 12 | 13 | There are two setups available: 14 | * Network/Internet access available for connected devices when an ethernet cable is connected for the Raspberry Pi's 3A,3B,3B+ & 4. For Rapberry Pi's A,B, B+,& 2 if an usb Wifi adapter is used. 15 | * No internet access for connected devices. Designed for the Raspberry Pi Zero W or other Raspberry PI's where only a direct connection to the PI from a phone, tablet or Laptop is required. 16 | 17 | There is also a setup for permanent access point with network/internet access from eth0 for WiFi connected devices. 18 | 19 | For more information and for the manual setup's see: 20 | * https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/157-raspberry-pi-auto-wifi-hotspot-switch-internet 21 | * https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/158-raspberry-pi-auto-wifi-hotspot-switch-direct-connection 22 | * https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/168-raspberry-pi-hotspot-access-point-dhcpcd-method 23 | 24 | This script will install any of these three setups or allow you to change between setup types. 25 | In additionm the Access Point SSID and Password can be changed, new WiFi networks can be added to the Raspberry PI while in access point mode. The Pi can be forced between WiFi Network mode and Access Point mode without a reboot. Also there is an uninstaller. 26 | 27 | # Using the installer 28 | 29 | Download the AutoHotspot-Setup.tar.xz archive from 30 | ``` 31 | curl "https://www.raspberryconnect.com/images/hsinstaller/Autohotspot-Setup.tar.xz" -o AutoHotspot-Setup.tar.xz 32 | ``` 33 | Unarchive the file to the curent folder using the command 34 | ``` 35 | tar -xzvf AutoHotspot-Setup.tar.xz 36 | ``` 37 | If you are using the Desktop then right click on the AutoHotspot-Setup.tar.xz and select Extract Here 38 | 39 | open a terminal window and navigate to the Autohotspot folder. If this is in your home directory then use 40 | ``` 41 | cd Autohotspot 42 | ``` 43 | if this is your desktop then use 44 | ``` 45 | cd ./Desktop/Autohotspot 46 | ``` 47 | Run the script with the command 48 | ``` 49 | sudo ./autohotspot-setup.sh 50 | ``` 51 | This script will fail if sudo is not used. 52 | 53 | You will presented with a menu with these options 54 | ``` 55 | 1 = Install Autohotspot with eth0 access for Connected Devices 56 | 2 = Install Autohotspot with No eth0 for connected devices 57 | 3 = Install a Permanent Access Point with eth0 access for connected devices 58 | 4 = Uninstall Autohotspot or permanent access point 59 | 5 = Add a new wifi network to the Pi (SSID) or update the password for an existing one. 60 | 6 = Autohotspot: Force to an access point or connect to WiFi network if a known SSID is in range 61 | 7 = Change the access points SSID and password 62 | 8 = Exit 63 | ``` 64 | 65 | In these options, Options 1-4 determine the overall type of your installation. Options 5-7 allow changing of passwords and testing. 66 | 67 | # Main installation options 68 | 69 | The main installation options are Options 1-4. 70 | 71 | ## Option 1: Install Autohotspot with eth0 access for Connected Devices 72 | 73 | Once installed and after a reboot the Raspberry Pi will connect to a router that has previously been connected to and is listed in /etc/wpa_supplicant/wpa_supplicant.conf. If no router is in range then it will generate a WiFi access point. 74 | * This will have an SSID of RPiHotspot and password of 1234567890. 75 | * Use option 7 to change the access point password and also the SSID if required. 76 | If an ethernet cable is connected to the Pi with access to the internet then it will allow devices connected to the access point to connect to the internet or local network. 77 | Once a connection to the access point has been made you can access the Raspberry Pi via ssh & VNC with 78 | * `ssh pi@192.168.50.5` 79 | * vnc: 192.168.50.5::5900 80 | * for webservers use http://192.168.50.5/ 81 | 82 | The option installs 83 | ``` 84 | /usr/bin/autohotspotN 85 | ``` 86 | As noted above, this setup provides network/Internet access for connected devices 87 | * when an ethernet cable is connected for the Raspberry Pi's 3A,3B,3B+ & 4, 88 | * Or, for Rapberry Pi's A,B, B+,& 2, if a usb Wifi adapter is used. 89 | 90 | ## Option 2: Install Autohotspot with No eth0 for connected devices 91 | 92 | This option is similar to option 1 but connected devices have no network/internet connection if an ethernet cable is connected. 93 | The Pi itself can use the eth0 connection and also be accessed from a device on the etho network. 94 | * This has been designed so you can access only the Pi from a Laptop, tablet or phone. 95 | * The access point SSID will be RPiHotspot with a password of 1234567890 96 | Once a connection to the access point has been made you can access the Raspberry Pi via ssh & VNC with 97 | * `ssh pi@10.0.0.5` 98 | * vnc: 10.0.0.5::5900 99 | * for webservers use http://10.0.0.5/ 100 | 101 | The option installs 102 | ``` 103 | /usr/bin/autohotspot 104 | ``` 105 | As noted above, this provides no internet access for connected devices. The mode is designed for the Raspberry Pi Zero W or other Raspberry PI's where only a direct connection to the PI from a phone, tablet or Laptop is required. 106 | 107 | ## Option 3: Install a Permanent Access Point with eth0 access for connected devices 108 | 109 | This is for a permanent WiFi access point with network/internet access for connected devices. 110 | The Raspberry Pi will only have network and internet access when an ethernet cable is connected. 111 | Once a connection to the access point has been made, you can access the Raspberry Pi via ssh & VNC with 112 | * `ssh pi@192.168.50.10` 113 | * vnc: 192.168.50.10::5900 114 | * for webservers use http://192.168.50.10/ 115 | 116 | Additional setup is required if you wanted to use a second WiFi device to connect to a network or internet rather than a ethernet conection. 117 | This requires changing the references in the iptables or fftables files from eth0 to wlan1 118 | * /etc/iptables-hs (PiOS version 10 or lower , Buster) 119 | * /etc/nftables/nft-stat-ap.nft (PiOS version 11 or higher, Bullseye) 120 | 121 | ## Option 4: Uninstall Autohotspot or Permanent Access Point 122 | 123 | This will disable the setup of any of the three setups and return the Raspberry Pi to default Wifi settings. 124 | Hostapd & dnsmasq will not be uninstalled just disabled. 125 | 126 | # Configuration options 127 | 128 | Options 5 and 7 allow changing of passwords. Option 6 allows 'force switch' between hotspot and WiFi network, useful for testing. 129 | 130 | ## Option 5: Add a new wifi network to the Pi (SSID) or update the password for an existing one. 131 | 132 | If you are using either of the autohotspot setups in access point mode and wish to connect to a local WiFi network. You will be unable to scan for any networks as the desktop wifi option will be disabled, shown as red crosses. You can manually add the details to /etc/wpa_supplicant/wpa_supplicant.conf if you know them. 133 | This option will allow you to scan for local WiFi networks and update the Pi. If you then reboot or use the Force... option 6 ,see below. 134 | This option only works for WiFi networks where only a password is required. If a username is required this will not work. 135 | 136 | ## Option 6: Autohotspot: Force to an access point or Force to WiFi network if a known SSID is in range 137 | 138 | This option is only for the Autohotspot setups. 139 | If you are at home and connected to your home network but would like to use the hotspot. This option will force the pi to access point mode and will ignore your home network untill the next reboot. If you use this option again while in access point mode, it will attempt to connect to a known WiFi network. This will go back to the access point if no valid WiFi network is found or there is a connection issue. 140 | 141 | ## Option 7: Change the Pi's access point SSID and Password 142 | 143 | By default the access point SSID is RPiHotSpot with a password of 1234567890. Use this option to change either or both SSID and Password. 144 | You will be prompted to change both but if you make no entry and press enter the existing setting will be kept. 145 | The password must be at least 8 characters. 146 | 147 | ## Option 8: Exit 148 | 149 | Exit the script. 150 | 151 | 152 | # Note 153 | 154 | # Regarding `/etc/network/interfaces` file 155 | 156 | Many older access points and network setup guides online add entries to the `/etc/network/interfaces` file. This file is depreciated in Raspbian & PiOS. Any entry in this file is not compatible with these setups. This installer backup and remove any entries found in this file. They will be restored if the uninstall option is used. 157 | 158 | # The service is just for automatic start at boot time. 159 | 160 | The system service just facilitates automatic start at boot time. It doesn't do any checking while the configuration is running. Note that, unfortunately, a systemd timer doesn't work with the script so it can't be repeated with that. Therefore, another script or `cron` is the best way to rerun the script at intervals. 161 | 162 | For running a timer you simply add `/usr/bin/autohotspot` or `/usr/bin/autohotspotN` to the root crontab. E.g. to run every 5 minutes: 163 | ``` 164 | */5 * * * * sudo /usr/bin/autohotspot >/dev/null 2>&1 165 | ``` 166 | For more detailed instructions, see here: https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/158-raspberry-pi-auto-wifi-hotspot-switch-direct-connection. 167 | 168 | 169 | # Suppose I wanted the script, but without running it at boot time? 170 | 171 | In other words, only run the script as needed. Would the correct process be to install the script (e.g. Options 1 or 2, as required), and then disable the service? 172 | 173 | To do this install and disable the service. Though wpa_supplicant will be disabled in `/etc/dhcpcd.conf` so you will get no wifi network connection. To reactivate it comment out the line `nohook wpa_supplicant`. If you re-enable the service then that needs to be un-commented. 174 | 175 | This process will stop the script running at boot. You can then manually run `sudo /usr/bin/autohotspotN` (Option 1) / `sudo /usr/bin/autohotspot` (Option 2). You can run the service `sudo systemctl start autohotspot` as this will also run the autohotspot script once on demand. 176 | 177 | # Can I use `ifup` and `ifdown`? 178 | 179 | `ifup` and `ifdown` use the `/network/interfaces` file i believe which is depreciated on the PiOS so you will need to use 180 | `ip link set dev wlan0 down` and `ip link set dev wlan0 up`. 181 | 182 | However if you bring wlan0 down while the access point is running, you will need to bring wlan0 up and then run the autohotspot straight after as hostapd will not restart on it's own. 183 | 184 | You can bring wlan0 down and up while connected to a wifi network ok with `ip link set dev wlan0 down / up` 185 | 186 | if it does not come back up properly then rebind dhcpcd with `sudo dhcpcd -n wlan0` 187 | which will do the trick. 188 | 189 | 190 | RaspberryConnect.com 191 | 192 | Jan 29th 2022, with updates 26 July 2023 193 | --------------------------------------------------------------------------------