#! /bin/sh

set_wifi_chip() {
    local WIFI_CHIP=$(fw_printconst wifichip)
    case "${WIFI_CHIP#*=}" in
        "4359")
            echo "Found WiFi chip... Symlinking wl_AP6398S to /usr/bin/wl."
            ln -sf /usr/bin/wl_AP6398S /usr/bin/wl
            ;;
        "aae8")
            echo "Found WiFi chip... Symlinking wl_AP72598V to /usr/bin/wl."
            ln -sf /usr/bin/wl_AP72598V /usr/bin/wl
            ;;
        *)
            echo "failed to identify WiFi Chip... Symlinking fallback wl_AP6398S to /usr/bin/wl."
            ln -sf /usr/bin/wl_AP6398S /usr/bin/wl
            return;
            ;;
    esac
}

case "$1" in
start)
    set_wifi_chip
    ;;

stop)
    echo "Nothing to do in select_wl_binary stop"
    ;;

restart)
	$0 stop
	$0 start
	;;

*)
	echo "Usage: /etc/init.d/select_wl_binary {start|stop|restart}"
	exit 1

esac