add preinit modularization work by Daniel Dickinson (cshore)
[openwrt.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/boot.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 # invoked as an executable
16 if [ "${0##*/}" = "firstboot" ]; then
17     if [ "$1" = "switch2jffs" ]; then
18         boot_run_hook switch2jffs
19     elif [ -z "$jffs" ]; then
20         reset_has_fo=true
21         echo "firstboot has already been run"
22         echo "jffs2 partition is mounted, only resetting files"
23         boot_run_hook jffs2reset
24     else
25         mtd erase "$partname"
26         mount "$mtdpart" /jffs -t jffs2
27         fopivot /jffs /rom 1
28     fi
29 else 
30     set_mtd_part
31     set_rom_part
32     set_jffs_part
33 fi
34