#!/bin/bash
#
# Start/stop/restart iwd.

iwd_start() {
  if [ -x /usr/libexec/iwd ]; then
    echo "Starting iwd: /usr/libexec/iwd"
	/usr/libexec/iwd 2>/dev/null &
  fi
}

iwd_stop() {
  echo "Stopping iwd"
  killall iwd
}

iwd_restart() {
  iwd_stop
  sleep 1
  iwd_start
}

case "$1" in
'start')
  iwd_start
  ;;
'stop')
  iwd_stop
  ;;
'restart')
  iwd_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac
