summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authoremax <emax@FreeBSD.org>2008-04-08 23:34:12 +0000
committeremax <emax@FreeBSD.org>2008-04-08 23:34:12 +0000
commit194303edd4457c066da393413f43817b5449603e (patch)
tree5d215b72db0b7ec1b67ab1189021490117168655 /etc
parentc20bcaca65b4e3e98391498b56ef7214622bf1f6 (diff)
downloadFreeBSD-src-194303edd4457c066da393413f43817b5449603e.zip
FreeBSD-src-194303edd4457c066da393413f43817b5449603e.tar.gz
Add rfcomm_pppd_server rc script to allow start rfcomm_pppd(8) in server
mode at boot time. Multiple profiles can be started at the same time. The whole idea is very similar to the ppp rc script. Document Bluetooth knobs in rc.conf(5) MFC after: 1 week
Diffstat (limited to 'etc')
-rwxr-xr-xetc/rc.d/Makefile2
-rw-r--r--etc/rc.d/rfcomm_pppd_server122
2 files changed, 123 insertions, 1 deletions
diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile
index aa094f6..bfb1bfc 100755
--- a/etc/rc.d/Makefile
+++ b/etc/rc.d/Makefile
@@ -29,7 +29,7 @@ FILES= DAEMON FILESYSTEMS LOGIN NETWORKING SERVERS \
pf pflog pfsync \
powerd power_profile ppp pppoed pwcheck \
quota \
- random rarpd resolv root \
+ random rarpd resolv rfcomm_pppd_server root \
route6d routed routing rpcbind rtadvd rwho \
savecore sdpd securelevel sendmail \
serial sppp statd swap1 \
diff --git a/etc/rc.d/rfcomm_pppd_server b/etc/rc.d/rfcomm_pppd_server
new file mode 100644
index 0000000..7b8067e
--- /dev/null
+++ b/etc/rc.d/rfcomm_pppd_server
@@ -0,0 +1,122 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: rfcomm_pppd_server
+# REQUIRE: DAEMON sdpd
+# BEFORE: LOGIN
+# KEYWORD: nojail
+
+. /etc/rc.subr
+
+name="rfcomm_pppd_server"
+rcvar=`set_rcvar`
+command="/usr/sbin/rfcomm_pppd"
+start_cmd="rfcomm_pppd_server_start"
+stop_cmd="rfcomm_pppd_server_stop"
+required_modules="ng_btsocket"
+
+rfcomm_pppd_server_start_profile()
+{
+ local _profile _profile_cleaned _punct _punct_c
+ local _bdaddr _channel _x
+
+ _profile=$1
+ _profile_cleaned=$1
+
+ _punct=". - / +"
+ for _punct_c in ${_punct} ; do
+ _profile_cleaned=`ltr ${_profile_cleaned} ${_punct_c} '_'`
+ done
+
+ rc_flags=""
+
+ # Check for RFCOMM PPP profile bdaddr override
+ #
+ eval _bdaddr=\$rfcomm_pppd_server_${_profile_cleaned}_bdaddr
+ if [ -n "${_bdaddr}" ]; then
+ rc_flags="${rc_flags} -a ${_bdaddr}"
+ fi
+
+ # Check for RFCOMM PPP profile channel override
+ #
+ eval _channel=\$rfcomm_pppd_server_${_profile_cleaned}_channel
+ if [ -z "${_channel}" ]; then
+ _channel=1
+ fi
+ rc_flags="${rc_flags} -C ${_channel}"
+
+ # Check for RFCOMM PPP profile register SP override
+ #
+ eval _x=\$rfcomm_pppd_server_${_profile_cleaned}_register_sp
+ if [ -n "${_x}" ]; then
+ if checkyesno "rfcomm_pppd_server_${_profile_cleaned}_register_sp" ; then
+ rc_flags="${rc_flags} -S"
+ fi
+ fi
+
+ # Check for RFCOMM PPP profile register DUN override
+ #
+ eval _x=\$rfcomm_pppd_server_${_profile_cleaned}_register_dun
+ if [ -n "${_x}" ]; then
+ if checkyesno "rfcomm_pppd_server_${_profile_cleaned}_register_dun" ; then
+ rc_flags="${rc_flags} -D"
+ fi
+ fi
+
+ # Run!
+ #
+ $command -s ${rc_flags} -l ${_profile}
+}
+
+rfcomm_pppd_server_stop_profile()
+{
+ local _profile
+
+ _profile=$1
+
+ /bin/pkill -f "^${command}.*[[:space:]]${_profile}\$" || \
+ echo -n "(not running)"
+}
+
+rfcomm_pppd_server_start()
+{
+ local _profile _p
+
+ _profile=$*
+ if [ -z "${_profile}" ]; then
+ _profile=${rfcomm_pppd_server_profile}
+ fi
+
+ echo -n "Starting RFCOMM PPP profile:"
+
+ for _p in ${_profile} ; do
+ echo -n " ${_p}"
+ rfcomm_pppd_server_start_profile ${_p}
+ done
+
+ echo "."
+}
+
+rfcomm_pppd_server_stop()
+{
+ local _profile _p
+
+ _profile=$*
+ if [ -z "${_profile}" ]; then
+ _profile=${rfcomm_pppd_server_profile}
+ fi
+
+ echo -n "Stopping RFCOMM PPP profile:"
+
+ for _p in ${_profile} ; do
+ echo -n " ${_p}"
+ rfcomm_pppd_server_stop_profile ${_p}
+ done
+
+ echo "."
+}
+
+load_rc_config $name
+run_rc_command $*
OpenPOWER on IntegriCloud