diff options
author | John Klug <john.klug@multitech.com> | 2020-08-18 10:13:26 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2020-08-18 10:13:26 -0500 |
commit | e0b6b7444498fdef7151a4b363cf6eb89e1ec504 (patch) | |
tree | 79946c2609960e10a0b145beda3b8f62ec00134e /recipes-connectivity/hostapd | |
parent | 5101a0f32017c23707ea0b3aa2f650803b11a644 (diff) | |
download | meta-mlinux-e0b6b7444498fdef7151a4b363cf6eb89e1ec504.tar.gz meta-mlinux-e0b6b7444498fdef7151a4b363cf6eb89e1ec504.tar.bz2 meta-mlinux-e0b6b7444498fdef7151a4b363cf6eb89e1ec504.zip |
Add hostapd-extra package for setting channel and SSID
Diffstat (limited to 'recipes-connectivity/hostapd')
-rw-r--r-- | recipes-connectivity/hostapd/files/WiFi-SSID | 27 | ||||
-rwxr-xr-x | recipes-connectivity/hostapd/files/setchan | 24 | ||||
-rw-r--r-- | recipes-connectivity/hostapd/hostapd_%.bbappend | 34 |
3 files changed, 85 insertions, 0 deletions
diff --git a/recipes-connectivity/hostapd/files/WiFi-SSID b/recipes-connectivity/hostapd/files/WiFi-SSID new file mode 100644 index 0000000..e5d22ee --- /dev/null +++ b/recipes-connectivity/hostapd/files/WiFi-SSID @@ -0,0 +1,27 @@ +diff -Naru orig/etc/init.d/hostapd new/etc/init.d/hostapd +--- orig/etc/init.d/hostapd 2020-08-18 10:03:13.687093151 -0500 ++++ new/etc/init.d/hostapd 2020-08-18 10:05:30.095090777 -0500 +@@ -2,7 +2,12 @@ + DAEMON=/usr/sbin/hostapd + NAME=hostapd + DESC="HOSTAP Daemon" +-ARGS="/etc/hostapd.conf -B" ++CONFIG=/var/config/hostapd.conf ++ARGS="${CONFIG} -B" ++ ++DEVID=$(mts-io-sysfs show device-id) ++HOSTNAME=$(uname -n) ++SSID="${HOSTNAME}-${DEVID}" + + test -f $DAEMON || exit 0 + +@@ -35,6 +40,9 @@ + if [[ -n $PREUP ]] ; then + bash -c "$PREUP" + fi ++ if ! grep -q "^ssid=${SSID}$" ${CONFIG} ; then ++ sed -i "s/^ssid=.*/ssid=${SSID}/" ${CONFIG} ++ fi + echo -n "Starting $DESC: " + start-stop-daemon -S -x $DAEMON -- $ARGS + if [[ -n $POSTUP ]] ; then diff --git a/recipes-connectivity/hostapd/files/setchan b/recipes-connectivity/hostapd/files/setchan new file mode 100755 index 0000000..ceae0cf --- /dev/null +++ b/recipes-connectivity/hostapd/files/setchan @@ -0,0 +1,24 @@ +#!/bin/bash +echo 'Old Channel' +egrep '^channel=|^hw_mode=' /var/config/hostapd.conf +CHAN=$1 +if ! [[ $CHAN =~ ^[0-9]+$ ]] ; then + echo channel must be an integer +fi +if ((CHAN < 15)) ; then + HW='g' +else + HW='a' +fi + +sed -i "s/^channel=.*/channel=${CHAN}/" /var/config/hostapd.conf +sed -i "s/^hw_mode=.*/hw_mode=${HW}/" /var/config/hostapd.conf + +/etc/init.d/bt-pan stop +/etc/init.d/bluetooth stop +/etc/init.d/hostapd stop +/etc/init.d/rs9113 stop +/etc/init.d/rs9113 start +/etc/init.d/bluetooth start +/etc/init.d/bt-pan start +/etc/init.d/hostapd start diff --git a/recipes-connectivity/hostapd/hostapd_%.bbappend b/recipes-connectivity/hostapd/hostapd_%.bbappend index d94e2ad..7851129 100644 --- a/recipes-connectivity/hostapd/hostapd_%.bbappend +++ b/recipes-connectivity/hostapd/hostapd_%.bbappend @@ -4,3 +4,37 @@ do_install_append() { install -d ${D}{sysconfdir}/modprobe.d install -m 644 -D ${WORKDIR}/cfg80211.conf ${D}${sysconfdir}/modprobe.d/cfg80211.conf } + + +# -p option is striplevel +SRC_URI += " file://cfg80211.conf \ + file://WiFi-SSID \ + file://setchan \ + " + +do_install() { + install -d ${D}${sbindir} ${D}${sysconfdir}/init.d + install -m 0644 ${S}/hostapd.conf ${D}${sysconfdir} + install -m 0755 ${S}/hostapd ${D}${sbindir} + install -m 0755 ${S}/hostapd_cli ${D}${sbindir} + install -m 755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/hostapd + + install -m 644 -D ${WORKDIR}/cfg80211.conf ${D}${sysconfdir}/modprobe.d/cfg80211.conf + install -d ${D}/usr/share/hostap-daemon + install -m 0444 ${WORKDIR}/WiFi-SSID ${D}/usr/share/hostap-daemon/WiFi-SSID.patch + install -d ${D}/usr/local/bin + install -m 0744 ${WORKDIR}/setchan ${D}/usr/local/bin +} + +PACKAGES =+ "${PN}-extra" +FILES_${PN}-extra = "/usr/local/bin/* /usr/share/hostap-daemon/WiFi-SSID.patch" + +pkg_postinst_${PN}-bt-name() { + cd /$D + patch -Np1 < $D/usr/share/hostap-daemon/WiFi-SSID.patch +} + +pkg_prerm_${PN}-bt-name() { + cd /$D + patch -Rp1 < $D/usr/share/hostap-daemon/WiFi-SSID.patch +}
\ No newline at end of file |