#!/bin/bash
# Run this script with bash shell and SUDO -SS
# nbiot helper script


#FILE_PPP=/boot/simcom2
rm .nbiotip.txt

if [ $# -eq 0 ]; then
	echo 'Disconnecting'
	poff simcom2
	exit 0
fi

echo "closing simcom ppp connection, in case it exists"
poff simcom2

#if [[ -f "$FILE_PPP" ]]; then
#    echo "$FILE_PPP exists. copying/replacing..."
#		cp $FILE_PP /etc/ppp/peers/simcom2
#fi

echo "starting simcom ppp connection"
pon simcom2

ifconfig ppp0 | grep "inet " | awk -F'[: ]+' '{ print $3 }' > .nbiotip.txt
