Removed 'ping' and check state of connection a bit differently using /sys and checking for default route.
Fixed a missing "exit"