GNU/Linux как интернет-шлюз для КПК через Bluetooth
(Леонид Пономарев)


rfcomm0 
{
	# Автоматически привязывать устройство при запуске
	bind yes;
	# MAC должен быть закомментирован
	#
	# device 11:22:33:44:55:66;
	#
	# RFCOMM-канал для соединения
	channel 2;
	# Метка
	comment "Bluetooth Access Point";
}



name "BlueZ Access Point at %h";



noauth
ms-dns 216.148.227.62
ms-dns 204.127.202.2



#!/sbin/runscript

depend() {
	use net
	use iptables
	after sshd
	after bluetooth
	after logger
}

start() {
	#modprobe rfcomm
	#modprobe hci_usb
	ebegin "Starting btlan"
	[ -a /dev/rfcomm0 ]|| mknod /dev/rfcomm0 c 216 0
	[ -a /dev/rfcomm1 ]|| mknod /dev/rfcomm1 c 216 1
	[ -a /dev/rfcomm2 ]|| mknod /dev/rfcomm2 c 216 2
	[ -a /dev/rfcomm3 ]|| mknod /dev/rfcomm3 c 216 3

	hciconfig hci0 up
	hcid
	sdptool add SP
	sdpd
	rfcomm bind all
	dund --listen --msdun --channel 2 10.20.4.89:10.0.0.111
	echo '1' > /proc/sys/net/ipv4/ip_forward

	eend 0
}

stop() {
	ebegin "Stopping btlan"
	killall dund
	rfcomm release all
	killall sdpd
	sdptool del SP
	killall hcid
	hciconfig hci0 down
	[ -a /dev/rfcomm0 ]&& rm -f /dev/rfcomm0
	[ -a /dev/rfcomm1 ]&& rm -f /dev/rfcomm1
	[ -a /dev/rfcomm2 ]&& rm -f /dev/rfcomm2
	[ -a /dev/rfcomm3 ]&& rm -f /dev/rfcomm3

	eend 0
}



KERNEL=="hci[0-9]*", RUN+="/lib/udev/bluetooth.sh"



#!/bin/sh
#
# bluetooth.sh: udev external RUN script
#
# Copyright 2005-2006 Henrik Brix Andersen <brix@gentoo.org>
# Distributed under the terms of the GNU General Public License v2

script=/etc/init.d/bluetooth
btlan=/etc/init.d/btlan #

# Find out where sysfs is mounted. Exit if not available
sysfs=`grep -F sysfs /proc/mounts | awk '{print $2}'`
if [ "$sysfs" = "" ]; then
    echo "sysfs is required"
    exit 1
fi

if [ ! -d $sysfs/class/bluetooth/hci[0-9]* ]; then
    if $script --quiet status; then
	$btlan stop #
	$script stop
    fi
else 
	if ! $script --quiet status; then
	$script start 
	$btlan start # 
	fi
fi

------------------------------------------------------------
