#! /bin/sh -
#
# wpa_supplicant/rc.main
#
# Wi-Fi Protected Access client and IEEE 802.1X supplicant.
#

# Redirects the standard error to the standard output
exec 2>&1

TARGET="$1"
SVNAME="${2:-wpa_supplicant}"

start()
{
    echo "*** ${SVNAME}: Starting wpa_supplicant ..."

    # Check if the dbus daemon is running
    if ! perpok -u3 dbus
    then
        echo "${SVNAME}: Dependency 'dbus' not running." 1>&2
        exit 1
    fi

    exec /usr/sbin/wpa_supplicant -u -c /etc/wpa_supplicant.conf
}

reset()
{
    case $3 in
    exit)
        echo "*** ${SVNAME}: Exited status $4"
        ;;
    signal)
        echo "*** ${SVNAME}: Killed on signal $5"
        ;;
    *)
        echo "*** ${SVNAME}: Stopped (${3})"
        ;;
    esac
}

# Branch to target
eval ${TARGET} "$@"

