ppp revision 177959
198184Sgordon#!/bin/sh 298184Sgordon# 398184Sgordon# $FreeBSD: head/etc/rc.d/ppp 177959 2008-04-06 20:39:33Z brooks $ 498184Sgordon# 598184Sgordon 6151806Syar# PROVIDE: ppp 7113676Smtm# REQUIRE: netif isdnd 8136224Smtm# KEYWORD: nojail 998184Sgordon 1098184Sgordon. /etc/rc.subr 1198184Sgordon 1298184Sgordonname="ppp" 13138889Sbrianrcvar=`set_rcvar` 14151807Syarcommand="/usr/sbin/${name}" 15172586Semaxstart_cmd="ppp_start" 16172761Semaxstop_cmd="ppp_stop" 17168119Smtmstart_postcmd="ppp_poststart" 1898184Sgordon 19172586Semaxppp_start_profile() 2098184Sgordon{ 21177683Sbrooks local _ppp_profile _ppp_mode _ppp_nat _ppp_unit 22172586Semax 23172586Semax _ppp_profile=$1 24177649Sbrooks _ppp_profile_cleaned=$1 25177649Sbrooks _punct=". - / +" 26177649Sbrooks for _punct_c in $_punct; do 27177649Sbrooks _ppp_profile_cleaned=`ltr ${_ppp_profile_cleaned} ${_punct_c} '_'` 28177649Sbrooks done 29172586Semax 30172586Semax # Check for ppp profile mode override. 31172586Semax # 32177649Sbrooks eval _ppp_mode=\$ppp_${_ppp_profile_cleaned}_mode 33172586Semax if [ -z "$_ppp_mode" ]; then 34172586Semax _ppp_mode=$ppp_mode 35172586Semax fi 36172586Semax 37172586Semax # Check for ppp profile nat override. 38172586Semax # 39177649Sbrooks eval _ppp_nat=\$ppp_${_ppp_profile_cleaned}_nat 40172586Semax if [ -z "$_ppp_nat" ]; then 41172586Semax _ppp_nat=$ppp_nat 42172586Semax fi 43172586Semax 4498184Sgordon # Establish ppp mode. 4598184Sgordon # 46172586Semax if [ "${_ppp_mode}" != "ddial" -a "${_ppp_mode}" != "direct" \ 47172586Semax -a "${_ppp_mode}" != "dedicated" \ 48172586Semax -a "${_ppp_mode}" != "background" ]; then 49172586Semax _ppp_mode="auto" 5098184Sgordon fi 5198184Sgordon 52172586Semax rc_flags="-quiet -${_ppp_mode}" 5398184Sgordon 5498184Sgordon # Switch on NAT mode? 5598184Sgordon # 56172586Semax case ${_ppp_nat} in 5798184Sgordon [Yy][Ee][Ss]) 58138889Sbrian rc_flags="$rc_flags -nat" 5998184Sgordon ;; 6098184Sgordon esac 6198184Sgordon 62177683Sbrooks # Check for hard wired unit 63177683Sbrooks eval _ppp_unit=\$ppp_${_ppp_profile_cleaned}_unit 64177959Sbrooks if [ -n "${_ppp_unit}" ]; then 65177683Sbrooks _ppp_unit="-unit${_ppp_unit}" 66177683Sbrooks fi 67177683Sbrooks rc_flags="$rc_flags $_ppp_unit" 68177683Sbrooks 69172586Semax # Run! 70172586Semax # 71172586Semax su -m $ppp_user -c "$command ${rc_flags} ${_ppp_profile}" 72138889Sbrian} 7398184Sgordon 74172586Semaxppp_start() 75172586Semax{ 76172761Semax local _ppp_profile _p 77172586Semax 78172761Semax _ppp_profile=$* 79172761Semax if [ -z "${_ppp_profile}" ]; then 80172761Semax _ppp_profile=$ppp_profile 81172761Semax fi 82172761Semax 83172586Semax echo -n "Starting PPP profile:" 84172586Semax 85172761Semax for _p in $_ppp_profile; do 86172586Semax echo -n " $_p" 87172586Semax ppp_start_profile $_p 88172586Semax done 89172586Semax 90172586Semax echo "." 91172586Semax} 92172586Semax 93168119Smtmppp_poststart() 94138889Sbrian{ 95163696Savatar # Re-Sync ipfilter and pf so they pick up any new network interfaces 9698184Sgordon # 97175686Smtm /etc/rc.d/ipfilter quietresync 98175686Smtm /etc/rc.d/pf quietresync 9998184Sgordon} 10098184Sgordon 101172761Semaxppp_stop_profile() { 102172761Semax local _ppp_profile 103172761Semax 104172761Semax _ppp_profile=$1 105172761Semax 106172761Semax /bin/pkill -f "^${command}.*[[:space:]]${_ppp_profile}\$" || \ 107172761Semax echo -n "(not running)" 108172761Semax} 109172761Semax 110172761Semaxppp_stop() { 111172761Semax local _ppp_profile _p 112172761Semax 113172761Semax _ppp_profile=$* 114172761Semax if [ -z "${_ppp_profile}" ]; then 115172761Semax _ppp_profile=$ppp_profile 116172761Semax fi 117172761Semax 118172761Semax echo -n "Stopping PPP profile:" 119172761Semax 120172761Semax for _p in $_ppp_profile; do 121172761Semax echo -n " $_p" 122172761Semax ppp_stop_profile $_p 123172761Semax done 124172761Semax 125172761Semax echo "." 126172761Semax} 127172761Semax 12898184Sgordonload_rc_config $name 129172761Semaxrun_rc_command $* 130