Allow setting up wifi from config
Add WPA_ESSID, WPA_PASSWORD and WPA_COUNTRY options to config.
This commit is contained in:
		
							parent
							
								
									d07096ebb5
								
							
						
					
					
						commit
						f4dc2dcce6
					
				|  | @ -81,6 +81,10 @@ The following environment variables are supported: | ||||||
| 
 | 
 | ||||||
|    Password for the first user |    Password for the first user | ||||||
| 
 | 
 | ||||||
|  |  * `WPA_ESSID`, `WPA_PASSWORD` and `WPA_COUNTRY` (Default: unset) | ||||||
|  | 
 | ||||||
|  |    If these are set, they are use to configure `wpa_supplicant.conf`, so that the raspberry pi can automatically connect to a wifi network on first boot. | ||||||
|  | 
 | ||||||
| A simple example for building Raspbian: | A simple example for building Raspbian: | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								build.sh
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								build.sh
									
									
									
									
									
								
							|  | @ -143,6 +143,9 @@ export LOG_FILE="${WORK_DIR}/build.log" | ||||||
| 
 | 
 | ||||||
| export FIRST_USER_NAME=${FIRST_USER_NAME:-pi} | export FIRST_USER_NAME=${FIRST_USER_NAME:-pi} | ||||||
| export FIRST_USER_PASS=${FIRST_USER_PASS:-raspberry} | export FIRST_USER_PASS=${FIRST_USER_PASS:-raspberry} | ||||||
|  | export WPA_ESSID | ||||||
|  | export WPA_PASSWORD | ||||||
|  | export WPA_COUNTRY | ||||||
| 
 | 
 | ||||||
| export BASE_DIR | export BASE_DIR | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -6,3 +6,14 @@ install -v -m 644 files/wait.conf		"${ROOTFS_DIR}/etc/systemd/system/dhcpcd.serv | ||||||
| install -v -d					"${ROOTFS_DIR}/etc/wpa_supplicant" | install -v -d					"${ROOTFS_DIR}/etc/wpa_supplicant" | ||||||
| install -v -m 600 files/wpa_supplicant.conf	"${ROOTFS_DIR}/etc/wpa_supplicant/" | install -v -m 600 files/wpa_supplicant.conf	"${ROOTFS_DIR}/etc/wpa_supplicant/" | ||||||
| 
 | 
 | ||||||
|  | if [ -v WPA_COUNTRY ] | ||||||
|  | then | ||||||
|  | 	echo "country=${WPA_COUNTRY}" >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | if [ -v WPA_ESSID -a -v WPA_PASSWORD ] | ||||||
|  | then | ||||||
|  | on_chroot <<EOF | ||||||
|  | wpa_passphrase ${WPA_ESSID} ${WPA_PASSWORD} >> "/etc/wpa_supplicant/wpa_supplicant.conf" | ||||||
|  | EOF | ||||||
|  | fi | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user