Skip to content

run on boot scripts

Vojtěch Boček edited this page Sep 19, 2013 · 1 revision

MultiROM can run bash script just before booting the ROM. It can be used for whatever you want, I use it to do fstrim on my 4.1 ROM. Place the scripts to folder /sdcard/multirom/roms/*rom_name*/run-on-boot, they must have *.sh suffix. You can place multiple scripts. MultiROM calls something along these lines to run theme:

for x in $(busybox ls "/path/to/rom/run-on-boot/"*.sh); do
    echo Running script $x;
    busybox sh $x "*path_to_busybox*" "*path_to_rom_root*" || exit 1;
done

There are no busybox symlinks installed, so you have to call all commands with busybox's path - the first script argument is path to the busybox, so just $1 command. You'll probably also have to mount partitions (except /data - it is in /realdata). This is my fstrim script, for example:

BX="$1"

cleanup()
{
     $BX umount /tmpsys
     $BX umount /tmpcache
     $BX rmdir /tmpsys
     $BX rmdir /tmpcache
}

fail()
{
     echo $1
     cleanup
     exit 1
}

$BX mkdir /tmpsys
$BX mkdir /tmpcache
$BX mount -t ext4 /dev/block/mmcblk0p3 /tmpsys   || fail "Failed to mount system"
$BX mount -t ext4 /dev/block/mmcblk0p4 /tmpcache || fail "Failed to mount cache"

echo $($BX date) > /fstrim_ran

/tmpsys/bin/fstrim /tmpsys >> /fstrim_ran || fail "Failed to run fstrim on system"
/tmpsys/bin/fstrim /tmpcache >> /fstrim_ran || fail "Failed to run fstrim on cache"
/tmpsys/bin/fstrim /realdata >> /fstrim_ran || fail "Failed to run fstrim on data"

cleanup
Clone this wiki locally