ppp revision 179315
1#!/bin/sh 2# 3# $FreeBSD: head/etc/rc.d/ppp 179315 2008-05-26 10:40:09Z bz $ 4# 5 6# PROVIDE: ppp 7# REQUIRE: netif 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 _ppp_unit 22 local _ppp_profile_cleaned _punct _punct_c 23 24 _ppp_profile=$1 25 _ppp_profile_cleaned=$1 26 _punct=". - / +" 27 for _punct_c in $_punct; do 28 _ppp_profile_cleaned=`ltr ${_ppp_profile_cleaned} ${_punct_c} '_'` 29 done 30 31 # Check for ppp profile mode override. 32 # 33 eval _ppp_mode=\$ppp_${_ppp_profile_cleaned}_mode 34 if [ -z "$_ppp_mode" ]; then 35 _ppp_mode=$ppp_mode 36 fi 37 38 # Check for ppp profile nat override. 39 # 40 eval _ppp_nat=\$ppp_${_ppp_profile_cleaned}_nat 41 if [ -z "$_ppp_nat" ]; then 42 _ppp_nat=$ppp_nat 43 fi 44 45 # Establish ppp mode. 46 # 47 if [ "${_ppp_mode}" != "ddial" -a "${_ppp_mode}" != "direct" \ 48 -a "${_ppp_mode}" != "dedicated" \ 49 -a "${_ppp_mode}" != "background" ]; then 50 _ppp_mode="auto" 51 fi 52 53 rc_flags="-quiet -${_ppp_mode}" 54 55 # Switch on NAT mode? 56 # 57 case ${_ppp_nat} in 58 [Yy][Ee][Ss]) 59 rc_flags="$rc_flags -nat" 60 ;; 61 esac 62 63 # Check for hard wired unit 64 eval _ppp_unit=\$ppp_${_ppp_profile_cleaned}_unit 65 if [ -n "${_ppp_unit}" ]; then 66 _ppp_unit="-unit${_ppp_unit}" 67 fi 68 rc_flags="$rc_flags $_ppp_unit" 69 70 # Run! 71 # 72 su -m $ppp_user -c "$command ${rc_flags} ${_ppp_profile}" 73} 74 75ppp_start() 76{ 77 local _ppp_profile _p 78 79 _ppp_profile=$* 80 if [ -z "${_ppp_profile}" ]; then 81 _ppp_profile=$ppp_profile 82 fi 83 84 echo -n "Starting PPP profile:" 85 86 for _p in $_ppp_profile; do 87 echo -n " $_p" 88 ppp_start_profile $_p 89 done 90 91 echo "." 92} 93 94ppp_poststart() 95{ 96 # Re-Sync ipfilter and pf so they pick up any new network interfaces 97 # 98 /etc/rc.d/ipfilter quietresync 99 /etc/rc.d/pf quietresync 100} 101 102ppp_stop_profile() { 103 local _ppp_profile 104 105 _ppp_profile=$1 106 107 /bin/pkill -f "^${command}.*[[:space:]]${_ppp_profile}\$" || \ 108 echo -n "(not running)" 109} 110 111ppp_stop() { 112 local _ppp_profile _p 113 114 _ppp_profile=$* 115 if [ -z "${_ppp_profile}" ]; then 116 _ppp_profile=$ppp_profile 117 fi 118 119 echo -n "Stopping PPP profile:" 120 121 for _p in $_ppp_profile; do 122 echo -n " $_p" 123 ppp_stop_profile $_p 124 done 125 126 echo "." 127} 128 129load_rc_config $name 130run_rc_command $* 131