06b64c31332e48bb1025a7fd3dad9a3c139e6376
[openwrt/svn-archive/archive.git] / package / base-files / files / sbin / firstboot
1 #!/bin/sh
2
3 switch2jffs_hook=
4 jffs2reset_hook=
5 no_fo_hook=
6
7 . /lib/functions.sh
8
9 firstboot_skip_next=false
10
11 for fb_source_file in /lib/firstboot/*; do
12 . $fb_source_file
13 done
14
15 set_mtd_part
16 set_rom_part
17 set_jffs_part
18
19 # invoked as an executable
20 if [ "${0##*/}" = "firstboot" ]; then
21 if [ "$1" = "switch2jffs" ]; then
22 boot_run_hook switch2jffs
23 else
24 if [ -t 0 ] && [ "$1" != "-y" ]; then
25 local input
26
27 echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]"
28 read input
29 [ "$input" = "y" ] || [ "$input" = "Y" ] || return 0
30 fi
31
32 if [ -n "$jffs" ]; then
33 reset_has_fo=true
34 echo "firstboot has already been run"
35 echo "jffs2 partition is mounted, only resetting files"
36 boot_run_hook jffs2reset
37 else
38 mtd erase "$partname"
39 mount -o noatime "$mtdpart" /overlay -t jffs2
40 fopivot /overlay /rom 1
41 fi
42 fi
43 fi
44