##// 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 #### Networking settings (DHCP):
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 Set the system to use DHCP. This requires an DHCP server.
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):
172 #### Networking settings (WIFI 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`.
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 Set a static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24".
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 Set the IP address for the default gateway.
179 Set the IP address for the default gateway.
141
180
142 ##### `NET_DNS_1`=""
181 ##### `NET_WIFI_DNS_1`=""
143 Set the IP address for the first DNS server.
182 Set the IP address for the first DNS server.
144
183
145 ##### `NET_DNS_2`=""
184 ##### `NET_WIFI_DNS_2`=""
146 Set the IP address for the second DNS server.
185 Set the IP address for the second DNS server.
147
186
148 ##### `NET_DNS_DOMAINS`=""
187 ##### `NET_WIFI_DNS_DOMAINS`=""
149 Set the default DNS search domains to use for non fully qualified hostnames.
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 Set the IP address for the first NTP server.
191 Set the IP address for the first NTP server.
153
192
154 ##### `NET_NTP_2`=""
193 ##### `NET_WIFI_NTP_2`=""
155 Set the IP address for the second NTP server.
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 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.
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 ##### `ENABLE_WIRELESS`=false
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 ##### `ENABLE_RSYSLOG`=true
232 ##### `ENABLE_RSYSLOG`=true
194 If set to false, disable and uninstall rsyslog (so logs will be available only in journal files)
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 fi
39 fi
40
40
41 if [ "$CRYPTFS_DROPBEAR" = true ] ; then
41 if [ "$CRYPTFS_DROPBEAR" = true ] ; then
42 if [ "$ENABLE_DHCP" = false ] ; then
42 if [ "$ENABLE_ETH_DHCP" = false ] ; then
43 # Get cdir from NET_ADDRESS e.g. 24
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 # Convert cdir ro netmask e.g. 24 to 255.255.255.0
46 # Convert cdir ro netmask e.g. 24 to 255.255.255.0
47 NET_MASK=$(cdr2mask "$cdir")
47 NET_MASK=$(cdr2mask "$cdir")
48
48
49 # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf
49 # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf
50 # ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
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 else
52 else
53 sed -i "\$a\nIP=::::${HOSTNAME}::dhcp" "${ETC_DIR}"/initramfs-tools/initramfs.conf
53 sed -i "\$a\nIP=::::${HOSTNAME}::dhcp" "${ETC_DIR}"/initramfs-tools/initramfs.conf
54 fi
54 fi
@@ -14,8 +14,8 install_readonly files/network/hosts "${ETC_DIR}/hosts"
14 sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts"
14 sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts"
15
15
16 # Setup hostname entry with static IP
16 # Setup hostname entry with static IP
17 if [ "$NET_ADDRESS" != "" ] ; then
17 if [ "$NET_ETH_ADDRESS" != "" ] ; then
18 NET_IP=$(echo "${NET_ADDRESS}" | cut -f 1 -d'/')
18 NET_IP=$(echo "${NET_ETH_ADDRESS}" | cut -f 1 -d'/')
19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts"
19 sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts"
20 fi
20 fi
21
21
@@ -28,51 +28,92 fi
28 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
28 install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces"
29
29
30 # Install configuration for interface eth0
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 if [ "$RPI_MODEL" = 3P ] ; then
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 fi
35 fi
36
36
37 # Install configuration for interface wl*
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 #always with dhcp since wpa_supplicant integration is missing
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 # Enable DHCP configuration for interface eth0
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 # Set DHCP configuration to IPv4 only
47 # Set DHCP configuration to IPv4 only
48 if [ "$ENABLE_IPV6" = false ] ; then
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 fi
51 fi
51
52
52 else # ENABLE_DHCP=false
53 else # ENABLE_ETH_DHCP=false
53 # Set static network configuration for interface eth0
54 # Set static network configuration for interface eth0
54 sed -i\
55 sed -i\
55 -e "s|DHCP=.*|DHCP=no|"\
56 -e "s|DHCP=.*|DHCP=no|"\
56 -e "s|Address=\$|Address=${NET_ADDRESS}|"\
57 -e "s|Address=\$|Address=${NET_ETH_ADDRESS}|"\
57 -e "s|Gateway=\$|Gateway=${NET_GATEWAY}|"\
58 -e "s|Gateway=\$|Gateway=${NET_ETH_GATEWAY}|"\
58 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_1}|"\
59 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_ETH_DNS_1}|"\
59 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_DNS_2}|"\
60 -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_ETH_DNS_2}|"\
60 -e "s|Domains=\$|Domains=${NET_DNS_DOMAINS}|"\
61 -e "s|Domains=\$|Domains=${NET_ETH_DNS_DOMAINS}|"\
61 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_1}|"\
62 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_ETH_NTP_1}|"\
62 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_NTP_2}|"\
63 -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_ETH_NTP_2}|"\
63 "${ETC_DIR}/systemd/network/eth.network"
64 "${ETC_DIR}/systemd/network/eth0.network"
64 fi
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 # Remove empty settings from network configuration
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 # Remove empty settings from wlan configuration
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 # Move systemd network configuration if required by Debian release
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 # If WLAN is enabled copy wlan configuration too
114 # If WLAN is enabled copy wlan configuration too
74 if [ "$ENABLE_WIRELESS" = true ] ; then
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 fi
117 fi
77 rm -fr "${ETC_DIR}/systemd/network"
118 rm -fr "${ETC_DIR}/systemd/network"
78
119
@@ -1,13 +1,28
1 logger -t "rc.firstboot" "Configuring network interface name"
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 [ ! -z INTERFACE_NAME_ETH ] ; then
6 if [ -r "/etc/systemd/network/eth.network" ] ; then
7 if [ -r "/etc/systemd/network/eth0.network" ] ; then
7 sed -i "s/eth0/${INTERFACE_NAME}/" /etc/systemd/network/eth.network
8 sed -i "s/eth0/${INTERFACE_NAME_ETH}/" /etc/systemd/network/eth0.network
8 fi
9 fi
9
10
10 if [ -r "/lib/systemd/network/10-eth.network" ] ; then
11 if [ -r "/lib/systemd/network/10-eth0.network" ] ; then
11 sed -i "s/eth0/${INTERFACE_NAME}/" /lib/systemd/network/10-eth.network
12 sed -i "s/eth0/${INTERFACE_NAME_ETH}/" /lib/systemd/network/10-eth0.network
12 fi
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 fi
28 fi
@@ -2,6 +2,8
2 Name=eth0
2 Name=eth0
3
3
4 [Network]
4 [Network]
5 RouteMetric=10
6 IPv6PrivacyExtensions=true
5 DHCP=no
7 DHCP=no
6 Address=
8 Address=
7 Gateway=
9 Gateway=
@@ -2,6 +2,8
2 Name=wlan0
2 Name=wlan0
3
3
4 [Network]
4 [Network]
5 RouteMetric=20
6 IPv6PrivacyExtensions=true
5 DHCP=no
7 DHCP=no
6 Address=
8 Address=
7 Gateway=
9 Gateway=
@@ -113,16 +113,29 XKB_VARIANT=${XKB_VARIANT:=""}
113 XKB_OPTIONS=${XKB_OPTIONS:=""}
113 XKB_OPTIONS=${XKB_OPTIONS:=""}
114
114
115 # Network settings (DHCP)
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 # Network settings (static)
119 # Network settings (static)
119 NET_ADDRESS=${NET_ADDRESS:=""}
120 NET_ETH_ADDRESS=${NET_ETH_ADDRESS:=""}
120 NET_GATEWAY=${NET_GATEWAY:=""}
121 NET_ETH_GATEWAY=${NET_ETH_GATEWAY:=""}
121 NET_DNS_1=${NET_DNS_1:=""}
122 NET_ETH_DNS_1=${NET_ETH_DNS_1:=""}
122 NET_DNS_2=${NET_DNS_2:=""}
123 NET_ETH_DNS_2=${NET_ETH_DNS_2:=""}
123 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
124 NET_ETH_DNS_DOMAINS=${NET_ETH_DNS_DOMAINS:=""}
124 NET_NTP_1=${NET_NTP_1:=""}
125 NET_ETH_NTP_1=${NET_ETH_NTP_1:=""}
125 NET_NTP_2=${NET_NTP_2:=""}
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 # APT settings
140 # APT settings
128 APT_PROXY=${APT_PROXY:=""}
141 APT_PROXY=${APT_PROXY:=""}
@@ -361,7 +374,7 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$
361 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
374 APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez"
362 fi
375 fi
363 if [ "$ENABLE_WIRELESS" = true ] ; then
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 fi
378 fi
366 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
379 else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard
367 # Check if the internal wireless interface is not supported by the RPi model
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