summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/connman/connman/connman
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity/connman/connman/connman')
-rw-r--r--meta/recipes-connectivity/connman/connman/connman83
1 files changed, 83 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/connman/connman/connman b/meta/recipes-connectivity/connman/connman/connman
new file mode 100644
index 0000000..bf7a94a
--- /dev/null
+++ b/meta/recipes-connectivity/connman/connman/connman
@@ -0,0 +1,83 @@
1#!/bin/sh
2
3DAEMON=/usr/sbin/connmand
4PIDFILE=/var/run/connmand.pid
5DESC="Connection Manager"
6
7if [ -f /etc/default/connman ] ; then
8 . /etc/default/connman
9fi
10
11set -e
12
13nfsroot=0
14
15exec 9<&0 < /proc/mounts
16while read dev mtpt fstype rest; do
17 if test $mtpt = "/" ; then
18 case $fstype in
19 nfs | nfs4)
20 nfsroot=1
21 break
22 ;;
23 *)
24 ;;
25 esac
26 fi
27done
28
29do_start() {
30 EXTRA_PARAM=""
31 if test $nfsroot -eq 1 ; then
32 NET_DEVS=`cat /proc/net/dev | sed -ne 's/^\([a-zA-Z0-9 ]*\):.*$/\1/p'`
33 NET_ADDR=`cat /proc/cmdline | sed -ne 's/^.*ip=\([^ :]*\).*$/\1/p'`
34
35 if [ ! -z "$NET_ADDR" ]; then
36 if [ "$NET_ADDR" = dhcp ]; then
37 ethn=`ifconfig | grep "^eth" | sed -e "s/\(eth[0-9]\)\(.*\)/\1/"`
38 if [ ! -z "$ethn" ]; then
39 EXTRA_PARAM="-I $ethn"
40 fi
41 else
42 for i in $NET_DEVS; do
43 ADDR=`ifconfig $i | sed 's/addr://g' | sed -ne 's/^.*inet \([0-9.]*\) .*$/\1/p'`
44 if [ "$NET_ADDR" = "$ADDR" ]; then
45 EXTRA_PARAM="-I $i"
46 break
47 fi
48 done
49 fi
50 fi
51 fi
52 if [ -f @LIBDIR@/connman/wired-setup ] ; then
53 . @LIBDIR@/connman/wired-setup
54 fi
55 $DAEMON $EXTRA_PARAM
56}
57
58do_stop() {
59 start-stop-daemon --stop --name connmand --quiet
60}
61
62case "$1" in
63 start)
64 echo "Starting $DESC"
65 do_start
66 ;;
67 stop)
68 echo "Stopping $DESC"
69 do_stop
70 ;;
71 restart|force-reload)
72 echo "Restarting $DESC"
73 do_stop
74 sleep 1
75 do_start
76 ;;
77 *)
78 echo "Usage: $0 {start|stop|restart|force-reload}" >&2
79 exit 1
80 ;;
81esac
82
83exit 0