2017-05-26 20:26:25 +00:00
|
|
|
#!/bin/sh
|
2017-06-09 10:28:57 +00:00
|
|
|
IP=172.16.42.1
|
2017-05-26 20:26:25 +00:00
|
|
|
TELNET_PORT=23
|
|
|
|
|
|
|
|
usb_setup_android() {
|
|
|
|
SYS=/sys/class/android_usb/android0
|
|
|
|
[ -e "$SYS" ] || return
|
|
|
|
printf "%s" "0" > "$SYS/enable"
|
|
|
|
printf "%s" "18D1" > "$SYS/idVendor"
|
|
|
|
printf "%s" "D001" > "$SYS/idProduct"
|
|
|
|
printf "%s" "rndis" > "$SYS/functions"
|
|
|
|
printf "%s" "1" > "$SYS/enable"
|
|
|
|
}
|
|
|
|
|
|
|
|
dhcpcd_start()
|
|
|
|
{
|
|
|
|
# get usb interface
|
|
|
|
INTERFACE=""
|
|
|
|
ifconfig rndis0 "$IP" && INTERFACE=rndis0
|
|
|
|
if [ -z $INTERFACE ]; then
|
|
|
|
ifconfig usb0 "$IP" && INTERFACE=usb0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# create /etc/udhcpd.conf
|
|
|
|
{
|
2017-06-09 10:28:57 +00:00
|
|
|
echo "start 172.16.42.2"
|
|
|
|
echo "end 172.16.42.254"
|
2017-05-26 20:26:25 +00:00
|
|
|
echo "lease_file /var/udhcpd.leases"
|
|
|
|
echo "interface $INTERFACE"
|
|
|
|
echo "option subnet 255.255.255.0"
|
|
|
|
} > /etc/udhcpd.conf
|
|
|
|
udhcpd
|
|
|
|
}
|
|
|
|
|
|
|
|
telnetd_start()
|
|
|
|
{
|
|
|
|
mkdir -p /dev/pts
|
|
|
|
mount -t devpts devpts /dev/pts
|
|
|
|
{
|
|
|
|
echo '#!/bin/sh'
|
|
|
|
echo '. /init_functions.sh'
|
|
|
|
echo 'unlock_root_partition'
|
|
|
|
echo 'killall cryptsetup telnetd'
|
|
|
|
} > /telnet_connect.sh
|
|
|
|
chmod +x /telnet_connect.sh
|
|
|
|
telnetd -b "${IP}:${TELNET_PORT}" -l /telnet_connect.sh
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_setup_android
|
|
|
|
dhcpcd_start
|
|
|
|
telnetd_start
|