summaryrefslogtreecommitdiffstats
path: root/meta-eca/recipes-connectivity/connman/files/connman-init-settings.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta-eca/recipes-connectivity/connman/files/connman-init-settings.sh')
-rwxr-xr-xmeta-eca/recipes-connectivity/connman/files/connman-init-settings.sh96
1 files changed, 96 insertions, 0 deletions
diff --git a/meta-eca/recipes-connectivity/connman/files/connman-init-settings.sh b/meta-eca/recipes-connectivity/connman/files/connman-init-settings.sh
new file mode 100755
index 0000000..9b4f040
--- /dev/null
+++ b/meta-eca/recipes-connectivity/connman/files/connman-init-settings.sh
@@ -0,0 +1,96 @@
1#!/bin/sh
2#
3# Connection Manager Init Service
4#
5# Copyright (C) 2012 Intel Corporation. All rights reserved.
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 2 as
9# published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
20
21CONNMAN_DIR=/var/lib/connman
22CONNMAN_SETTINGS=$CONNMAN_DIR/settings
23
24if [ -s $CONNMAN_SETTINGS ]; then
25 exit 0
26fi
27
28if [ ! -d $CONNMAN_DIR ]; then
29 mkdir -p $CONNMAN_DIR
30fi
31
32TETHERING="$1"
33TETHERING_AP_PASSPHRASE="$2"
34TETHERING_AP_SSID="$3"
35
36if [ -z "$TETHERING" ]; then
37 TETHERING="true"
38fi
39
40# Create main.conf with those values that we need
41MAINCONF=/etc/connman/main.conf
42cat > $MAINCONF <<EOF
43[General]
44TetheringTechnologies=wifi,bluetooth,gadget,ethernet
45PersistentTetheringMode=true
46EOF
47
48function get_mac
49{
50 # Get the mac address of the first network interface returned by kernel
51 IFACE=`head -n 3 /proc/net/dev|tail -n 1|awk '{ print $1 }'|sed 's/://'`
52 if [ -z "$IFACE" -o ! -d /sys/class/net/$IFACE ]; then
53 echo 010203040506
54 else
55 sed 's/://g' /sys/class/net/$IFACE/address
56 fi
57}
58
59if [ -z "$TETHERING_AP_SSID" ]; then
60 MAC=`get_mac`
61 TETHERING_AP_SSID=eca-$MAC
62fi
63
64if [ -z "$TETHERING_AP_PASSPHRASE" ]; then
65 if [ -z "$MAC" ]; then
66 MAC=`get_mac`
67 fi
68 TETHERING_AP_PASSPHRASE=$MAC
69fi
70
71cat > $CONNMAN_SETTINGS <<EOF
72[global]
73OfflineMode=false
74
75[Bluetooth]
76Enable=true
77
78[Cellular]
79Enable=true
80
81[WiFi]
82Enable=true
83Tethering=$TETHERING
84Tethering.Identifier=$TETHERING_AP_SSID
85Tethering.Passphrase=$TETHERING_AP_PASSPHRASE
86
87
88[Wired]
89Enable=true
90EOF
91
92if [ $? -eq 0 -a -f $CONNMAN_SETTINGS ]; then
93 chmod 0600 $CONNMAN_SETTINGS
94fi
95
96exit 0