init-ifupdown: adapt recipe for read-only-rootfs
This recipe had a post install script to do the following: - create runlevel symlinks. - comment the 'auto' lines of /etc/network/interfaces if running on a non-Wi-Fi variant. - add Atheros or QCA bridge examples depending on the detected chip. - add wlan1 interface only if QCA chip is detected. This post install cannot run on a read-only-rootfs so the recipe has been reworked to do the same things at build time: - the runlevel symlinks have been removed because they are taken care of by a poky class. - add a pre-up condition (the existance of a wireless entry on the device tree) so that the interface is not brought up if the condition is not met. - for the cc6/cc6n, since the Wi-Fi chip can be Atheros or QCA, add specific wlan1 and br0 fragments with a pre-up condition basing on the detected ID of the Wi-Fi chip Signed-off-by: Hector Palacios <hector.palacios@digi.com> https://onedigi.atlassian.net/browse/DEL-7708
This commit is contained in:
parent
bc88451131
commit
71b3623b59
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
## Example bridge between eth0 and wlan0
|
## Example bridge between eth0 and wlan0 (Atheros AR6233)
|
||||||
#auto br0
|
#auto br0
|
||||||
#iface br0 inet static
|
#iface br0 inet static
|
||||||
# bridge_ports eth0 wlan0
|
# bridge_ports eth0 wlan0
|
||||||
|
|
@ -7,3 +7,4 @@
|
||||||
# netmask 255.255.255.0
|
# netmask 255.255.255.0
|
||||||
# bridge_wpa_driver nl80211
|
# bridge_wpa_driver nl80211
|
||||||
# bridge_wpa_conf /etc/wpa_supplicant.conf
|
# bridge_wpa_conf /etc/wpa_supplicant.conf
|
||||||
|
# pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
## Example bridge between eth0 and wlan1 (Qualcomm QCA65x4)
|
||||||
|
#auto br0
|
||||||
|
#iface br0 inet static
|
||||||
|
# bridge_ports eth0 wlan1
|
||||||
|
# address 192.168.42.50
|
||||||
|
# netmask 255.255.255.0
|
||||||
|
# pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ]
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
# Wi-Fi AP interface (Atheros AR6233)
|
||||||
|
#auto wlan1
|
||||||
|
iface wlan1 inet dhcp
|
||||||
|
udhcpc_opts -S -b >/dev/null &
|
||||||
|
pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ]
|
||||||
|
wpa-driver nl80211
|
||||||
|
wpa-conf /etc/wpa_supplicant.conf
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
# Wi-Fi AP interface (Atheros AR6233)
|
||||||
|
#auto wlan1
|
||||||
|
iface wlan1 inet static
|
||||||
|
address ##WLAN1_STATIC_IP##
|
||||||
|
netmask ##WLAN1_STATIC_NETMASK##
|
||||||
|
gateway ##WLAN1_STATIC_GATEWAY##
|
||||||
|
dns-nameservers ##WLAN1_STATIC_DNS##
|
||||||
|
pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d0301) ]
|
||||||
|
wpa-driver nl80211
|
||||||
|
wpa-conf /etc/wpa_supplicant.conf
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
# Wi-Fi AP interface (Qualcomm QCA65x4)
|
||||||
|
#auto wlan1
|
||||||
|
iface wlan1 inet dhcp
|
||||||
|
udhcpc_opts -S -b >/dev/null &
|
||||||
|
pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ]
|
||||||
|
post-up ##WLAN1_POST_UP_ACTION##
|
||||||
|
pre-down ##WLAN1_PRE_DOWN_ACTION##
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
# Wi-Fi AP interface (Qualcomm QCA65x4)
|
||||||
|
#auto wlan1
|
||||||
|
iface wlan1 inet static
|
||||||
|
address ##WLAN1_STATIC_IP##
|
||||||
|
netmask ##WLAN1_STATIC_NETMASK##
|
||||||
|
gateway ##WLAN1_STATIC_GATEWAY##
|
||||||
|
dns-nameservers ##WLAN1_STATIC_DNS##
|
||||||
|
pre-up [ $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio:c00v0271d050A) ]
|
||||||
|
post-up ##WLAN1_POST_UP_ACTION##
|
||||||
|
pre-down ##WLAN1_PRE_DOWN_ACTION##
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
## Example bridge between eth0 and wlan1
|
## Example bridge between eth0 and wlan1 (Qualcomm QCA65x4)
|
||||||
#auto br0
|
#auto br0
|
||||||
#iface br0 inet static
|
#iface br0 inet static
|
||||||
# bridge_ports eth0 wlan1
|
# bridge_ports eth0 wlan1
|
||||||
# address 192.168.42.50
|
# address 192.168.42.50
|
||||||
# netmask 255.255.255.0
|
# netmask 255.255.255.0
|
||||||
|
# pre-up [ -d /proc/device-tree/wireless ]
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,4 @@ iface ##WLAN_P2P_INTERFACE## inet static
|
||||||
dns-nameservers ##P2P0_STATIC_DNS##
|
dns-nameservers ##P2P0_STATIC_DNS##
|
||||||
wpa-driver ##WPA_DRIVER##
|
wpa-driver ##WPA_DRIVER##
|
||||||
wpa-conf /etc/wpa_supplicant_p2p.conf
|
wpa-conf /etc/wpa_supplicant_p2p.conf
|
||||||
|
pre-up [ -d /proc/device-tree/wireless ]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
|
# Wi-Fi AP interface (Qualcomm QCA65x4)
|
||||||
#auto wlan1
|
#auto wlan1
|
||||||
iface wlan1 inet dhcp
|
iface wlan1 inet dhcp
|
||||||
udhcpc_opts -S -b >/dev/null &
|
udhcpc_opts -S -b >/dev/null &
|
||||||
|
pre-up [ -d /proc/device-tree/wireless ]
|
||||||
post-up ##WLAN1_POST_UP_ACTION##
|
post-up ##WLAN1_POST_UP_ACTION##
|
||||||
pre-down ##WLAN1_PRE_DOWN_ACTION##
|
pre-down ##WLAN1_PRE_DOWN_ACTION##
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
|
|
||||||
|
# Wi-Fi AP interface (Qualcomm QCA65x4)
|
||||||
#auto wlan1
|
#auto wlan1
|
||||||
iface wlan1 inet static
|
iface wlan1 inet static
|
||||||
address ##WLAN1_STATIC_IP##
|
address ##WLAN1_STATIC_IP##
|
||||||
netmask ##WLAN1_STATIC_NETMASK##
|
netmask ##WLAN1_STATIC_NETMASK##
|
||||||
gateway ##WLAN1_STATIC_GATEWAY##
|
gateway ##WLAN1_STATIC_GATEWAY##
|
||||||
dns-nameservers ##WLAN1_STATIC_DNS##
|
dns-nameservers ##WLAN1_STATIC_DNS##
|
||||||
|
pre-up [ -d /proc/device-tree/wireless ]
|
||||||
post-up ##WLAN1_POST_UP_ACTION##
|
post-up ##WLAN1_POST_UP_ACTION##
|
||||||
pre-down ##WLAN1_PRE_DOWN_ACTION##
|
pre-down ##WLAN1_PRE_DOWN_ACTION##
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,16 @@ SRC_URI_append = " \
|
||||||
${@oe.utils.conditional('HAS_WIFI_VIRTWLANS', 'true', '${WIFI_VIRTWLANS_FILES}', '', d)} \
|
${@oe.utils.conditional('HAS_WIFI_VIRTWLANS', 'true', '${WIFI_VIRTWLANS_FILES}', '', d)} \
|
||||||
"
|
"
|
||||||
|
|
||||||
SRC_URI_append_ccimx6sbc = " file://interfaces.br0.atheros.example"
|
SRC_URI_append_ccimx6sbc = " \
|
||||||
|
file://interfaces.wlan1.atheros.static \
|
||||||
|
file://interfaces.wlan1.atheros.dhcp \
|
||||||
|
file://interfaces.br0.atheros.example \
|
||||||
|
"
|
||||||
|
|
||||||
SYSTEMD_SERVICE_${PN} = "ifupdown.service"
|
SYSTEMD_SERVICE_${PN} = "ifupdown.service"
|
||||||
|
|
||||||
WPA_DRIVER ?= "nl80211"
|
WPA_DRIVER ?= "nl80211"
|
||||||
|
|
||||||
IS_CCIMX6 ?= "0"
|
|
||||||
IS_CCIMX6_ccimx6sbc = "1"
|
|
||||||
|
|
||||||
do_install_append() {
|
do_install_append() {
|
||||||
# Install 'ifupdown' scripts
|
# Install 'ifupdown' scripts
|
||||||
install -m 0755 ${WORKDIR}/p2plink ${D}${sysconfdir}/network/if-up.d/
|
install -m 0755 ${WORKDIR}/p2plink ${D}${sysconfdir}/network/if-up.d/
|
||||||
|
|
@ -68,14 +69,11 @@ do_install_append() {
|
||||||
install_wlan1
|
install_wlan1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# On ccimx6, install the two possible br0 fragments in the filesystem
|
cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces
|
||||||
# so we can decide which one to use during runtime depending on the
|
if [ "${MACHINE}" = "ccimx6sbc" ]; then
|
||||||
# wireless MAC used on the SOM.
|
# On ccimx6, append also the Atheros fragments so the user can
|
||||||
if [ "${IS_CCIMX6}" = "1" ]; then
|
# decide which one to use depending on the wireless MAC used on the SOM.
|
||||||
install -m 0644 ${WORKDIR}/interfaces.br0.example ${D}${sysconfdir}
|
cat ${WORKDIR}/interfaces.br0.atheros.example >> ${D}${sysconfdir}/network/interfaces
|
||||||
install -m 0644 ${WORKDIR}/interfaces.br0.atheros.example ${D}${sysconfdir}
|
|
||||||
else
|
|
||||||
cat ${WORKDIR}/interfaces.br0.example >> ${D}${sysconfdir}/network/interfaces
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,67 +87,25 @@ WLAN1_POST_UP_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'syst
|
||||||
WLAN1_PRE_DOWN_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemctl stop hostapd@wlan1.service', '/etc/init.d/hostapd stop', d)}"
|
WLAN1_PRE_DOWN_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemctl stop hostapd@wlan1.service', '/etc/init.d/hostapd stop', d)}"
|
||||||
|
|
||||||
install_wlan1() {
|
install_wlan1() {
|
||||||
TARGET_WLAN1_FILE="${D}${sysconfdir}/network/interfaces"
|
|
||||||
|
|
||||||
if [ -n "${HAVE_WIFI}" ]; then
|
if [ -n "${HAVE_WIFI}" ]; then
|
||||||
# On the ccimx6, install the wlan1 fragment in the filesystem
|
cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces
|
||||||
# so we can decide if we want to incorporate it or not
|
if [ "${MACHINE}" = "ccimx6sbc" ]; then
|
||||||
# depending on the wireless MAC used on the SOM.
|
cat ${WORKDIR}/interfaces.wlan1.atheros.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces
|
||||||
if [ "${IS_CCIMX6}" = "1" ]; then
|
|
||||||
TARGET_WLAN1_FILE="${D}${sysconfdir}/interfaces.wlan1.example"
|
|
||||||
install -m 0644 ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} ${TARGET_WLAN1_FILE}
|
|
||||||
else
|
|
||||||
cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${TARGET_WLAN1_FILE}
|
|
||||||
fi
|
fi
|
||||||
[ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${TARGET_WLAN1_FILE}
|
[ -n "${WLAN1_AUTO}" ] && sed -i -e 's/^#auto wlan1/auto wlan1/g' ${D}${sysconfdir}/network/interfaces
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove config entries if corresponding variable is not defined
|
# Remove config entries if corresponding variable is not defined
|
||||||
[ -z "${WLAN1_STATIC_DNS}" ] && sed -i -e "/##WLAN1_STATIC_DNS##/d" ${TARGET_WLAN1_FILE}
|
[ -z "${WLAN1_STATIC_DNS}" ] && sed -i -e "/##WLAN1_STATIC_DNS##/d" ${D}${sysconfdir}/network/interfaces
|
||||||
[ -z "${WLAN1_STATIC_GATEWAY}" ] && sed -i -e "/##WLAN1_STATIC_GATEWAY##/d" ${TARGET_WLAN1_FILE}
|
[ -z "${WLAN1_STATIC_GATEWAY}" ] && sed -i -e "/##WLAN1_STATIC_GATEWAY##/d" ${D}${sysconfdir}/network/interfaces
|
||||||
[ -z "${WLAN1_STATIC_IP}" ] && sed -i -e "/##WLAN1_STATIC_IP##/d" ${TARGET_WLAN1_FILE}
|
[ -z "${WLAN1_STATIC_IP}" ] && sed -i -e "/##WLAN1_STATIC_IP##/d" ${D}${sysconfdir}/network/interfaces
|
||||||
[ -z "${WLAN1_STATIC_NETMASK}" ] && sed -i -e "/##WLAN1_STATIC_NETMASK##/d" ${TARGET_WLAN1_FILE}
|
[ -z "${WLAN1_STATIC_NETMASK}" ] && sed -i -e "/##WLAN1_STATIC_NETMASK##/d" ${D}${sysconfdir}/network/interfaces
|
||||||
|
|
||||||
# Replace interface parameters
|
# Replace interface parameters
|
||||||
sed -i -e "s,##WLAN1_STATIC_IP##,${WLAN1_STATIC_IP},g" ${TARGET_WLAN1_FILE}
|
sed -i -e "s,##WLAN1_STATIC_IP##,${WLAN1_STATIC_IP},g" ${D}${sysconfdir}/network/interfaces
|
||||||
sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${TARGET_WLAN1_FILE}
|
sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${D}${sysconfdir}/network/interfaces
|
||||||
sed -i -e "s,##WLAN1_STATIC_GATEWAY##,${WLAN1_STATIC_GATEWAY},g" ${TARGET_WLAN1_FILE}
|
sed -i -e "s,##WLAN1_STATIC_GATEWAY##,${WLAN1_STATIC_GATEWAY},g" ${D}${sysconfdir}/network/interfaces
|
||||||
sed -i -e "s,##WLAN1_STATIC_DNS##,${WLAN1_STATIC_DNS},g" ${TARGET_WLAN1_FILE}
|
sed -i -e "s,##WLAN1_STATIC_DNS##,${WLAN1_STATIC_DNS},g" ${D}${sysconfdir}/network/interfaces
|
||||||
sed -i -e "s,##WLAN1_POST_UP_ACTION##,${WLAN1_POST_UP_ACTION},g" ${TARGET_WLAN1_FILE}
|
sed -i -e "s,##WLAN1_POST_UP_ACTION##,${WLAN1_POST_UP_ACTION},g" ${D}${sysconfdir}/network/interfaces
|
||||||
sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${TARGET_WLAN1_FILE}
|
sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${D}${sysconfdir}/network/interfaces
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disable wireless interfaces on first boot for non-wireless variants
|
|
||||||
pkg_postinst_ontarget_${PN}() {
|
|
||||||
if [ ! -d "/proc/device-tree/wireless" ]; then
|
|
||||||
sed -i -e '/^auto wlan/{s,^,#,g};/^auto p2p/{s,^,#,g}' /etc/network/interfaces
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create the symlinks in the different runlevels
|
|
||||||
if type update-rc.d >/dev/null 2>/dev/null; then
|
|
||||||
update-rc.d ${INITSCRIPT_NAME} ${INITSCRIPT_PARAMS}
|
|
||||||
fi
|
|
||||||
|
|
||||||
COMPAT="/proc/device-tree/compatible"
|
|
||||||
WIFI_MAC="/proc/device-tree/wireless/mac-address"
|
|
||||||
|
|
||||||
# Only execute the script on wireless ccimx6 platforms
|
|
||||||
if [ -e ${WIFI_MAC} -a $(grep fsl,imx6dl ${COMPAT} || grep fsl,imx6q ${COMPAT} | grep -v fsl,imx6qp) ]; then
|
|
||||||
for id in $(find /sys/devices -name modalias -print0 | xargs -0 sort -u -z | grep sdio); do
|
|
||||||
if [[ "$id" == "sdio:c00v0271d0301" ]] ; then
|
|
||||||
cat /etc/interfaces.br0.atheros.example >> /etc/network/interfaces
|
|
||||||
rm /etc/network/if-pre-up.d/virtwlans /etc/network/if-post-down.d/virtwlans
|
|
||||||
break
|
|
||||||
elif [[ "$id" == "sdio:c00v0271d050A" ]] ; then
|
|
||||||
cat /etc/interfaces.wlan1.example >> /etc/network/interfaces
|
|
||||||
cat /etc/interfaces.br0.example >> /etc/network/interfaces
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
rm /etc/interfaces.*.example
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
inherit ${@bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs", "remove-pkg-postinst-ontarget", "", d)}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue