[G1 Android Development] Firerat:
SM_install_a2sd.sh

btw, what is

"Do Not Change This Header Without Making a Significant Change That is found to be safe!"

all about?

I don't see anything that could be deemed as a header

did you see it in someone else's script and figured it did something important ?

#!/sbin/sh
# Do Not Change This Header Without Making a Significant Change That is found to be safe! This Script was made by SparksCo, to auto-dectect if sd-ext partition is present. If sd-ext is present, it will install Firerat's Scripts for froyo a2sd & IConrad01's fix's for Froyo a2sd. Meanwhile, it will also install any extra's needed, pretty simple really. Thanks again to Firerat and IConrad01, but mostly FR ;)
# Detect sd-ext and install data binds
if [ -e /dev/block/mmcblk0p2 ];
then
[COLOR="Blue"]# this checks if /dev/block/mmcblk0p2 exists
# no real problems here, but -b instead of -e is much better
# ( -b will also ckeck that it is a block device and not just some file or dir )[/COLOR]
if [ "`mount /data`" = "" ];
then
[COLOR="blue"] # the only thing this does is execute the command
# mount /data
# the test is pointless as mount will not output to stdout, it will always pass[/COLOR]
if [ -d /data/local ];
then
if [ -e /data/local/bootanimation.zip ];
then
rm -f /data/local/bootanimation.zip;
cp /tmp/bootanimation.zip /data/local/bootanimation.zip;
else
cp /tmp/bootanimation.zip /data/local/bootanimation.zip;
fi;
else
mkdir /data/local;
cp /tmp/bootanimation.zip /data/local/bootanimation.zip;
fi;
[COLOR="blue"] # much of the above is pointless, first is tests of /data/local is a dir,
# then is checks if /data/local/bootanimation.zip exists , and deletes it if it does
# it then copies /tmp/bootanimation.zip to /data/local/bootanimation.zip
# this is much much simpler, and achives the same
#####
# if [ -L /data/local/bootanimation.zip ];
# then
# rm /data/local/bootanimation.zip
# fi
# install -D /tmp/bootanimation.zip /data/local/bootanimation.zip
##### note, we checked if /data/local/bootanimation.zip was a link and removed it, so the file didn't get redirected[/COLOR]
if [ -d /data/app ];
then
if [ -e /data/app/GoLauncher.apk ];
then
rm -f /data/app/GoLauncher.apk;
cp /tmp/GoLauncher.apk /data/app/GoLauncher.apk;
umount /data;
else
cp /tmp/GoLauncher.apk /data/app/GoLauncher.apk;
umount /data;
fi;
else
mkdir /data/app;
cp /tmp/GoLauncher.apk /data/app/GoLauncher.apk;
umount /data;
fi;
[COLOR="blue"] # hmm, this looks a little bit like the bootanimation thing, lets have less duplicate code
#####
# for target in /data/local/bootanimation.zip /data/app/GoLauncher.apk;do
# if [ -L $target ];
# then
# rm $target
# fi
# install -m 644 -o 1000 -g 1000 -D /tmp/`basename $target` $target
# done[/COLOR]
else
if [ -d /data/local ];
then
if [ -e /data/local/bootanimation.zip ];
then
rm -f /data/local/bootanimation.zip;
cp /tmp/bootanimation.zip /data/local/bootanimation.zip;
else
cp /tmp/bootanimation.zip /data/local/bootanimation.zip;
fi;
else
mkdir /data/local;
cp /tmp/bootanimation.zip /data/local/bootanimation.zip;
fi;
if [ -d /data/app ];
then
if [ -e /data/app/GoLauncher.apk ];
then
rm -f /data/app/GoLauncher.apk;
cp /tmp/GoLauncher.apk /data/app/GoLauncher.apk;
umount /data;
else
cp /tmp/GoLauncher.apk /data/app/GoLauncher.apk;
umount /data;
fi;
else
mkdir /data/app;
cp /tmp/GoLauncher.apk /data/app/GoLauncher.apk;
umount /data;
fi;
fi;
[COLOR="blue"] # remember I said that the if [ "`mount /data`" = "" ]; was pointless ?
# will the above block will never run, and it is exacly the same anyway, so it is even more pointless
else
# hmm, hold on, All the above executed if /dev/block/mmcblk0p2 existed .. but.. errm none of it has anything to do with sd-ext[/COLOR]
echo "no ext partition detected, Skipping Froyo a2sd! Continue to install launcher seperately!";
if [ "`mount /data`" = "" ];
then
# again with the pointless testing
if [ -d /data/app ];
then
if [ -e /data/app/GoLauncher.apk ];
then
rm -f /data/app/GoLauncher.apk;
cp /tmp/GoLauncher.apk /system/app/GoLauncher.apk;
else
cp /tmp/GoLauncher.apk /system/app/GoLauncher.apk;
fi;
else
mkdir /data/app;
cp /tmp/GoLauncher.apk /system/app/GoLauncher.apk;
fi;
[COLOR="blue"] # ok, so if /dev/block/mmcblk0p2 doesn't exists we do the same as if it did but exclude the bootanimation?
# why? it has nothing to do with sd-ext
else
# errm, this is the same as the above block, and will never run anyway[/COLOR]
if [ -d /data/app ];
then
if [ -e /data/app/GoLauncher.apk ];
then
rm -f /data/app/GoLauncher.apk;
cp /tmp/GoLauncher.apk /system/app/GoLauncher.apk;
else
cp /tmp/GoLauncher.apk /system/app/GoLauncher.apk;
fi;
else
mkdir /data/app;
cp /tmp/GoLauncher.apk /system/app/GoLauncher.apk;
fi;
fi;
fi;
if [ -e /dev/block/mmcblk0p2 ];
then
mount /sd-ext;
mkdir /sd-ext/userinit.d;
cp /tmp/10data2sdext-binds /sd-ext/userinit.d/10data2sdext-binds;
chmod 755 /sd-ext/userinit.d/10data2sdext-binds;
cp /tmp/55ApkManager /sd-ext/userinit.d/55ApkManager;
chmod 755 /sd-ext/userinit.d/55ApkManager;
mkdir /sd-ext/app;
cp /tmp/sd-ext/ATKFroyo.apk /sd-ext/app/ATKFroyo.apk;
cp /tmp/sd-ext/CarHomeGoogle.apk /sd-ext/app/CarHomeGoogle.apk;
cp /tmp/sd-ext/CarHomeLauncher.apk /sd-ext/app/CarHomeLauncher.apk;
cp /tmp/sd-ext/Chrome2Phone.apk /sd-ext/app/Chrome2Phone.apk;
cp /tmp/sd-ext/GoogleVoice.apk /sd-ext/app/GoogleVoice.apk;
cp /tmp/sd-ext/Maps.apk /sd-ext/app/Maps.apk;
cp /tmp/sd-ext/RomManager.apk /sd-ext/app/RomManager.apk;
cp /tmp/sd-ext/Street.apk /sd-ext/app/Street.apk;
cp /tmp/sd-ext/Talk.apk /sd-ext/app/Talk.apk;
cp /tmp/sd-ext/TB.apk /sd-ext/app/TB.apk;
cp /tmp/sd-ext/Twitter.apk /sd-ext/app/Twitter.apk;
cp /tmp/sd-ext/VoiceSearch.apk /sd-ext/app/VoiceSearch.apk;
cp /tmp/sd-ext/youtube.apk /sd-ext/app/youtube.apk;
[COLOR="blue"] # thats all a bit tiersome
# cp /tmp/sd-ext/*apk /sd-ext/app/
# and then delete GoLauncher.apk ( or use the grep -v and the for loop below )
# there are other, better ways, of doing it[/COLOR]
umount /sd-ext;
else
echo "no ext partition detected, Skipping Froyo a2sd!";
fi;
if [ -e /dev/block/mmcblk0p2 ];
then
rm /system/etc/init.d/05mountsd;
rm /system/etc/init.d/20userinit;
cp /tmp/05mountsd /system/etc/init.d/05mountsd;
cp /tmp/20userinit /system/etc/init.d/20userinit;
cp /tmp/ApkManager.sh /system/bin/ApKManager.sh;
cp /tmp/swappy /system/bin/swappy;
# errm, why not include all this in the above ?
else
echo "No Ext Partition Found, Skipping Froyo a2sd!";
fi;

[COLOR="blue"]### here is all of the above , condensed into a real delivery script without all the redundent "I don't know wtf I'm doing " stuff
# it also sets the correct permissions
# #!/sbin/sh
# mount /data
# if [ "`grep -q \ \/data\ /proc/mounts;echo $?`" = "0" ];
# then
# for target in /data/local/bootanimation.zip /data/app/GoLauncher.apk;do
# if [ -L $target ];
# then
# rm $target
# fi
# install -m 644 -o 1000 -g 1000 -D /tmp/`basename $target` $target
# else
# echo "data failed to mount, which is very bad, this should not happen"
# fi
# mount /sd-ext
# if [ "`grep -q \ \/sd-ext\ /proc/mounts;echo $?`" != "0" ];
# then
# echo "sd-ext failed to mount, skipping sd-ext stuff"
# else
# mount /system
# if [ "`grep -q \ \/system\ /proc/mounts;echo $?`" != "0" ];
# then
# echo "system failed to mount, which is very bad, this should not happen"
# else
# for target in /sd-ext/userinit.d/10data2sdext-binds /sd-ext/userinit.d/55ApkManager /system/etc/init.d/05mount /system/etc/init.d/20userinit;do
# install -m 700 -o 0 -g 0 -D /tmp/`basename ${target}` ${target}
# done
# for target in `ls /tmp/*apk|grep -v GoLauncher.apk`;do
# install -m 644 -o 1000 -g 1000 -D $target /sd-ext/app/`basename $target`
# done
# fi
# fi

## Note, ApkManager is installed to system/bin by 55ApkManager
## and swappy is installed by 25Swap , which is being installed by some other crappy delivery script
##
[/COLOR]

anyone fancy having a go at correcting the other scripts?