summaryrefslogtreecommitdiff
path: root/multitech/recipes/ocg-scripts/ocg-scripts-1.0/ocg-set-apn
blob: 5c3985f2ac2dcf4abb14800ac49aab2258f02673 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

if [[ $# != 1 ]]; then
	echo "Usage: $(basename $0) APN"
	exit 1
fi

apn=$1
chat_file=/etc/ppp/peers/gsm_chat

sed -r -i "s/^OK\s+'AT\+CGDCONT=1,\"IP\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=1,\"IP\",\"${apn}\"'/" $chat_file

if [[ $? != 0 ]]; then
	echo "Failed to change APN"
	exit 1
else
	echo "Set APN to \"${apn}\" in $chat_file"
fi

exit 0