source: freewrt/package/base-files/default/bin/firstboot@ 95de009

freewrt_1_0 freewrt_2_0
Last change on this file since 95de009 was 95de009, checked in by Waldemar Brodkorb <wbx@…>, 19 years ago

sysfs is kernel 2.6 only

git-svn-id: svn://www.freewrt.org/trunk/freewrt@383 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#!/bin/sh
2# $Id: firstboot 3633 2006-04-13 14:43:47Z nbd $
3
4rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
5jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
6
7dupe() { # <new_root> <old_root>
8 cd $1
9 echo -n "creating directories... "
10 {
11 cd $2
12 find . -xdev -type d
13 echo "./dev ./jffs ./mnt ./proc ./tmp"
14 # xdev skips mounted directories
15 cd $1
16 } | xargs mkdir -p
17 echo "done"
18
19 echo -n "setting up symlinks... "
20 for file in $(cd $2; find . -xdev -type f;); do
21 case "$file" in
22 ./rom/note) ;; #nothing
23 ./etc/config*|\
24 ./etc/resolv.conf|\
25 ./usr/lib/ipkg/info) cp -af $2/$file $file;;
26 *) ln -sf /rom/${file#./*} $file;;
27 esac
28 done
29 for file in $(cd $2; find . -xdev -type l;); do
30 cp -af $2/${file#./*} $file
31 done
32 echo "done"
33}
34
35pivot() { # <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 return 0
41 }
42}
43
44mountdp() { # <device> <mount_point> <ignored> <fs>
45 dev=$1; mnt=$2; shift 2; opt=$*
46 mount $dev $mnt $opt
47 dupe $mnt $rom
48 pivot $mnt /rom
49}
50
51fopivot() { # <rw_root> <ro_root> <dupe?>
52 root=$1
53 mount -t mini_fo -o base=/,sto=$1 $1 /mnt 2>&- && root=/mnt
54 pivot $root $2
55}
56
57
58ramoverlay() {
59 mkdir -p /tmp/root
60 mountdp /tmp/root /mnt -o bind
61}
62
63[ "${0##*/}" = "firstboot" ] && {
64 [ -z "$rom" ] && {
65 echo "You do not have a squashfs partition; aborting"
66 echo "(firstboot cannot be run on jffs2 based firmwares)"
67 exit 1
68 }
69
70 # script run manually
71 [ \! -z "$jffs" ] && {
72 echo "firstboot has already been run"
73 echo "jffs2 partition is mounted, only resetting files"
74 dupe $jffs $rom
75 exit 0
76 }
77
78 mtd erase data
79 mountdp /dev/mtdblock/4 /jffs -t jffs2
80}
Note: See TracBrowser for help on using the repository browser.