2 # Copyright (C) 2006 OpenWrt.org
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
40 mount
-o move
$2/sys
/sys
45 mountdp
() { # <device> <mount_point> <ignored> <fs>
46 dev
=$1; mnt
=$2; shift 2; opt
=$
*
54 mountdp
/tmp
/root
/mnt
-o bind
57 [ "${0##*/}" = "firstboot" ] && {
59 echo "You do not have a squashfs partition; aborting"
60 echo "(firstboot cannot be run on jffs2 based firmwares)"
64 [ "$1" = "switch2jffs" ] && {
66 mount
-o remount
,ro none
/ # try to avoid fs changing while copying
68 mount
/dev
/mtdblock
/4 /rom
/jffs
-t jffs2
69 echo -n "copying files ... "
70 cp -a /mnt
/* /rom
/jffs
74 mount
-o move
/mnt
/tmp
/root
80 [ \
! -z "$jffs" ] && {
81 echo "firstboot has already been run"
82 echo "jffs2 partition is mounted, only resetting files"
88 mountdp
/dev
/mtdblock
/4 /jffs
-t jffs2
This page took 0.060806 seconds and 5 git commands to generate.