1
0

ppp.pre-up 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/bin/sh
  2. [ "$METHOD" == "ppp" ] || exit 0
  3. [ "$IF_USE_TEMPLATE" ] || exit 0
  4. [ -d /var/lock ] || mkdir /var/lock
  5. [ -f "/etc/ppp/templates/$IF_USE_TEMPLATE" ] || {
  6. logger "$0: requested template '/etc/ppp/templates/$IF_USE_TEMPLATE' not found."
  7. exit 1
  8. }
  9. IDLEOPTIONS="persist\nmaxfail 0"
  10. [ "$IF_PPP_IDLETIME" ] && {
  11. if [ "$IF_PPP_IDLETIME" -gt 0 ]; then
  12. IDLEOTPIONS="idletime $IF_PPP_IDLETIME"
  13. fi
  14. }
  15. [ "$IF_PPP_MTU" ] || IF_PPP_MTU=1412
  16. if [ "$IF_PPP_MTU" -gt 0 ] ; then
  17. NETWORKOPTIONS="mtu $IF_PPP_MTU\nmru $IF_PPP_MTU"
  18. fi
  19. [ "$IF_PPP_VPI" ] || IF_PPP_VPI=1
  20. [ "$IF_PPP_VCI" ] || IF_PPP_VCI=32
  21. REPLACE="
  22. s,#IDLEOPTIONS#,$IDLEOPTIONS,
  23. s,#ENCAPS#,$IF_PPP_ENCAPS,
  24. s,#VPI#,$IF_PPP_VPI,
  25. s,#VCI#,$IF_PPP_VCI,
  26. s,#USERNAME#,$IF_PPP_USERNAME,
  27. s,#PASSWORD#,$IF_PPP_PASSWORD,
  28. s,#DEVICE#,$IF_PPP_DEVICE,
  29. s,#MODEMIP#,$IF_PPP_MODEMIP,
  30. s,#NETWORKOPTIONS#,$NETWORKOPTIONS,
  31. "
  32. sed "$REPLACE" < /etc/ppp/templates/$IF_USE_TEMPLATE > /etc/ppp/peers/$IF_PROVIDER
  33. case "$IF_PPP_DEVICE" in
  34. eth*)
  35. ip link set up dev $IF_PPP_DEVICE
  36. ;;
  37. nas*)
  38. [ "$IF_PPP_ENCAPS" ] || encap=0
  39. [ "$IF_PPP_PAYLOAD" ] || payload=1
  40. case "$IF_PPP_PAYLOAD" in
  41. bridged)
  42. payload=1
  43. ;;
  44. routed)
  45. payload=0
  46. ;;
  47. *)
  48. echo "Wrong payload, use either bridged or routed"
  49. exit 1
  50. ;;
  51. esac
  52. case "$IF_PPP_ENCAPS" in
  53. llc)
  54. encap=0
  55. ;;
  56. vc)
  57. encap=1
  58. ;;
  59. *)
  60. echo "Wrong Encapsulation use either llc or vc"
  61. exit 1
  62. ;;
  63. esac
  64. count=$(echo $IF_PPP_DEVICE|sed -e "s/nas//")
  65. br2684ctl -b -c $count -e $encap -p $payload -a $IF_PPP_VPI.$IF_PPP_VCI
  66. ip link set up dev $IF_PPP_DEVICE
  67. ;;
  68. esac
  69. case "$IF_USE_TEMPLATE" in
  70. umts)
  71. # wait for card to initialize
  72. COUNT=0
  73. while [ $((COUNT++)) -lt 20 ]; do
  74. [ -c "$IF_PPP_DEVICE" ] && break
  75. [ $COUNT -eq 20 ] && {
  76. logger "$0: '$IF_PPP_DEVICE' not found"
  77. exit 1
  78. }
  79. sleep 1
  80. done
  81. # wait till the SIM is ready
  82. comgt -s /etc/comgt/waitready.comgt -d $IF_PPP_DEVICE || exit 1
  83. # set pincode
  84. if [ "$IF_PIN" ]; then
  85. COMGTPIN="$IF_PIN" comgt PIN -d $IF_PPP_DEVICE || exit 1
  86. fi
  87. # set APN
  88. COMGTAPN="$IF_APN" comgt APN -d $IF_PPP_DEVICE || exit 1
  89. # set umts/gprs mode if available (Option cards only)
  90. case "$IF_MODE" in
  91. gprs_only) comgt 2G -d $IF_PPP_DEVICE ;;
  92. umts_only) comgt 3G -d $IF_PPP_DEVICE ;;
  93. umts_first) comgt 3G2G -d $IF_PPP_DEVICE ;;
  94. "") ;;
  95. *) echo "unknown mode, exiting"
  96. exit 1
  97. ;;
  98. esac
  99. ;;
  100. esac