5

Okay, without getting too deep into details, I'm looking to automate the installation of a flashable zip (must be flashed from recovery). For now, I can use the command "reboot recovery" in a shell script to bring me into TWRP, but I'm not sure how to tell TWRP to install something automatically.

I know this is possible because Cyanogenmod does this exact thing with their ROM update utility. Once a ROM update is downloaded, you click "Reboot and Install" from within CM, the phone reboots into TWRP, the installation of the flashable zip begins, and after it completes the phone reboots again back into CM.

I don't know if I can just append the file's path onto the "reboot" command with a particular switch? I haven't been able to find documentation on the available options. I was also thinking maybe TWRP looks for an update.zip file upon launching?

Does anyone know how to do this?

1 Answer 1

6

I ended up looking at Cyanongenmod's source code and figured out how they did it.

Here is my working .sh script:

echo 'boot-recovery ' > /cache/recovery/command
echo '--update_package=/sdcard/update.zip' >> /cache/recovery/command
reboot recovery

Update:

with android JellyBean [4.1] and later versions, the sdcard data is located now at /sdcard/0, So the second command must be:

echo '--update_package=/sdcard/0/update.zip' >> /cache/recovery/command
4
  • I got this error: E:cannot mount /sdcard (No such file or directory) ---- E:Can't mount /sdcard/0/update.zip ----- Installation aborted.
    – Dr.jacky
    Commented Oct 13, 2015 at 10:48
  • Your device may not use that symlink "/sdcard/" then. Try "/mnt/sdcard/update.zip" instead. All storage devices should show up somewhere in "/mnt/", use a root file manager or terminal emulator to list all the available options. Commented Oct 13, 2015 at 15:45
  • I can access mnt/sdcard in terminal, but when I got this error in recovery mode: Finding update package...... E:unknown volume for path [/mnt/sdcard/update.zip] ...... Can't mount /mnt/sdcard/update.zip
    – Dr.jacky
    Commented Oct 14, 2015 at 6:00
  • One thing you can try next is browsing your root directory structure directly from recovery. In both TWRP and ClockworkMod, the "Install from Zip" feature can act as a directory-browser. Navigate through your root directories (obviously not installing any zips here) and see if you come across any sub-directories which lead to your desired storage location. On my device, I was unable to find any alternate paths; "/sdcard" is my only option. If you're unable to find your sdcard, I'd say just forget about flashing from that location. Copy the zip you're flashing to "/cache" and call it a day. Commented Oct 14, 2015 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .