[Galaxy S II Original Android Development] curioct:
[MOD/FIX]scripts will now mount storage on boot and path is fixed

First the [FIX] bit

The attached scripts change the PATH environment variable settings to include /usr/local/bin as needed this is added into the 'bt' script

not sure if this was in all versions of doom's scripts but it's fixed in these ones where it was missing.

*I have not gone through all programs to identify if other directories should be in path or not

Second the [MOD]

I have modified the 'startbt' and 'stopbt' scripts to automatically mount and unmount the sdcard, external_sd and the usb flash drives (otg cable required)

Once Back|track 5 is loaded these are mounted in the /root/storage directory creating three directories called 'sdcard', 'external_sd' and 'usbflash'

Since I was only really doing this as a POC, for myself and the poster above, I have not done extensive testing but so far the sdcard and external_sd are working just fine.

Using a USB flash via this methof the flash drive must be mounted via the OTG cable and fully enumerated prior to booting or files will not display.

one word of caution my startbt script is configred to boot BT5 from the external sdcard (edit line 5 remove '/external_sd' for default configuration)

Full scripts with mods highlighted and underlined (simple bold didn't seem to show up much):-

startbt :-

echo "BackTrack Loader by Anant based on ubuntu loader"
echo " "
echo "[ STEP 2 ]"
echo ">> Setting variables"
export kit=/sdcard/[B][U]external_sd/[/U][/B]bt
export bin=/system/bin
export mnt=/data/local/bt
[B][U]export stor=$mnt/root/storage
export sdcard=$stor/sdcard
export extsd=$stor/external_sd
export usbflash=$stor/usbflash[/U][/B]
export PATH=$bin:/usr/bin[B][U]:/usr/local/bin[/U][/B]:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
export bboxpath=/data/local/tmp/bt/busybox
# Mounting Image to the farthest loop point
# FIXME : check if mount sucessfull otherwise abort whole process.
echo ">> Creating nodes"
$bboxpath mknod /dev/block/loop254 b 7 254
echo ">> Mounting image"
$bboxpath losetup /dev/block/loop254 $kit/bt.img
echo ">> Setting other mount points"
$bboxpath mount -t ext2 /dev/block/loop254 $mnt
$bboxpath mount -t devpts devpts $mnt/dev/pts
$bboxpath mount -t proc proc $mnt/proc
$bboxpath mount -t sysfs sysfs $mnt/sys
[B][U]$bboxpath mkdir -p $sdcard
$bboxpath mkdir -p $extsd
$bboxpath mkdir -p $usbflash
$bboxpath mount --bind /mnt/sdcard $sdcard
$bboxpath mount --bind /mnt/sdcard/external_sd $extsd
$bboxpath mount --bind /mnt/sdcard/usbStorage/sda $usbflash[/U][/B]
echo ">> Seting environment"
sysctl -w net.ipv4.ip_forward=1
echo ">> Setting /etc/resolv.conf to Google Open DNS 8.8.8.8 and 8.8.4.4"
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost" > $mnt/etc/hosts
echo "[ STEP 2 COMPLETE ]"
echo " "
echo "BackTrack is ready just type 'bt' (without the quotes)"

bt script with mods in bold:-

echo "[ STEP 3 ]"
echo ">> Setting variables"
export kit=/sdcard/bt
export bin=/system/bin
export mnt=/data/local/bt
export PATH=$bin:/usr/bin:/usr/sbin[B][U]:/usr/local/bin[/U][/B]:/bin:$PATH
export TERM=linux
export HOME=/root
export bboxpath=/data/local/tmp/bt/busybox
echo ">> Correcting resolution issues"
$bboxpath sed -i 's/850/800/g' /data/local/bt/root/bin/ui
echo "[ STEP 3 COMPLETE ]"
echo "Customized script for BackTrack by Anant shrivastava http://anantshri.info"
echo "modded for SGS2 by DooMLoRD"
echo "Enjoy BackTrack 5 }:)"
echo " "
echo "BackTrack shell will now be lauched"
echo "to start GUI (vncserver) type 'ui' (without the quotes)"
$bboxpath chroot $mnt /bin/bash

stopbt script with mods in bold:-

echo "Cleaning the leftover and returning back the memory to Android."
echo "by Anant Shrivastava http://anantshri.info "
echo " "
echo "[ Cleanup ]"
#After exit command is executed clear it all up
echo ">> Setting variables"
export kit=/sdcard/bt
export bin=/system/bin
export mnt=/data/local/bt
export PATH=$bin:/usr/bin:/usr/sbin[B][U]:/usr/local/bin[/U][/B]:/bin:$PATH
export TERM=linux
export HOME=/root
export bboxpath=/data/local/tmp/bt/busybox
sync
echo ">> Unmounting temporary mount points"
[B][U]$bboxpath umount -l /data/local/bt/root/storage/external_sd
$bboxpath umount -l /data/local/bt/root/storage/usbflash
$bboxpath umount -l /data/local/bt/root/storage/sdcard[/U][/B]
$bboxpath umount -l $mnt/dev/pts
$bboxpath umount -l $mnt/proc
$bboxpath umount -l $mnt/sys
$bboxpath umount -l $mnt
echo ">> Unmounting image"
$bboxpath losetup -d /dev/block/loop254
echo ">> Remounting system as RO"
$bboxpath mount -o remount,ro /system
echo "[ Cleanup Completed ]"
echo " "
echo "Please reboot to properly unmount BackTrack"

I've just noticed I have used full path's in unmounting in this last script, so if you modified the paths to mount things you need to modify these too.

additionally I used root explorer to manually copy these to '/system/bin' there is no reason that I can think of that these should not work with the standard install.sh script but this has not been tested by me.

Disclaimer: as mentioned above this was a simple quick and dirty POC for me this messes with files in sensitve areas of your phone, I take no responsibilty for any damage you might do to your own phone.