ppp revision 172761
198184Sgordon#!/bin/sh 298184Sgordon# 398184Sgordon# $FreeBSD: head/etc/rc.d/ppp 172761 2007-10-18 17:10:40Z emax $ 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{ 21172586Semax local _ppp_profile _ppp_mode _ppp_nat 22172586Semax 23172586Semax _ppp_profile=$1 24172586Semax 25172586Semax # Check for ppp profile mode override. 26172586Semax # 27172586Semax eval _ppp_mode=\$ppp_${_ppp_profile}_mode 28172586Semax if [ -z "$_ppp_mode" ]; then 29172586Semax _ppp_mode=$ppp_mode 30172586Semax fi 31172586Semax 32172586Semax # Check for ppp profile nat override. 33172586Semax # 34172586Semax eval _ppp_nat=\$ppp_${_ppp_profile}_nat 35172586Semax if [ -z "$_ppp_nat" ]; then 36172586Semax _ppp_nat=$ppp_nat 37172586Semax fi 38172586Semax 3998184Sgordon # Establish ppp mode. 4098184Sgordon # 41172586Semax if [ "${_ppp_mode}" != "ddial" -a "${_ppp_mode}" != "direct" \ 42172586Semax -a "${_ppp_mode}" != "dedicated" \ 43172586Semax -a "${_ppp_mode}" != "background" ]; then 44172586Semax _ppp_mode="auto" 4598184Sgordon fi 4698184Sgordon 47172586Semax rc_flags="-quiet -${_ppp_mode}" 4898184Sgordon 4998184Sgordon # Switch on NAT mode? 5098184Sgordon # 51172586Semax case ${_ppp_nat} in 5298184Sgordon [Yy][Ee][Ss]) 53138889Sbrian rc_flags="$rc_flags -nat" 5498184Sgordon ;; 5598184Sgordon esac 5698184Sgordon 57172586Semax # Run! 58172586Semax # 59172586Semax su -m $ppp_user -c "$command ${rc_flags} ${_ppp_profile}" 60138889Sbrian} 6198184Sgordon 62172586Semaxppp_start() 63172586Semax{ 64172761Semax local _ppp_profile _p 65172586Semax 66172761Semax _ppp_profile=$* 67172761Semax if [ -z "${_ppp_profile}" ]; then 68172761Semax _ppp_profile=$ppp_profile 69172761Semax fi 70172761Semax 71172586Semax echo -n "Starting PPP profile:" 72172586Semax 73172761Semax for _p in $_ppp_profile; do 74172586Semax echo -n " $_p" 75172586Semax ppp_start_profile $_p 76172586Semax done 77172586Semax 78172586Semax echo "." 79172586Semax} 80172586Semax 81168119Smtmppp_poststart() 82138889Sbrian{ 83163696Savatar # Re-Sync ipfilter and pf so they pick up any new network interfaces 8498184Sgordon # 8598184Sgordon /etc/rc.d/ipfilter resync 86163696Savatar /etc/rc.d/pf resync 8798184Sgordon} 8898184Sgordon 89172761Semaxppp_stop_profile() { 90172761Semax local _ppp_profile 91172761Semax 92172761Semax _ppp_profile=$1 93172761Semax 94172761Semax /bin/pkill -f "^${command}.*[[:space:]]${_ppp_profile}\$" || \ 95172761Semax echo -n "(not running)" 96172761Semax} 97172761Semax 98172761Semaxppp_stop() { 99172761Semax local _ppp_profile _p 100172761Semax 101172761Semax _ppp_profile=$* 102172761Semax if [ -z "${_ppp_profile}" ]; then 103172761Semax _ppp_profile=$ppp_profile 104172761Semax fi 105172761Semax 106172761Semax echo -n "Stopping PPP profile:" 107172761Semax 108172761Semax for _p in $_ppp_profile; do 109172761Semax echo -n " $_p" 110172761Semax ppp_stop_profile $_p 111172761Semax done 112172761Semax 113172761Semax echo "." 114172761Semax} 115172761Semax 11698184Sgordonload_rc_config $name 117172761Semaxrun_rc_command $* 118