#!/bin/bash

set -e

x=1
while true; do
    state=$(/usr/bin/nmcli -t -f STATE nm)
    if [ "$state" = "connected" ]; then
        echo $state
        exit 0
    fi

    x=$(($x + 1))
    if [ $x -gt 12 ]; then
        echo $state
        exit 1
    fi

    sleep 5
done
