summaryrefslogtreecommitdiff
path: root/recipes-connectivity/hostapd/files/WiFi-SSID
blob: e5d22ee8f6be1ceba43b4b0776d61dd90398aa1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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