1178023Semax#!/bin/sh 2178023Semax# 3178023Semax# $FreeBSD$ 4178023Semax# 5178023Semax 6178023Semax# PROVIDE: rfcomm_pppd_server 7178023Semax# REQUIRE: DAEMON sdpd 8178023Semax# BEFORE: LOGIN 9178023Semax# KEYWORD: nojail 10178023Semax 11178023Semax. /etc/rc.subr 12178023Semax 13178023Semaxname="rfcomm_pppd_server" 14230099Sdougbrcvar="rfcomm_pppd_server_enable" 15178023Semaxcommand="/usr/sbin/rfcomm_pppd" 16178023Semaxstart_cmd="rfcomm_pppd_server_start" 17178023Semaxstop_cmd="rfcomm_pppd_server_stop" 18178023Semaxrequired_modules="ng_btsocket" 19178023Semax 20178023Semaxrfcomm_pppd_server_start_profile() 21178023Semax{ 22178023Semax local _profile _profile_cleaned _punct _punct_c 23178023Semax local _bdaddr _channel _x 24178023Semax 25178023Semax _profile=$1 26178023Semax _profile_cleaned=$1 27178023Semax 28178023Semax _punct=". - / +" 29178023Semax for _punct_c in ${_punct} ; do 30178023Semax _profile_cleaned=`ltr ${_profile_cleaned} ${_punct_c} '_'` 31178023Semax done 32178023Semax 33178023Semax rc_flags="" 34178023Semax 35178023Semax # Check for RFCOMM PPP profile bdaddr override 36178023Semax # 37178023Semax eval _bdaddr=\$rfcomm_pppd_server_${_profile_cleaned}_bdaddr 38178023Semax if [ -n "${_bdaddr}" ]; then 39178023Semax rc_flags="${rc_flags} -a ${_bdaddr}" 40178023Semax fi 41178023Semax 42178023Semax # Check for RFCOMM PPP profile channel override 43178023Semax # 44178023Semax eval _channel=\$rfcomm_pppd_server_${_profile_cleaned}_channel 45178023Semax if [ -z "${_channel}" ]; then 46178023Semax _channel=1 47178023Semax fi 48178023Semax rc_flags="${rc_flags} -C ${_channel}" 49208060Sdougb 50178023Semax # Check for RFCOMM PPP profile register SP override 51178023Semax # 52178023Semax eval _x=\$rfcomm_pppd_server_${_profile_cleaned}_register_sp 53178023Semax if [ -n "${_x}" ]; then 54178023Semax if checkyesno "rfcomm_pppd_server_${_profile_cleaned}_register_sp" ; then 55178023Semax rc_flags="${rc_flags} -S" 56178023Semax fi 57178023Semax fi 58208060Sdougb 59178023Semax # Check for RFCOMM PPP profile register DUN override 60178023Semax # 61178023Semax eval _x=\$rfcomm_pppd_server_${_profile_cleaned}_register_dun 62178023Semax if [ -n "${_x}" ]; then 63178023Semax if checkyesno "rfcomm_pppd_server_${_profile_cleaned}_register_dun" ; then 64178023Semax rc_flags="${rc_flags} -D" 65178023Semax fi 66178023Semax fi 67178023Semax 68178023Semax # Run! 69178023Semax # 70178023Semax $command -s ${rc_flags} -l ${_profile} 71178023Semax} 72178023Semax 73178023Semaxrfcomm_pppd_server_stop_profile() 74178023Semax{ 75178023Semax local _profile 76178023Semax 77178023Semax _profile=$1 78178023Semax 79178023Semax /bin/pkill -f "^${command}.*[[:space:]]${_profile}\$" || \ 80178023Semax echo -n "(not running)" 81178023Semax} 82178023Semax 83178023Semaxrfcomm_pppd_server_start() 84178023Semax{ 85178023Semax local _profile _p 86178023Semax 87178023Semax _profile=$* 88178023Semax if [ -z "${_profile}" ]; then 89178023Semax _profile=${rfcomm_pppd_server_profile} 90178023Semax fi 91178023Semax 92178023Semax echo -n "Starting RFCOMM PPP profile:" 93178023Semax 94178023Semax for _p in ${_profile} ; do 95178023Semax echo -n " ${_p}" 96178023Semax rfcomm_pppd_server_start_profile ${_p} 97178023Semax done 98178023Semax 99178023Semax echo "." 100178023Semax} 101178023Semax 102178023Semaxrfcomm_pppd_server_stop() 103178023Semax{ 104178023Semax local _profile _p 105178023Semax 106178023Semax _profile=$* 107178023Semax if [ -z "${_profile}" ]; then 108178023Semax _profile=${rfcomm_pppd_server_profile} 109178023Semax fi 110178023Semax 111178023Semax echo -n "Stopping RFCOMM PPP profile:" 112178023Semax 113178023Semax for _p in ${_profile} ; do 114178023Semax echo -n " ${_p}" 115178023Semax rfcomm_pppd_server_stop_profile ${_p} 116178023Semax done 117178023Semax 118178023Semax echo "." 119178023Semax} 120178023Semax 121178023Semaxload_rc_config $name 122178023Semaxrun_rc_command $* 123