diff --git a/config/menu/EX-bluetooth.menu b/config/menu/EX-bluetooth.menu
new file mode 100644
index 000000000..b7f1728a5
--- /dev/null
+++ b/config/menu/EX-bluetooth.menu
@@ -0,0 +1,5 @@
+ $subipfire->{'55.bluetooth'} = {'caption' => bluetooth,
+ 'uri' => '/cgi-bin/bluetooth.cgi',
+ 'title' => bluetooth,
+ 'enabled' => 1,
+ };
diff --git a/config/rootfiles/packages/bluez b/config/rootfiles/packages/bluez
index 188292b4b..470c1ccb6 100644
--- a/config/rootfiles/packages/bluez
+++ b/config/rootfiles/packages/bluez
@@ -1,3 +1,5 @@
+srv/web/ipfire/cgi-bin/bluetooth.cgi
+var/ipfire/menu.d/EX-bluetooth.menu
etc/rc.d/init.d/bluetooth
etc/rc.d/rc3.d/S16bluetooth
etc/rc.d/rc0.d/K84bluetooth
diff --git a/html/cgi-bin/bluetooth.cgi b/html/cgi-bin/bluetooth.cgi
new file mode 100644
index 000000000..32bd8e8e0
--- /dev/null
+++ b/html/cgi-bin/bluetooth.cgi
@@ -0,0 +1,187 @@
+#!/usr/bin/perl
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see . #
+# #
+###############################################################################
+#
+
+use strict;
+
+# enable only the following on debugging purpose
+use warnings;
+use CGI::Carp 'fatalsToBrowser';
+
+require '/var/ipfire/general-functions.pl';
+require '/var/ipfire/lang.pl';
+require '/var/ipfire/header.pl';
+
+my $debug = 0;
+my $i = 0;
+my $errormessage = '';
+my $status_started = "
$Lang::tr{'running'} | ";
+my $status_stopped = "$Lang::tr{'stopped'} | ";
+
+# get rid of used only once warnings
+my @onlyonce = ( $Header::colourgreen, $Header::colourred );
+undef @onlyonce;
+
+my %selected=();
+my %checked=();
+my %color = ();
+my %mainsettings = ();
+
+&General::readhash("${General::swroot}/main/settings", \%mainsettings);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+
+my %bluetoothsettings=();
+$bluetoothsettings{'PASSKEY_AGENT'} = 'on';
+$bluetoothsettings{'PWD'} = '12345';
+$bluetoothsettings{'RFCOMM0_BIND'} = 'off';
+$bluetoothsettings{'RFCOMM0_DEVICE'} = '';
+$bluetoothsettings{'RFCOMM0_CHANNEL'} = '1';
+$bluetoothsettings{'RFCOMM1_BIND'} = 'off';
+$bluetoothsettings{'RFCOMM1_DEVICE'} = '';
+$bluetoothsettings{'RFCOMM1_CHANNEL'} = '1';
+
+&General::readhash("/var/ipfire/bluetooth/settings", \%bluetoothsettings);
+
+my %cgiparams=();
+$cgiparams{'ACTION'} = '';
+$cgiparams{'RUNNING'} = 'off';
+$cgiparams{'PASSKEY_AGENT'} = 'off';
+$cgiparams{'PWD'} = '';
+$cgiparams{'RFCOMM0_BIND'} = 'off';
+$cgiparams{'RFCOMM0_DEVICE'} = '';
+$cgiparams{'RFCOMM0_CHANNEL'} = '';
+$cgiparams{'RFCOMM1_BIND'} = 'off';
+$cgiparams{'RFCOMM1_DEVICE'} = '';
+$cgiparams{'RFCOMM1_CHANNEL'} = '';
+
+
+&Header::getcgihash(\%cgiparams);
+
+&Header::showhttpheaders();
+
+if ( $cgiparams{'ACTION'} eq "$Lang::tr{'save'}" ){
+ $bluetoothsettings{'PASSKEY_AGENT'} = $cgiparams{'PASSKEY_AGENT'};
+ $bluetoothsettings{'PWD'} = $cgiparams{'PWD'};
+ if ( (length($bluetoothsettings{'PWD'}) < 4) || (length($bluetoothsettings{'PWD'}) > 8) ){
+ $errormessage .= "Invalid length in Passphrase. Must be between 4 and 8 characters.
";
+ }
+ $bluetoothsettings{'RFCOMM0_BIND'} = $cgiparams{'RFCOMM0_BIND'};
+ $bluetoothsettings{'RFCOMM1_BIND'} = $cgiparams{'RFCOMM1_BIND'};
+ $bluetoothsettings{'RFCOMM0_DEVICE'} = $cgiparams{'RFCOMM0_DEVICE'};
+ $bluetoothsettings{'RFCOMM1_DEVICE'} = $cgiparams{'RFCOMM1_DEVICE'};
+ $bluetoothsettings{'RFCOMM0_CHANNEL'} = $cgiparams{'RFCOMM0_CHANNEL'};
+ $bluetoothsettings{'RFCOMM1_CHANNEL'} = $cgiparams{'RFCOMM1_CHANNEL'};
+
+# TODO: CHECK RFCOMM DEVICES
+
+ if ( $errormessage eq '' ){
+ &WriteConfig();
+ system("/usr/local/bin/addonctrl bluetooth restart >/dev/null 2>&1")
+ }
+}
+
+&Header::openpage('Bluetooth', 1, '', '');
+&Header::openbigbox('100%', 'left', '', $errormessage);
+print "";
+&Header::closebigbox();
+&Header::closepage();
+
+
+sub WriteConfig{
+ &General::writehash("/var/ipfire/bluetooth/settings", \%bluetoothsettings);
+}
+
diff --git a/html/cgi-bin/wlanap.cgi b/html/cgi-bin/wlanap.cgi
old mode 100755
new mode 100644
diff --git a/src/initscripts/init.d/bluetooth b/src/initscripts/init.d/bluetooth
index 6ccd659ad..e3ee1b130 100644
--- a/src/initscripts/init.d/bluetooth
+++ b/src/initscripts/init.d/bluetooth
@@ -7,29 +7,45 @@
. /etc/sysconfig/rc
. $rc_functions
+eval $(/usr/local/bin/readhash /var/ipfire/bluetooth/settings)
+
case "$1" in
start)
boot_mesg "Starting Bluetooth daemon..."
loadproc /usr/sbin/hcid
sleep 1
-
- # The passkey-agent is only needed for pairing
- #boot_mesg "Starting Bluetooth passkey-agent..."
- #loadproc /usr/bin/passkey-agent --default 12345 &
- # Bind rfcomm to a blootooth cellphone/modem
- #boot_mesg "Bind rfcomm0 to cellphone/modem..."
- #rfcomm bind /dev/rfcomm0 00:11:22:33:44:55 1
- #evaluate_retval
+ if [ "$PASSKEY_AGENT" == "on" ]; then
+ boot_mesg "Starting Bluetooth passkey-agent..."
+ loadproc /usr/bin/passkey-agent --default $PWD &
+ fi
+
+ if [ "$RFCOMM0_BIND" == "on" ]; then
+ boot_mesg "Bind rfcomm0 to cellphone/modem ${RFCOMM0_DEVICE//-/:}/$RFCOMM0_CHANNEL ..."
+ rfcomm bind /dev/rfcomm0 ${RFCOMM0_DEVICE//-/:} $RFCOMM0_CHANNEL
+ evaluate_retval
+ fi
+ if [ "$RFCOMM1_BIND" == "on" ]; then
+ boot_mesg "Bind rfcomm1 to cellphone/modem ${RFCOMM1_DEVICE//-/:}/${RFCOMM1_CHANNEL} ..."
+ rfcomm bind /dev/rfcomm1 ${RFCOMM1_DEVICE//-/:} $RFCOMM1_CHANNEL
+ evaluate_retval
+ fi
+ exit 0;
+
;;
stop)
- #boot_mesg "Release rfcomm0..."
- #rfcomm release rfcomm0
- #boot_mesg "Stopping Bluetooth passkey-agent..."
- #killproc /usr/bin/passkey-agent
+ if [ -e /dev/rfcomm0 ]; then
+ boot_mesg "Release rfcomm0..."
+ rfcomm release rfcomm0
+ fi
+ if [ -e /dev/rfcomm1 ]; then
+ boot_mesg "Release rfcomm1..."
+ rfcomm release rfcomm1
+ fi
boot_mesg "Stopping Bluetooth daemon..."
killproc /usr/sbin/hcid
+ exit 0;
;;
restart)
@@ -41,8 +57,7 @@ case "$1" in
status)
statusproc /usr/sbin/hcid
statusproc /usr/bin/passkey-agent
-
- ;;
+ ;;
*)
echo "Usage: $0 {start|stop|restart|status}"