#!/bin/bash
#
# Test cellmodem function.

# Verify cellmodem service is up.
# Ping outside IP via cellmodem.
# Ping outside domain via cellmodem.
# Run cellmodemtest to get device info

if ! systemctl status signalytic-ppp &> /dev/null ; then
  echo "FAIL (signalytic-ppp service not up)"
  exit 1
fi

if ! ping -q -c 1 -w 10 -I wwan0 8.8.8.8 > /dev/null ; then
  echo "FAIL (unable to ping 8.8.8.8 on wwan0)"
  exit 1
fi

if ! ping -q -c 1 -w 10 -I wwan0 signalytic.ca > /dev/null ; then
  echo "FAIL (unable to ping signalytic.ca on wwan0)"
  exit 1
fi

cellmodemtest device
if [ $? -ne 0 ]; then
  echo "FAIL (failed to get device info with cellmodemtest)"
  exit 1
fi


echo "PASS"
exit 0