]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/rfcomm_pppd_server
Merge branch 'releng/11.3' into releng-CDN/11.3
[FreeBSD/FreeBSD.git] / etc / rc.d / rfcomm_pppd_server
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: rfcomm_pppd_server
7 # REQUIRE: DAEMON sdpd
8 # BEFORE: LOGIN
9 # KEYWORD: nojail
10
11 . /etc/rc.subr
12
13 name="rfcomm_pppd_server"
14 desc="RFCOMM PPP daemon"
15 rcvar="rfcomm_pppd_server_enable"
16 command="/usr/sbin/rfcomm_pppd"
17 start_cmd="rfcomm_pppd_server_start"
18 stop_cmd="rfcomm_pppd_server_stop"
19 required_modules="ng_btsocket"
20
21 rfcomm_pppd_server_start_profile()
22 {
23         local _profile _profile_cleaned _punct _punct_c
24         local _bdaddr _channel _x
25
26         _profile=$1
27         _profile_cleaned=$1
28
29         _punct=". - / +"
30         for _punct_c in ${_punct} ; do
31                 _profile_cleaned=`ltr ${_profile_cleaned} ${_punct_c} '_'`
32         done
33
34         rc_flags=""
35
36         # Check for RFCOMM PPP profile bdaddr override
37         #
38         eval _bdaddr=\$rfcomm_pppd_server_${_profile_cleaned}_bdaddr
39         if [ -n "${_bdaddr}" ]; then
40                 rc_flags="${rc_flags} -a ${_bdaddr}"
41         fi
42
43         # Check for RFCOMM PPP profile channel override
44         #
45         eval _channel=\$rfcomm_pppd_server_${_profile_cleaned}_channel
46         if [ -z "${_channel}" ]; then
47                 _channel=1
48         fi
49         rc_flags="${rc_flags} -C ${_channel}"
50
51         # Check for RFCOMM PPP profile register SP override
52         #
53         eval _x=\$rfcomm_pppd_server_${_profile_cleaned}_register_sp
54         if [ -n "${_x}" ]; then
55                 if checkyesno "rfcomm_pppd_server_${_profile_cleaned}_register_sp" ; then
56                         rc_flags="${rc_flags} -S"
57                 fi
58         fi
59
60         # Check for RFCOMM PPP profile register DUN override
61         #
62         eval _x=\$rfcomm_pppd_server_${_profile_cleaned}_register_dun
63         if [ -n "${_x}" ]; then
64                 if checkyesno "rfcomm_pppd_server_${_profile_cleaned}_register_dun" ; then
65                         rc_flags="${rc_flags} -D"
66                 fi
67         fi
68
69         # Run!
70         #
71         $command -s ${rc_flags} -l ${_profile}
72 }
73
74 rfcomm_pppd_server_stop_profile()
75 {
76         local _profile
77
78         _profile=$1
79
80         /bin/pkill -f "^${command}.*[[:space:]]${_profile}\$" || \
81                 echo -n "(not running)"
82 }
83
84 rfcomm_pppd_server_start()
85 {
86         local _profile _p
87
88         _profile=$*
89         if [ -z "${_profile}" ]; then
90                 _profile=${rfcomm_pppd_server_profile}
91         fi
92
93         echo -n "Starting RFCOMM PPP profile:"
94
95         for _p in ${_profile} ; do
96                 echo -n " ${_p}"
97                 rfcomm_pppd_server_start_profile ${_p}
98         done
99
100         echo "."
101 }
102
103 rfcomm_pppd_server_stop()
104 {
105         local _profile _p
106
107         _profile=$*
108         if [ -z "${_profile}" ]; then
109                 _profile=${rfcomm_pppd_server_profile}
110         fi
111
112         echo -n "Stopping RFCOMM PPP profile:"
113
114         for _p in ${_profile} ; do
115                 echo -n " ${_p}"
116                 rfcomm_pppd_server_stop_profile ${_p}
117         done
118
119         echo "."
120 }
121
122 load_rc_config $name
123 run_rc_command $*