5 ldd
() { LD_TRACE_LOADED_OBJECTS
=1 $
*; }
6 libs
() { ldd $
* |
awk '{print $3}'; }
8 install_file
() { # <file> [ <file> ... ]
10 dest
="$RAM_ROOT/$file"
11 [ -f $file -a ! -f $dest ] && {
12 dir
="$(dirname $dest)"
19 install_bin
() { # <file> [ <symlink> ... ]
22 [ -x "$src" ] && files
="$src $(libs $src)"
25 for link
in "$@"; do {
26 dest
="$RAM_ROOT/$link"
27 dir
="$(dirname $dest)"
29 [ -f "$dest" ] ||
ln -s $src $dest
33 pivot
() { # <new_root> <old_root>
34 mount |
grep "on $1 type" 2>&- 1>&- || mount
-o bind $1 $1
35 mkdir
-p $1$2 $1/proc
$1/dev
$1/tmp
$1/jffs
&& \
36 mount
-o move
/proc
$1/proc
&& \
37 pivot_root
$1 $1$2 ||
{
41 mount
-o move
$2/dev
/dev
42 mount
-o move
$2/tmp
/tmp
43 mount
-o move
$2/jffs
/jffs
2>&-
47 run_ramfs
() { # <command> [...]
48 install_bin
/bin
/busybox
/bin
/ash
/bin
/sh
/bin
/mount
/bin
/umount
/sbin
/pivot_root
/usr
/bin
/wget
/sbin
/reboot
/bin
/sync
/bin
/dd /bin
/grep /bin
/cp /bin
/mv /bin
/tar /usr
/bin
/md5sum "/usr/bin/[" /bin
/vi
50 for file in $RAMFS_COPY_BIN; do
53 install_file
/etc
/resolv.conf
/etc
/functions.sh
/lib
/upgrade
/*.sh
$RAMFS_COPY_DATA
55 pivot
$RAM_ROOT /mnt ||
{
56 echo "Failed to switch over to ramfs. Please reboot."
60 mount
-o remount
,ro
/mnt
63 grep /jffs
/proc
/mounts
> /dev
/null
&& {
64 mount
-o remount
,ro
/jffs
68 # spawn a new shell from ramdisk to reduce the probability of cache issues
69 exec /bin
/busybox ash
-c "$*"
80 local default
="$1"; shift;
81 local answer
="$default"
83 [ "$INTERACTIVE" -eq 1 ] && {
85 0) echo -n "$* (y/N): ";;
86 *) echo -n "$* (Y/n): ";;
92 *) answer
="$default";;
99 [ "$VERBOSE" -ge 1 ] && echo "$@"
103 mount |
awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }'
110 http
://*|
ftp://*) wget
-O- -q "$from";;
116 get_image
"$1" |
dd bs
=2 count
=1 2>/dev
/null |
hexdump |
awk '$2 { print $2 }'
119 refresh_mtd_partitions
() {
123 jffs2_copy_config
() {
124 if grep rootfs_data
/proc
/mtd
>/dev
/null
; then
126 mtd
-e rootfs_data jffs2write
"$CONF_TAR" rootfs_data
129 mtd jffs2write
"$CONF_TAR" rootfs
134 v
"Performing system upgrade..."
135 platform_do_upgrade
"$ARGV"
137 [ "$SAVE_CONFIG" -eq 1 ] && {
138 v
"Refreshing partitions"
139 if type 'platform_refresh_partitions' >/dev
/null
2>/dev
/null
; then
140 platform_refresh_partitions
142 refresh_mtd_partitions
144 if type 'platform_copy_config' >/dev
/null
2>/dev
/null
; then
150 ask_bool
1 "Reboot" && reboot