scripts: Print out brief information about network connection 39/204239/2 accepted/tizen/unified/20190425.111810 submit/tizen/20190425.041112
authorDongwoo Lee <dwoo08.lee@samsung.com>
Mon, 22 Apr 2019 07:53:12 +0000 (16:53 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 23 Apr 2019 02:08:00 +0000 (11:08 +0900)
This patch refactors init script in order to provide brief
information of the target network as below:

  Network Information:
  Wired: xxx.xxx.xxx.xxx
  Wireless: xxx.xxx.xxx.xxx [SSID: xxxxxxxxx]

Change-Id: I5df962443cc846e60a5952dbb3e8dadb37273dd3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
scripts/flash-init.sh

index aba4d7e42fc38319ff4a6d3891d1f23dbaea38c8..e5d12f89f33e44134dd1cd91431cc187a485f7d0 100755 (executable)
@@ -34,7 +34,7 @@ clear_bootmode() {
 #------------------------------------------------
 # Copy Module and Firmware file
 #------------------------------------------------
-copy_module() {
+setup_wireless() {
        MODULES_PART=`"$BLKID" --label modules`
        if [ "$MODULES_PART" != "" ]; then
                echo "Module partition is $MODULES_PART"
@@ -53,20 +53,22 @@ copy_module() {
                $INSMOD /lib/firmware/brcm/brcmfmac.ko
                sleep 1
 
-               echo "wlan0 ipaddr is 192.168.43.1"
-               $IFCONFIG $WLANIF 192.168.43.1 up
+               WLANIP="192.168.43.1"
+               $IFCONFIG $WLANIF ${WLANIP} up
 
                $DNSMASQ -p 0 -9 -C /lib/firmware/brcm/dnsmasq.conf
-               $HOSTAPD -B /lib/firmware/brcm/hostapd.conf
+               SSID=`$HOSTAPD -B /lib/firmware/brcm/hostapd.conf | "$GREP" -oP '(?<=ssid\s\")(.*?)(?=\")'`
        else
                echo "There is no module partition"
+               WLANIP="N/A"
+               SSID="N/A"
        fi
 }
 
 #------------------------------------------------
-#      print_ip
+#      setup_writed_nic()
 #------------------------------------------------
-print_ip() {
+setup_wired_nic() {
        IPADDR=`"$IP" -4 addr show $NETIF | "$GREP" -oP '(?<=inet\s)\d+(\.\d+){3}'`
        if [ "z$IPADDR" == "z" ]; then
                IPADDR="192.168.0.100"
@@ -92,6 +94,18 @@ print_ip() {
        fi
 }
 
+#------------------------------------------------
+#      print_info()
+#------------------------------------------------
+print_info() {
+       echo ""
+       echo "Tizen flash manager is ready."
+       echo ""
+       echo "Network Information:"
+       echo "Wired: ${IPADDR}"
+       echo "Wireless: ${WLANIP} [SSID: ${SSID}]"
+}
+
 #------------------------------------------------
 #      do_flash
 #------------------------------------------------
@@ -108,7 +122,8 @@ do_flash() {
 #------------------------------------------------
 #      Main Routine Start
 #------------------------------------------------
-print_ip
+setup_wired_nic
+setup_wireless
 clear_bootmode
-copy_module
+print_info
 do_flash