aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/adbd/files/adb-init
blob: e88df23a9e867931ba0626c0b0a69df19ddd07bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

DAEMON=/usr/bin/adbd

VENDOR=0x18d1
PRODUCT=0x0000
SERIAL=$(hostname)-$(sed -e 's/://g' /sys/class/net/eth0/address)

case "$1" in
start)
    insmod $(busybox find /lib/modules/$(uname -r) -name "g_ffs.ko") idVendor=${VENDOR} idProduct=${PRODUCT} iSerialNumber=${SERIAL}
    mkdir -p /dev/usb-ffs
    chmod 770 /dev/usb-ffs
    mkdir -p /dev/usb-ffs/adb
    chmod 770 /dev/usb-ffs/adb
    mount -t functionfs adb /dev/usb-ffs/adb -o uid=0,gid=0
    start-stop-daemon --start --quiet --exec $DAEMON &
    ;;
stop)
    start-stop-daemon --stop --quiet --exec $DAEMON
    sleep 1
    umount /dev/usb-ffs/adb
    rmmod g_ffs
    ;;
restart)
    start-stop-daemon --stop --quiet --exec $DAEMON
    sleep 1
    start-stop-daemon --start --quiet --exec $DAEMON &
    ;;
*)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac
exit 0