Skip to content

Instantly share code, notes, and snippets.

@olesenm
Last active April 27, 2022 01:27
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save olesenm/06ee8cdee893c732462a to your computer and use it in GitHub Desktop.
Save olesenm/06ee8cdee893c732462a to your computer and use it in GitHub Desktop.
helium shell script with normal system locations for 'adb'
#!/bin/sh
# start helium server on android device - see http://www.clockworkmod.com/carbon for more details
# set -x
# try normal system locations before the local binary
unset adb
for i in /usr/bin /usr/local/bin "$(/usr/bin/dirname $0)"
do
i="$i/adb"
if [ -f "$i" -a -x "$i" ]
then
adb=$i
break
fi
done
if [ -e "$adb" ]
then
echo "using adb: $adb" 1>&2
else
echo "could not resolve a path to adb ... check your installation" 1>&2
exit 1
fi
# "pm path" returns somthing like the following
# "package:/data/app/com.koushikdutta.backup-1.apk\r"
# but with a trailing carriage return that screws up the class name in dalvikvm invocation
#
echo "retrieving the class name ..." 1>&2
pkg=$($adb shell pm path com.koushikdutta.backup | /usr/bin/sed -e 's/^.*://' -e 's/\r//')
echo "starting up helium package '$pkg'" 1>&2
$adb shell << EOF
CLASSPATH=$pkg app_process /system/bin com.koushikdutta.shellproxy.ShellRunner2 $@ &
exit
EOF
# end-of-file
@Scooby-2
Copy link

On Mint 17 (Ubuntu 14.04LTS) sed is in /bin and not /usr/bin so as-is this script fails at line 30.

@inukaze
Copy link

inukaze commented Dec 7, 2015

Hi there , for me i must add my device ( DG-310 / Doogee Voyager 2 ) , to my udev rules , i use this code for make that quick

sudo groupadd plugdev
sudo gpasswd -a $USER plugdev
AVID=$(lsusb | grep HTC | awk '{print $6}' | sed 's/[:].*//')
APID=$(lsusb | grep HTC | awk '{print $6}' | sed 's/.*[:]//')
sudo echo 'SUBSYSTEMS=="usb", ATTR{idProduct}=="$AVID",  ATTR{idProduct}=="$APID", MODE="0666", GROUP="plugindev"' >> /etc/udev/rules.d/51-android.rules
ADBN=$(lsusb | grep HTC | awk '{print $2}')
ADDN=$(lsusb | grep HTC | awk '{print $4}' | sed 's/[:].*//')
sudo chmod 666 /dev/bus/usb/$ADBN/$ADDN
sudo udevadm control --reload-rules
sudo service udev restart
sudo udevadm trigger
sudo ./adb kill-server
sudo ./adb usb
sudo ./adb devices
List of devices attached 
0123456789ABCDEF    device
sudo ./adb kill-server
sudo ./run.sh 
linker
CLASSPATH= linker app_process /system/bin com.koushikdutta.shellproxy.ShellRunner2  &
exit
s /system/bin com.koushikdutta.shellproxy.ShellRunner2  &                     <
[1] 3187
shell@J608_PUBLIC:/ $ exit
You have stopped jobs
[1] + Stopped (signal)     CLASSPATH= linker app_process /system/bin c
shell@J608_PUBLIC:/ $ 

well the "Hellium" app from Android , still waiting for "Hellium Desktop" , and now what i must do , to start my sync backups ???

@jotebe
Copy link

jotebe commented Aug 21, 2016

Same issue as Scooby on Lubuntu 15.04, but I was able to symlink sed from /bin to /use/bin and the script worked. This was done on a live CD session so symlink at your own risk.

@andres-asm
Copy link

Thanks for this, now I run this on cron over TCP/IP to keep helium working on my devices on my lan!

@gizmovt
Copy link

gizmovt commented May 5, 2019

worked like a charm, thanks!

@sobaee
Copy link

sobaee commented Dec 5, 2021

Hello @jotebe

Could you please modify the script with this amazing solution?

Iam slightly a beginner and need this please 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment