# Contributed by Robbie Smith # Based on Thomas Bächler’s pppoe script # Also see for more information. : ${PPPD:=pppd} : ${InterfaceRoot=dev/} quote_word() { set -- "${@//\\/\\\\}" printf '"%s"\n' "${@//\"/\\\"}" } mobile_ppp_up() { local options chat options="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/options" chat="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/modem.chat" mkdir -p "$(dirname "$options")" cat >> "$options" << EOF linkname $(quote_word "$Profile") $(quote_word "$Interface") 921600 lock crtscts modem passive novj holdoff 10 noauth $(is_yes "${DefaultRoute:-yes}" || printf no)defaultroute maxfail $(quote_word "${MaxFail:-5}") $(is_yes "${UsePeerDNS:-yes}" && printf usepeerdns) hide-password ${User:+user $(quote_word "$User")} ${Password:+password $(quote_word "$Password")} connect $(quote_word "/usr/sbin/chat -v -t15 -f $(quote_word "$chat")") ${OptionsFile:+file $(quote_word "$OptionsFile")} EOF cat >> "$chat" << EOF ECHO ON ABORT 'BUSY' ABORT 'NO CARRIER' ABORT 'VOICE' ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT 'DELAYED' ABORT '\nRINGING\r\n\r\nRINGING\r' REPORT CONNECT TIMEOUT 6 '' 'ATQ0' 'OK-AT-OK' 'ATZ' TIMEOUT 3 'OK' 'AT+CFUN=1' 'OK' 'AT${Pin:++CPIN=$(quote_word "$Pin")}' 'OK\d-AT-OK' 'ATI' 'OK' 'ATZ' 'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' 'OK' 'AT$(case $Mode in 3Gonly) printf "\^SYSCFG=14,2,3fffffff,0,1";; 3Gpref) printf "\^SYSCFG=2,2,3fffffff,0,1";; GPRSonly) printf "\^SYSCFG=13,1,3fffffff,0,0";; GPRSpref) printf "\^SYSCFG=2,1,3fffffff,0,0";; esac)' 'OK-AT-OK' 'AT+CGDCONT=1,"IP",$(quote_word "$AccessPointName")' 'OK' 'ATDT${PhoneNumber:-*99#}' TIMEOUT 30 CONNECT '' EOF if ! $PPPD file "$options"; then rm "$options" "$chat" rmdir "$(dirname "$options")" report_error "Could not establish a ppp connection for profile '$Profile'." return 1 fi } mobile_ppp_down() { local options chat pidfile options="$STATE_DIR/mobile_ppp.$Interface.$Profile/options" chat="$STATE_DIR/mobile_ppp.$Interface.$Profile/modem.chat" pidfile="/var/run/ppp-$Profile.pid" [[ -r $pidfile ]] && kill "$(< "$pidfile")" rm "$options" "$chat" rmdir "$(dirname "$options")" } # vim: ft=sh ts=4 et sw=4: