#!/bin/bash
# Check if root
if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi
service=$(connmanctl services | grep wifi | awk '{if ($1=="*AO" || $1=="*AR"){ print $3 }}')
if [[ ! $service ]]
then
      #No Wifi interface detected.
      echo "noService"
else
      ipv4=$(connmanctl services $service |grep 'IPv4\.Configuration')
      mode=$(echo "$ipv4" |grep 'dhcp\|auto')
      if [[ ! $mode ]]
      then
            echo "0"
      else
            echo "1"
      fi
fi