hostapd: add systemd support
When using systemd, putting the wlan1 interface up wasn't working because it was relying on initscripts that are no longer in the filesystem. Add a parametrized version of the upstream hostapd service to be able to use a configuration that's different from the default one. Also, modify the generation of the wlan1 entry in /etc/network/interfaces to be able to use different post-up/pre-down hooks depending on the init manager that's being used. https://jira.digi.com/browse/DEL-6504 Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
parent
e13d086612
commit
b957f0ef75
|
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator (%i)
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
PIDFile=/run/hostapd.%i.pid
|
||||||
|
ExecStart=@SBINDIR@/hostapd @SYSCONFDIR@/hostapd_%i.conf -P /run/hostapd.%i.pid -B
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
@ -1,17 +1,25 @@
|
||||||
# Copyright (C) 2016-2018 Digi International.
|
# Copyright (C) 2016-2019 Digi International.
|
||||||
|
|
||||||
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
||||||
|
|
||||||
SRC_URI_append = " file://hostapd_wlan0.conf"
|
SRC_URI_append = " \
|
||||||
|
file://hostapd_wlan0.conf \
|
||||||
|
file://hostapd@.service \
|
||||||
|
"
|
||||||
SRC_URI_append_ccimx6ul = " file://hostapd_wlan1.conf"
|
SRC_URI_append_ccimx6ul = " file://hostapd_wlan1.conf"
|
||||||
SRC_URI_append_ccimx6qpsbc = " file://hostapd_wlan1.conf"
|
SRC_URI_append_ccimx6qpsbc = " file://hostapd_wlan1.conf"
|
||||||
SRC_URI_append_ccimx8x = " file://hostapd_wlan1.conf"
|
SRC_URI_append_ccimx8x = " file://hostapd_wlan1.conf"
|
||||||
|
|
||||||
|
SYSTEMD_SERVICE_${PN}_append = " hostapd@.service"
|
||||||
|
|
||||||
do_install_append() {
|
do_install_append() {
|
||||||
# Remove the default hostapd.conf
|
# Remove the default hostapd.conf
|
||||||
rm -f ${WORKDIR}/hostapd.conf
|
rm -f ${WORKDIR}/hostapd.conf
|
||||||
# Install custom hostapd_IFACE.conf file
|
# Install custom hostapd_IFACE.conf file
|
||||||
install -m 0644 ${WORKDIR}/hostapd_wlan0.conf ${D}${sysconfdir}
|
install -m 0644 ${WORKDIR}/hostapd_wlan0.conf ${D}${sysconfdir}
|
||||||
|
# Install interface-specific systemd service
|
||||||
|
install -m 0644 ${WORKDIR}/hostapd@.service ${D}${systemd_unitdir}/system/
|
||||||
|
sed -i -e 's,@SBINDIR@,${sbindir},g' -e 's,@SYSCONFDIR@,${sysconfdir},g' ${D}${systemd_unitdir}/system/hostapd@.service
|
||||||
}
|
}
|
||||||
|
|
||||||
do_install_append_ccimx6ul() {
|
do_install_append_ccimx6ul() {
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,5 @@
|
||||||
auto wlan1
|
auto wlan1
|
||||||
iface wlan1 inet dhcp
|
iface wlan1 inet dhcp
|
||||||
udhcpc_opts -S -b >/dev/null &
|
udhcpc_opts -S -b >/dev/null &
|
||||||
post-up /etc/init.d/hostapd start
|
post-up ##WLAN1_POST_UP_ACTION##
|
||||||
pre-down /etc/init.d/hostapd stop
|
pre-down ##WLAN1_PRE_DOWN_ACTION##
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@ iface wlan1 inet static
|
||||||
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##
|
||||||
post-up /etc/init.d/hostapd start
|
post-up ##WLAN1_POST_UP_ACTION##
|
||||||
pre-down /etc/init.d/hostapd stop
|
pre-down ##WLAN1_PRE_DOWN_ACTION##
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (C) 2013-2018 Digi International Inc.
|
# Copyright (C) 2013-2019 Digi International Inc.
|
||||||
|
|
||||||
FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:"
|
FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:"
|
||||||
|
|
||||||
|
|
@ -64,6 +64,9 @@ install_virtwlans() {
|
||||||
install -m 0755 ${WORKDIR}/virtwlans.sh ${D}${base_bindir}
|
install -m 0755 ${WORKDIR}/virtwlans.sh ${D}${base_bindir}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WLAN1_POST_UP_ACTION = "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemctl start hostapd@wlan1.service', '/etc/init.d/hostapd start', 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() {
|
||||||
if [ -n "${HAVE_WIFI}" ]; then
|
if [ -n "${HAVE_WIFI}" ]; then
|
||||||
cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces
|
cat ${WORKDIR}/interfaces.wlan1.${WLAN1_MODE} >> ${D}${sysconfdir}/network/interfaces
|
||||||
|
|
@ -80,6 +83,8 @@ install_wlan1() {
|
||||||
sed -i -e "s,##WLAN1_STATIC_NETMASK##,${WLAN1_STATIC_NETMASK},g" ${D}${sysconfdir}/network/interfaces
|
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" ${D}${sysconfdir}/network/interfaces
|
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" ${D}${sysconfdir}/network/interfaces
|
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" ${D}${sysconfdir}/network/interfaces
|
||||||
|
sed -i -e "s,##WLAN1_PRE_DOWN_ACTION##,${WLAN1_PRE_DOWN_ACTION},g" ${D}${sysconfdir}/network/interfaces
|
||||||
}
|
}
|
||||||
|
|
||||||
do_install_append_ccimx6qpsbc() {
|
do_install_append_ccimx6qpsbc() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue