#!/bin/sh
#
#  Perform NTP time synchronization
#  Wait before executing the process
#  Change the wait time depending on the network
#
#####

# wait time
WAIT_TIME_LAN=30
WAIT_TIME_LTE=180

COMM_SETTING="/usr/local/bin/comm_setting"
PYTHON="/usr/bin/python3"
NTP_SYNC="${PYTHON} /usr/local/nerntp/NtpSync.py"

wait_time=${WAIT_TIME_LAN}

if [ -f ${COMM_SETTING} ]; then
  ${COMM_SETTING}
  ret_comm=`echo $?`
  if [ "x${ret_comm}" != "x0" ]; then
     wait_time=${WAIT_TIME_LTE}
  fi
fi

sleep ${wait_time}
${NTP_SYNC} &

