From: Christian Zimmermann <zimmermach@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Christian Zimmermann <zimmermach@gmail.com>
Subject: [PATCH BlueZ 1/2] Added config conversion for Bluez4 as shell script during install
Date: Mon, 26 Nov 2018 17:49:06 +0100 [thread overview]
Message-ID: <20181126164907.15659-1-zimmermach@gmail.com> (raw)
---
Makefile.am | 8 +++
tools/bluez4_conversion/convert_config.sh | 89 ++++++++++++++++++++++++++++++
tools/bluez4_conversion/convert_devices.sh | 3 +
3 files changed, 100 insertions(+)
create mode 100755 tools/bluez4_conversion/convert_config.sh
create mode 100644 tools/bluez4_conversion/convert_devices.sh
diff --git a/Makefile.am b/Makefile.am
index 0b26ccc3e..6dc5711d9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -477,6 +477,8 @@ endif
EXTRA_DIST += $(manual_pages:.1=.txt)
+EXTRA_DIST += tools/bluez4_conversion/convert_config.sh tools/bluez4_conversion/convert_devices.sh
+
DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles --enable-library \
--enable-health \
--enable-midi \
@@ -535,3 +537,9 @@ clean-local:
-find $(top_builddir) -name "*.gcda" -delete
$(RM) -r lib/bluetooth
endif
+
+BLUEZ4_CONFIG_CONVERSION = $(srcdir)/tools/bluez4_conversion/convert_config.sh
+BLUEZ4_DEVICE_CONVERSION = $(srcdir)/tools/bluez4_conversion/convert_devices.sh
+install-exec-hook:
+ $(BLUEZ4_CONFIG_CONVERSION)
+ $(BLUEZ4_DEVICE_CONVERION)
\ No newline at end of file
diff --git a/tools/bluez4_conversion/convert_config.sh b/tools/bluez4_conversion/convert_config.sh
new file mode 100755
index 000000000..477e18fae
--- /dev/null
+++ b/tools/bluez4_conversion/convert_config.sh
@@ -0,0 +1,89 @@
+!/bin/sh
+
+CONFIG_DIR="/var/lib/bluetooth"
+
+convert_on_mode()
+{
+ config_file=$1
+ #Read on_mode from config file
+ on_mode=$( cat $config_file | grep -Po 'mode \K(.*)')
+ if [ ! -z "$on_mode" ]
+ then
+ if [ $on_mode == "discoverable" ]
+ then
+ #Write on mode to new INI file
+ echo -e "Discoverable=true" >> settings
+ else
+ #Write on mode to new INI file
+ echo -e "Discoverable=false" >> settings
+ fi
+ else
+ echo "On mode not found"
+ fi
+}
+
+convert_discoverable_timeout()
+{
+ config_file=$1
+ #Read discoverable timeout from config file
+ discoverable_timeout=$( cat $config_file | grep -Po 'discovto \K([0-9]+)')
+ if [ ! -z "$discoverable_timeout" ]
+ then
+ #Write discoverable timeout to new INI file
+ echo -e "DiscoverableTimeout=$discoverable_timeout" >> settings
+ else
+ echo "Discoverable Timeout not found"
+ fi
+}
+
+convert_pairable_timeout()
+{
+ config_file=$1
+ #Read pairable timeout from config file
+ pairable_timeout=$( cat $config_file | grep -Po 'pairto \K([0-9]+)')
+ if [ ! -z "$pairable_timeout" ]
+ then
+ #Write discoverable timeout to new INI file
+ echo -e "PairableTimeout=$pairable_timeout" >> settings
+ else
+ echo "Pairable Timeout not found"
+ fi
+}
+
+convert_local_name()
+{
+ config_file=$1
+ #Read local name from config file
+ local_name=$( cat $config_file | grep -Po 'name \K(.*)')
+ if [ ! -z "$local_name" ]
+ then
+ #Write local_name to new INI file
+ echo -e "Alias=$local_name" >> settings
+ else
+ echo "Local name not found"
+ fi
+}
+
+###
+# Main script body
+###
+for entry in `ls $CONFIG_DIR`; do
+ cd $CONFIG_DIR
+ cd $entry
+ if [ -f "config" ]
+ then
+ if [ ! -f "settings" ]
+ then
+ #Create new settings INI file
+ touch settings
+ echo -e "[General]" >> settings
+ convert_pairable_timeout config
+ convert_discoverable_timeout config
+ convert_on_mode config
+ convert_local_name config
+ rm config
+ else
+ echo "Settings already available"
+ fi
+ fi
+done
diff --git a/tools/bluez4_conversion/convert_devices.sh b/tools/bluez4_conversion/convert_devices.sh
new file mode 100644
index 000000000..a8a013b06
--- /dev/null
+++ b/tools/bluez4_conversion/convert_devices.sh
@@ -0,0 +1,3 @@
+# TODO
+# This file is intended for replacing the conversion of Bluez4 device datas when upgrading to Bluez5 INI format
+# This is currently checked at every bluetoothd startup in src/adapter.c
\ No newline at end of file
--
2.11.0
next reply other threads:[~2018-11-26 16:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-26 16:49 Christian Zimmermann [this message]
2018-11-26 16:49 ` [PATCH BlueZ 2/2] Removed obsolete conversion functions, since the conversion is now done once during install Christian Zimmermann
2018-11-27 11:50 ` [PATCH BlueZ 1/2] Added config conversion for Bluez4 as shell script " Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181126164907.15659-1-zimmermach@gmail.com \
--to=zimmermach@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).