A few notes: Maemo 4 does not have an ext3 partition on the built-in card so it's a no-go unless you repartition (at which point you are better off cloning the whole root).
Also, I have not analyzed your script, but be VERY careful about moving /usr/lib stuff around - that can cause serious breakage.