##// END OF EJS Templates
Preconfigure Wifi...
Unknown -
r698:1d5e72bc7aa0
parent child
Show More
@@ -123,35 +123,74 Set extra xkb configuration options.
123 123 ---
124 124
125 125 #### Networking settings (DHCP):
126 This parameter is used to set up networking auto-configuration in `/etc/systemd/network/eth.network`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.`
126 This parameter `ENABLE_ETH_DHCP` is used to set up networking auto-configuration in `/etc/systemd/network/eth0.network`. This parameter `ENABLE_WIFI_DHCP` is used to set up networking auto-configuration in `/etc/systemd/network/wlan0.network`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.`
127 127
128 ##### `ENABLE_DHCP`=true
128 ##### `ENABLE_ETH_DHCP`=true
129 129 Set the system to use DHCP. This requires an DHCP server.
130 130
131 ##### `ENABLE_WIFI_DHCP`=true
132 Set the system to use DHCP. This requires an DHCP server.
133
134 ---
135
136 #### Networking settings (ethernet static):
137 These parameters are used to set up a static networking configuration in `/etc/systemd/network/eth0.network`. The following static networking parameters are only supported if `ENABLE_ETH_DHCP` was set to `false`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
138
139 ##### `NET_ETH_ADDRESS`=""
140 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
141
142 ##### `NET_ETH_GATEWAY`=""
143 Set the IP address for the default gateway.
144
145 ##### `NET_ETH_DNS_1`=""
146 Set the IP address for the first DNS server.
147
148 ##### `NET_ETH_DNS_2`=""
149 Set the IP address for the second DNS server.
150
151 ##### `NET_ETH_DNS_DOMAINS`=""
152 Set the default DNS search domains to use for non fully qualified hostnames.
153
154 ##### `NET_ETH_NTP_1`=""
155 Set the IP address for the first NTP server.
156
157 ##### `NET_ETH_NTP_2`=""
158 Set the IP address for the second NTP server.
159
160 ---
161
162 #### Networking settings (WIFI):
163
164 ##### `NET_WIFI_SSID`=""
165 Set to your WIFI SSID
166
167 ##### `NET_WIFI_WPAPSK`=""
168 Set your WPA/WPA2 PSK
169
131 170 ---
132 171
133 #### Networking settings (static):
134 These parameters are used to set up a static networking configuration in `/etc/systemd/network/eth.network`. The following static networking parameters are only supported if `ENABLE_DHCP` was set to `false`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
172 #### Networking settings (WIFI static):
173 These parameters are used to set up a static networking configuration in `/etc/systemd/network/wlan0.network`. The following static networking parameters are only supported if `ENABLE_WIFI_DHCP` was set to `false`. The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.
135 174
136 ##### `NET_ADDRESS`=""
175 ##### `NET_WIFI_ADDRESS`=""
137 176 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
138 177
139 ##### `NET_GATEWAY`=""
178 ##### `NET_WIFI_GATEWAY`=""
140 179 Set the IP address for the default gateway.
141 180
142 ##### `NET_DNS_1`=""
181 ##### `NET_WIFI_DNS_1`=""
143 182 Set the IP address for the first DNS server.
144 183
145 ##### `NET_DNS_2`=""
184 ##### `NET_WIFI_DNS_2`=""
146 185 Set the IP address for the second DNS server.
147 186
148 ##### `NET_DNS_DOMAINS`=""
187 ##### `NET_WIFI_DNS_DOMAINS`=""
149 188 Set the default DNS search domains to use for non fully qualified hostnames.
150 189
151 ##### `NET_NTP_1`=""
190 ##### `NET_WIFI_NTP_1`=""
152 191 Set the IP address for the first NTP server.
153 192
154 ##### `NET_NTP_2`=""
193 ##### `NET_WIFI_NTP_2`=""
155 194 Set the IP address for the second NTP server.
156 195
157 196 ---
@@ -188,7 +227,7 Install and enable OpenSSH service. The default configuration of the service doe
188 227 Allow the installation of non-free Debian packages that do not comply with the DFSG. This is required to install closed-source firmware binary blobs.
189 228
190 229 ##### `ENABLE_WIRELESS`=false
191 Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `3`.
230 Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `0`,`3`,`3P`,`4`.
192 231
193 232 ##### `ENABLE_RSYSLOG`=true
194 233 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
@@ -39,16 +39,16 if [ "$ENABLE_INITRAMFS" = true ] ; then
39 39 fi
40 40
41 41 if [ "$CRYPTFS_DROPBEAR" = true ] ; then
42 if [ "$ENABLE_DHCP" = false ] ; then
42 if [ "$ENABLE_ETH_DHCP" = false ] ; then
43 43 # Get cdir from NET_ADDRESS e.g. 24
44 cdir=$(printf "%s" "${NET_ADDRESS}" | cut -d '/' -f2)
44 cdir=$(printf "%s" "${NET_ETH_ADDRESS}" | cut -d '/' -f2)
45 45
46 46 # Convert cdir ro netmask e.g. 24 to 255.255.255.0
47 47 NET_MASK=$(cdr2mask "$cdir")
48 48
49 49 # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf
50 50 # ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
51 sed -i "\$a\nIP=${NET_ADDRESS}::${NET_GATEWAY}:${NET_MASK}:${HOSTNAME}:" "${ETC_DIR}"/initramfs-tools/initramfs.conf
51 sed -i "\$a\nIP=${NET_ETH_ADDRESS}::${NET_ETH_GATEWAY}:${NET_MASK}:${HOSTNAME}:" "${ETC_DIR}"/initramfs-tools/initramfs.conf
52 52 else
53 53 sed -i "\$a\nIP=::::${HOSTNAME}::dhcp" "${ETC_DIR}"/initramfs-tools/initramfs.conf
54 54 fi
@@ -14,8 +14,8 install_readonly files/network/hosts "${ETC_DIR}/hosts"
14 14 sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts"
15 15
16 16 # Setup hostname entry with static IP
17 if [ "$NET_ADDRESS" != "" ] ; then
18 NET_IP=$(echo "${NET_ADDRESS}" | cut -f 1 -d'/')
17 if [ "$NET_ETH_ADDRESS" != "" ] ; then
18 NET_IP=$(echo "${NET_ETH_ADDRESS}" | cut -f 1 -d'/')
19 19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts"
20 20 fi
21 21
@@ -28,51 +28,92 fi
28 28 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
29 29
30 30 # Install configuration for interface eth0
31 install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network"
31 install_readonly files/network/eth0.network "${ETC_DIR}/systemd/network/eth0.network"
32 32
33 33 if [ "$RPI_MODEL" = 3P ] ; then
34 printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth.network"
34 printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth0.network"
35 35 fi
36 36
37 37 # Install configuration for interface wl*
38 install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network"
38 install_readonly files/network/wlan0.network "${ETC_DIR}/systemd/network/wlan0.network"
39 39
40 40 #always with dhcp since wpa_supplicant integration is missing
41 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network"
41 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan0.network"
42 42
43 if [ "$ENABLE_DHCP" = true ] ; then
43 if [ "$ENABLE_ETH_DHCP" = true ] ; then
44 44 # Enable DHCP configuration for interface eth0
45 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network"
45 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth0.network"
46 46
47 47 # Set DHCP configuration to IPv4 only
48 48 if [ "$ENABLE_IPV6" = false ] ; then
49 sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network"
49 sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth0.network"
50 sed '/IPv6PrivacyExtensions=true/d' "${ETC_DIR}/systemd/network/eth0.network"
50 51 fi
51 52
52 else # ENABLE_DHCP=false
53 else # ENABLE_ETH_DHCP=false
53 54 # Set static network configuration for interface eth0
54 55 sed -i\
55 56 -e "s|DHCP=.*|DHCP=no|"\
56 -e "s|Address=\$|Address=${NET_ADDRESS}|"\
57 -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\
58 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\
59 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\
60 -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
61 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
62 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
63 "${ETC_DIR}/systemd/network/eth.network"
57 -e "s|Address=\$|Address=${NET_ETH_ADDRESS}|"\
58 -e "s|Gateway=\$|Gateway=${NET_ETH_GATEWAY}|"\
59 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_ETH_DNS_1}|"\
60 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_ETH_DNS_2}|"\
61 -e "s|Domains=\$|Domains=${NET_ETH_DNS_DOMAINS}|"\
62 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_ETH_NTP_1}|"\
63 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_ETH_NTP_2}|"\
64 "${ETC_DIR}/systemd/network/eth0.network"
64 65 fi
65 66
67 if [ "$ENABLE_WIFI_DHCP" = true ] ; then
68 # Enable DHCP configuration for interface eth0
69 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan0.network"
70
71 # Set DHCP configuration to IPv4 only
72 if [ "$ENABLE_IPV6" = false ] ; then
73 sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/wlan0.network"
74 sed '/IPv6PrivacyExtensions=true/d' "${ETC_DIR}/systemd/network/wlan0.network"
75 fi
76
77 else # ENABLE_ETH_DHCP=false
78 # Set static network configuration for interface eth0
79 sed -i\
80 -e "s|DHCP=.*|DHCP=no|"\
81 -e "s|Address=\$|Address=${NET_WIFI_ADDRESS}|"\
82 -e "s|Gateway=\$|Gateway=${NET_WIFI_GATEWAY}|"\
83 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_WIFI_DNS_1}|"\
84 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_WIFI_DNS_2}|"\
85 -e "s|Domains=\$|Domains=${NET_WIFI_DNS_DOMAINS}|"\
86 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_WIFI_NTP_1}|"\
87 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_WIFI_NTP_2}|"\
88 "${ETC_DIR}/systemd/network/wlan0.network"
89 fi
90
91 printf "
92 ctrl_interface=/run/wpa_supplicant
93 ctrl_interface_group=wheel
94 update_config=1
95 eapol_version=1
96 ap_scan=1
97 fast_reauth=1
98
99 " > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
100
101 #Configure WPA_supplicant
102 chroot_exec wpa_passphrase "$NET_SSID" "$NET_WPAPSK" >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
103
104 chroot_exec systemctl enable wpa_supplicant.service
105 chroot_exec systemctl enable wpa_supplicant@wlan0.service
106
66 107 # Remove empty settings from network configuration
67 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network"
108 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth0.network"
68 109 # Remove empty settings from wlan configuration
69 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network"
110 sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan0.network"
70 111
71 112 # Move systemd network configuration if required by Debian release
72 mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network"
113 mv -v "${ETC_DIR}/systemd/network/eth0.network" "${LIB_DIR}/systemd/network/10-eth0.network"
73 114 # If WLAN is enabled copy wlan configuration too
74 115 if [ "$ENABLE_WIRELESS" = true ] ; then
75 mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network"
116 mv -v "${ETC_DIR}/systemd/network/wlan0.network" "${LIB_DIR}/systemd/network/11-wlan0.network"
76 117 fi
77 118 rm -fr "${ETC_DIR}/systemd/network"
78 119
@@ -1,13 +1,28
1 1 logger -t "rc.firstboot" "Configuring network interface name"
2 2
3 INTERFACE_NAME=$(dmesg | grep "renamed from eth0" | awk -F ":| " '{ print $9 }')
3 INTERFACE_NAME_ETH=$(dmesg | grep "renamed from eth0" | awk -F ":| " '{ print $9 }')
4 INTERFACE_NAME_WIFI=$(dmesg | grep "renamed from wlan0" | awk -F ":| " '{ print $9 }')
4 5
5 if [ ! -z INTERFACE_NAME ] ; then
6 if [ -r "/etc/systemd/network/eth.network" ] ; then
7 sed -i "s/eth0/${INTERFACE_NAME}/" /etc/systemd/network/eth.network
6 if [ ! -z INTERFACE_NAME_ETH ] ; then
7 if [ -r "/etc/systemd/network/eth0.network" ] ; then
8 sed -i "s/eth0/${INTERFACE_NAME_ETH}/" /etc/systemd/network/eth0.network
8 9 fi
9 10
10 if [ -r "/lib/systemd/network/10-eth.network" ] ; then
11 sed -i "s/eth0/${INTERFACE_NAME}/" /lib/systemd/network/10-eth.network
11 if [ -r "/lib/systemd/network/10-eth0.network" ] ; then
12 sed -i "s/eth0/${INTERFACE_NAME_ETH}/" /lib/systemd/network/10-eth0.network
12 13 fi
14 # Move config to new interface name
15 mv /etc/systemd/network/eth0.network /etc/systemd/network/"${INTERFACE_NAME_ETH}".network
16 fi
17
18 if [ ! -z INTERFACE_NAME_WIFI ] ; then
19 if [ -r "/etc/systemd/network/wlan0.network" ] ; then
20 sed -i "s/wlan0/${INTERFACE_NAME_WIFI}/" /etc/systemd/network/wlan0.network
21 fi
22
23 if [ -r "/lib/systemd/network/11-wlan0.network" ] ; then
24 sed -i "s/wlan0/${INTERFACE_NAME_WIFI}/" /lib/systemd/network/11-wlan0.network
25 fi
26 # Move config to new interface name
27 mv /etc/systemd/network/wlan0.network /etc/systemd/network/"${INTERFACE_NAME_WIFI}".network
13 28 fi
@@ -2,6 +2,8
2 2 Name=eth0
3 3
4 4 [Network]
5 RouteMetric=10
6 IPv6PrivacyExtensions=true
5 7 DHCP=no
6 8 Address=
7 9 Gateway=
@@ -2,6 +2,8
2 2 Name=wlan0
3 3
4 4 [Network]
5 RouteMetric=20
6 IPv6PrivacyExtensions=true
5 7 DHCP=no
6 8 Address=
7 9 Gateway=
@@ -113,16 +113,29 XKB_VARIANT=${XKB_VARIANT:=""}
113 113 XKB_OPTIONS=${XKB_OPTIONS:=""}
114 114
115 115 # Network settings (DHCP)
116 ENABLE_DHCP=${ENABLE_DHCP:=true}
116 ENABLE_ETH_DHCP=${ENABLE_ETH_DHCP:=true}
117 ENABLE_WIFI_DHCP=${ENABLE_ETH_DHCP:=true}
117 118
118 119 # Network settings (static)
119 NET_ADDRESS=${NET_ADDRESS:=""}
120 NET_GATEWAY=${NET_GATEWAY:=""}
121 NET_DNS_1=${NET_DNS_1:=""}
122 NET_DNS_2=${NET_DNS_2:=""}
123 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
124 NET_NTP_1=${NET_NTP_1:=""}
125 NET_NTP_2=${NET_NTP_2:=""}
120 NET_ETH_ADDRESS=${NET_ETH_ADDRESS:=""}
121 NET_ETH_GATEWAY=${NET_ETH_GATEWAY:=""}
122 NET_ETH_DNS_1=${NET_ETH_DNS_1:=""}
123 NET_ETH_DNS_2=${NET_ETH_DNS_2:=""}
124 NET_ETH_DNS_DOMAINS=${NET_ETH_DNS_DOMAINS:=""}
125 NET_ETH_NTP_1=${NET_ETH_NTP_1:=""}
126 NET_ETH_NTP_2=${NET_ETH_NTP_2:=""}
127
128 NET_WIFI_SSID=${NET_SSID:=""}
129 NET_WIFI_WPAPSK=${NET_WPAPSK:=""}
130
131 # Network settings (static)
132 NET_WIFI_ADDRESS=${NET_WIFI_ADDRESS:=""}
133 NET_WIFI_GATEWAY=${NET_WIFI_GATEWAY:=""}
134 NET_WIFI_DNS_1=${NET_WIFI_DNS_1:=""}
135 NET_WIFI_DNS_2=${NET_WIFI_DNS_2:=""}
136 NET_WIFI_DNS_DOMAINS=${NET_WIFI_DNS_DOMAINS:=""}
137 NET_WIFI_NTP_1=${NET_WIFI_NTP_1:=""}
138 NET_WIFI_NTP_2=${NET_WIFI_NTP_2:=""}
126 139
127 140 # APT settings
128 141 APT_PROXY=${APT_PROXY:=""}
@@ -361,7 +374,7 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$
361 374 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
362 375 fi
363 376 if [ "$ENABLE_WIRELESS" = true ] ; then
364 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb"
377 APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb,wpasupplicant"
365 378 fi
366 379 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
367 380 # Check if the internal wireless interface is not supported by the RPi model
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant