#! /bin/sh

# exit value of 0 = OK to run GSM
# exit value of 1 = don't run

# if file does not exist
# touch file
# return 0
MODEM=/var/tmp/modem
DELAY=25

if [ ! -e $MODEM ]
	then
	touch $MODEM
	exit 0
fi

# if file exists
#  get current time
#  get file timestamp
#  if file older than 25s
#   touch file
#   return 0
#  else return 1

OURTIME=$(date +%s)
FILETIME=$(date +%s -r $MODEM)

TIMEDIFF=$(($OURTIME - $FILETIME))

if [ $TIMEDIFF -lt 0 ]
	then
	exit 1
elif [ $TIMEDIFF -lt  $DELAY ]
	then
	exit 1
else
	touch $MODEM
	exit 0
fi
