source: freewrt/package/ppp/files/ppp.pre-up@ 63a0abc

freewrt_1_0 freewrt_2_0
Last change on this file since 63a0abc was 63a0abc, checked in by Markus Wigge <markus@…>, 19 years ago
  • added the usage of new comgt script to check SIM availability

git-svn-id: svn://www.freewrt.org/branches/freewrt_1_0@2123 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#!/bin/sh
2
3[ "$METHOD" == "ppp" ] || exit 0
4[ "$IF_USE_TEMPLATE" ] || exit 0
5
6[ -d /var/lock ] || mkdir /var/lock
7
8[ -f "/etc/ppp/templates/$IF_USE_TEMPLATE" ] || {
9 logger "$0: requested template '/etc/ppp/templates/$IF_USE_TEMPLATE' not found."
10 exit 1
11}
12
13IDLEOPTIONS="persist\nmaxfail 0"
14if [ "$IF_PPP_IDLETIME" -gt 0 ]; then
15 IDLEOTPIONS="idletime $IF_PPP_IDLETIME"
16fi
17
18REPLACE="
19 s,#IDLEOPTIONS#,$IDLEOPTIONS,
20 s,#USERNAME#,$IF_PPP_USERNAME,
21 s,#PASSWORD#,$IF_PPP_PASSWORD,
22 s,#DEVICE#,$IF_PPP_DEVICE,
23"
24
25sed "$REPLACE" < /etc/ppp/templates/$IF_USE_TEMPLATE > /etc/ppp/peers/$IF_PROVIDER
26
27case "$IF_USE_TEMPLATE" in
28umts)
29 # set UMTS-LED to green (bit 3)
30 LED=$(cat /proc/sys/diag)
31 echo $((LED | 8)) > /proc/sys/diag
32
33 # wait for card to initialize
34 COUNT=0
35 while [ $((COUNT++)) -lt 20 ]; do
36 [ -c "$IF_PPP_DEVICE" ] && break
37 [ $COUNT -eq 20 ] && {
38 logger "$0: '$IF_PPP_DEVICE' not found"
39 exit 1
40 }
41 sleep 1
42 done
43
44 # wait till the SIM is ready
45 comgt -s /etc/comgt/waitready.comgt -d $IF_PPP_DEVICE || exit 1
46
47 # set pincode
48 if [ "$IF_UMTS_PINCODE" ]; then
49 COMGTPIN="$IF_UMTS_PINCODE" comgt PIN -d $IF_PPP_DEVICE || ERROR=1
50 fi
51
52 # set APN
53 COMGTAPN="$IF_UMTS_APN" comgt APN -d $IF_PPP_DEVICE || ERROR=1
54
55 # set umts/gprs mode if available (Option cards only)
56 case "$IF_UMTS_MODE" in
57 gprs_only) comgt 2G -d $IF_PPP_DEVICE ;;
58 umts_only) comgt 3G -d $IF_PPP_DEVICE ;;
59 umts_first) comgt 3G2G -d $IF_PPP_DEVICE ;;
60 "") ;;
61 *) echo "unknown umts-mode, exiting"
62 ERROR=1
63 ;;
64 esac
65
66 if [ "$ERROR" == "1" ]; then
67 echo "$LED" > /proc/sys/diag
68 exit 1
69 fi
70 ;;
71esac
Note: See TracBrowser for help on using the repository browser.