ppp revision 175686
1#!/bin/sh 2# 3# $FreeBSD: head/etc/rc.d/ppp 175686 2008-01-26 14:02:19Z mtm $ 4# 5 6# PROVIDE: ppp 7# REQUIRE: netif isdnd 8# KEYWORD: nojail 9 10. /etc/rc.subr 11 12name="ppp" 13rcvar=`set_rcvar` 14command="/usr/sbin/${name}" 15start_cmd="ppp_start" 16stop_cmd="ppp_stop" 17start_postcmd="ppp_poststart" 18 19ppp_start_profile() 20{ 21 local _ppp_profile _ppp_mode _ppp_nat 22 23 _ppp_profile=$1 24 25 # Check for ppp profile mode override. 26 # 27 eval _ppp_mode=\$ppp_${_ppp_profile}_mode 28 if [ -z "$_ppp_mode" ]; then 29 _ppp_mode=$ppp_mode 30 fi 31 32 # Check for ppp profile nat override. 33 # 34 eval _ppp_nat=\$ppp_${_ppp_profile}_nat 35 if [ -z "$_ppp_nat" ]; then 36 _ppp_nat=$ppp_nat 37 fi 38 39 # Establish ppp mode. 40 # 41 if [ "${_ppp_mode}" != "ddial" -a "${_ppp_mode}" != "direct" \ 42 -a "${_ppp_mode}" != "dedicated" \ 43 -a "${_ppp_mode}" != "background" ]; then 44 _ppp_mode="auto" 45 fi 46 47 rc_flags="-quiet -${_ppp_mode}" 48 49 # Switch on NAT mode? 50 # 51 case ${_ppp_nat} in 52 [Yy][Ee][Ss]) 53 rc_flags="$rc_flags -nat" 54 ;; 55 esac 56 57 # Run! 58 # 59 su -m $ppp_user -c "$command ${rc_flags} ${_ppp_profile}" 60} 61 62ppp_start() 63{ 64 local _ppp_profile _p 65 66 _ppp_profile=$* 67 if [ -z "${_ppp_profile}" ]; then 68 _ppp_profile=$ppp_profile 69 fi 70 71 echo -n "Starting PPP profile:" 72 73 for _p in $_ppp_profile; do 74 echo -n " $_p" 75 ppp_start_profile $_p 76 done 77 78 echo "." 79} 80 81ppp_poststart() 82{ 83 # Re-Sync ipfilter and pf so they pick up any new network interfaces 84 # 85 /etc/rc.d/ipfilter quietresync 86 /etc/rc.d/pf quietresync 87} 88 89ppp_stop_profile() { 90 local _ppp_profile 91 92 _ppp_profile=$1 93 94 /bin/pkill -f "^${command}.*[[:space:]]${_ppp_profile}\$" || \ 95 echo -n "(not running)" 96} 97 98ppp_stop() { 99 local _ppp_profile _p 100 101 _ppp_profile=$* 102 if [ -z "${_ppp_profile}" ]; then 103 _ppp_profile=$ppp_profile 104 fi 105 106 echo -n "Stopping PPP profile:" 107 108 for _p in $_ppp_profile; do 109 echo -n " $_p" 110 ppp_stop_profile $_p 111 done 112 113 echo "." 114} 115 116load_rc_config $name 117run_rc_command $* 118