4 rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
5 jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
7 dupe() { # <new_root> <old_root>
9 echo -n "creating directories... "
13 echo "./dev ./jffs ./mnt ./proc ./tmp ./sys"
14 # xdev skips mounted directories
19 echo -n "setting up symlinks... "
20 for file in $(cd $2; find . -xdev -type f;); do
22 "./rom/note") ;; #nothing
25 "./usr/lib/ipkg/info") cp -af $2/$file $file;;
26 *) ln -sf /rom/${file#./*} $file;;
29 for file in $(cd $2; find . -xdev -type l;); do
30 cp -af $2/${file#./*} $file
35 pivot() { # <new_root> <old_root>
36 mount -o move /proc $1/proc && \
37 pivot_root $1 $1$2 && {
38 mount -o move $2/dev /dev
39 mount -o move $2/tmp /tmp
43 mountdp() { # <device> <mount_point> <ignored> <fs>
44 dev=$1; mnt=$2; shift 2; opt=$*
52 mountdp /tmp/root /mnt -o bind
55 [ "${0##*/}" = "firstboot" ] && {
57 echo "You do not have a squashfs partition; aborting"
58 echo "(firstboot cannot be run on jffs2 based firmwares)"
62 [ "$1" = "switch2jffs" ] && {
64 mount -o remount,ro none / # try to avoid fs changing while copying
66 mount /dev/mtdblock/4 /rom/jffs -t jffs2
67 echo -n "copying files ... "
68 cp -a /mnt/* /rom/jffs
72 mount -o move /mnt /tmp/root
79 [ \! -z "$jffs" ] && {
80 echo "firstboot has already been run"
81 echo "jffs2 partition is mounted, only resetting files"
87 mountdp /dev/mtdblock/4 /jffs -t jffs2