diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:29:32 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:29:32 +0200 |
commit | 6b4c82f4657bdb56e6b7a56651d6d4bb91a35b8f (patch) | |
tree | 814ad3da280833de03535ca04cf5068da1d31822 /meta-eca/recipes-connectivity/connman/files/connman-init-settings.sh | |
download | meta-eca-daisy-enea.tar.gz |
initial commit for Enea Linux 4.0daisy-enea
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'meta-eca/recipes-connectivity/connman/files/connman-init-settings.sh')
-rwxr-xr-x | meta-eca/recipes-connectivity/connman/files/connman-init-settings.sh | 96 |
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 | |||
21 | CONNMAN_DIR=/var/lib/connman | ||
22 | CONNMAN_SETTINGS=$CONNMAN_DIR/settings | ||
23 | |||
24 | if [ -s $CONNMAN_SETTINGS ]; then | ||
25 | exit 0 | ||
26 | fi | ||
27 | |||
28 | if [ ! -d $CONNMAN_DIR ]; then | ||
29 | mkdir -p $CONNMAN_DIR | ||
30 | fi | ||
31 | |||
32 | TETHERING="$1" | ||
33 | TETHERING_AP_PASSPHRASE="$2" | ||
34 | TETHERING_AP_SSID="$3" | ||
35 | |||
36 | if [ -z "$TETHERING" ]; then | ||
37 | TETHERING="true" | ||
38 | fi | ||
39 | |||
40 | # Create main.conf with those values that we need | ||
41 | MAINCONF=/etc/connman/main.conf | ||
42 | cat > $MAINCONF <<EOF | ||
43 | [General] | ||
44 | TetheringTechnologies=wifi,bluetooth,gadget,ethernet | ||
45 | PersistentTetheringMode=true | ||
46 | EOF | ||
47 | |||
48 | function 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 | |||
59 | if [ -z "$TETHERING_AP_SSID" ]; then | ||
60 | MAC=`get_mac` | ||
61 | TETHERING_AP_SSID=eca-$MAC | ||
62 | fi | ||
63 | |||
64 | if [ -z "$TETHERING_AP_PASSPHRASE" ]; then | ||
65 | if [ -z "$MAC" ]; then | ||
66 | MAC=`get_mac` | ||
67 | fi | ||
68 | TETHERING_AP_PASSPHRASE=$MAC | ||
69 | fi | ||
70 | |||
71 | cat > $CONNMAN_SETTINGS <<EOF | ||
72 | [global] | ||
73 | OfflineMode=false | ||
74 | |||
75 | [Bluetooth] | ||
76 | Enable=true | ||
77 | |||
78 | [Cellular] | ||
79 | Enable=true | ||
80 | |||
81 | [WiFi] | ||
82 | Enable=true | ||
83 | Tethering=$TETHERING | ||
84 | Tethering.Identifier=$TETHERING_AP_SSID | ||
85 | Tethering.Passphrase=$TETHERING_AP_PASSPHRASE | ||
86 | |||
87 | |||
88 | [Wired] | ||
89 | Enable=true | ||
90 | EOF | ||
91 | |||
92 | if [ $? -eq 0 -a -f $CONNMAN_SETTINGS ]; then | ||
93 | chmod 0600 $CONNMAN_SETTINGS | ||
94 | fi | ||
95 | |||
96 | exit 0 | ||