summarylogtreecommitdiffstats
path: root/gadget-start.sh
blob: 5a5025c399781ae962e7462c8379d732cb73c6c0 (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
#!/usr/bin/bash
source "$(dirname "$0")/functions.sh"
set -e
cd "${GADGET}"
case "${1}" in
	start)
		if [ "${UDC}" == "auto" ]
		then	if _UDC="$(get_cmdline androidboot.usbcontroller)"
			then	echo "set udc to ${_UDC}"
				echo "${_UDC}" > UDC
			else	for i in /sys/class/udc/*
				do	[ -h "${i}" ]||continue
					_UDC="$(basename "$i")"||continue
					echo "set udc to ${_UDC}"
					echo "${_UDC}" > UDC
					exit
				done
			fi
		fi
	;;
	stop)
		echo "disable gadget"
		echo > UDC
	;;
esac