mount_root: prepare base-files

Signed-off-by: John Crispin <blogic@openwrt.org>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@36429 3c298f89-4303-0410-b956-a3cf2f4a3e73
master
John Crispin 2013-04-25 19:02:32 +00:00
parent b605befa7c
commit 1940283948
33 changed files with 80 additions and 71 deletions

View File

@ -0,0 +1,20 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=95
boot() {
[ -d /tmp/root ] && {
lock /tmp/.switch2jffs
firstboot switch2jffs
lock -u /tmp/.switch2jffs
}
# process user commands
[ -f /etc/rc.local ] && {
sh /etc/rc.local
}
# set leds to normal state
. /etc/diag.sh
set_state done
}

View File

@ -6,7 +6,7 @@
with_fo_cleanup() { with_fo_cleanup() {
# try to get rid of /tmp/root # try to get rid of /tmp/root
# this will almost always fail # this will almost always fail
umount /tmp/root 2>&- umount -l /tmp/root 2>&-
grep -q overlay /proc/filesystems && { grep -q overlay /proc/filesystems && {
cd / cd /
( (

View File

@ -0,0 +1,44 @@
#!/bin/sh
switch2jffs_hook=
jffs2reset_hook=
no_fo_hook=
. /lib/functions.sh
firstboot_skip_next=false
for fb_source_file in /lib/firstboot/*; do
. $fb_source_file
done
set_mtd_part
set_rom_part
set_jffs_part
# invoked as an executable
if [ "${0##*/}" = "firstboot" ]; then
if [ "$1" = "switch2jffs" ]; then
boot_run_hook switch2jffs
else
if [ -t 0 ] && [ "$1" != "-y" ]; then
local input
echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]"
read input
[ "$input" = "y" ] || [ "$input" = "Y" ] || return 0
fi
if [ -n "$jffs" ]; then
reset_has_fo=true
echo "firstboot has already been run"
echo "jffs2 partition is mounted, only resetting files"
boot_run_hook jffs2reset
else
mtd erase "$partname"
mount -o noatime "$mtdpart" /overlay -t jffs2
fopivot /overlay /rom 1
fi
fi
fi

View File

@ -5,7 +5,7 @@ START=95
boot() { boot() {
[ -d /tmp/root ] && { [ -d /tmp/root ] && {
lock /tmp/.switch2jffs lock /tmp/.switch2jffs
firstboot switch2jffs switch2jffs
lock -u /tmp/.switch2jffs lock -u /tmp/.switch2jffs
} }

View File

@ -14,5 +14,5 @@ then
elif [ "$SEEN" -gt 5 ] elif [ "$SEEN" -gt 5 ]
then then
echo "FACTORY RESET" > /dev/console echo "FACTORY RESET" > /dev/console
firstboot && reboot & jffs2reset -y && reboot &
fi fi

View File

@ -1,25 +0,0 @@
#!/bin/sh
# Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2010 Vertical Communications
with_fo_cleanup() {
# try to get rid of /tmp/root
# this will almost always fail
umount -l /tmp/root 2>&-
grep -q overlay /proc/filesystems && {
cd /
(
cd /overlay
find -type l
) | while read FILE; do
[ -z "$FILE" ] && break
if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then
rm -f "$FILE"
fi
done
}
exit 0
}
boot_hook_add switch2jffs with_fo_cleanup

View File

@ -3,7 +3,16 @@
# Copyright (C) 2010 Vertical Communications # Copyright (C) 2010 Vertical Communications
do_mount_root() { do_mount_root() {
mount_root
boot_run_hook preinit_mount_root boot_run_hook preinit_mount_root
[ -f /sysupgrade.tgz ] && {
echo "- config restore -"
cd /
mv sysupgrade.tgz /tmp
tar xzf /tmp/sysupgrade.tgz
rm -f /tmp/sysupgrade.tgz
sync
}
} }
[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root [ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root

View File

@ -1,44 +1,3 @@
#!/bin/sh #!/bin/sh
switch2jffs_hook= /sbin/jffs2reset
jffs2reset_hook=
no_fo_hook=
. /lib/functions.sh
firstboot_skip_next=false
for fb_source_file in /lib/firstboot/*; do
. $fb_source_file
done
set_mtd_part
set_rom_part
set_jffs_part
# invoked as an executable
if [ "${0##*/}" = "firstboot" ]; then
if [ "$1" = "switch2jffs" ]; then
boot_run_hook switch2jffs
else
if [ -t 0 ] && [ "$1" != "-y" ]; then
local input
echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]"
read input
[ "$input" = "y" ] || [ "$input" = "Y" ] || return 0
fi
if [ -n "$jffs" ]; then
reset_has_fo=true
echo "firstboot has already been run"
echo "jffs2 partition is mounted, only resetting files"
boot_run_hook jffs2reset
else
mtd erase "$partname"
mount -o noatime "$mtdpart" /overlay -t jffs2
fopivot /overlay /rom 1
fi
fi
fi

View File

@ -179,6 +179,8 @@ fi
run_hooks "" $sysupgrade_pre_upgrade run_hooks "" $sysupgrade_pre_upgrade
ubus call system upgrade
kill_remaining TERM kill_remaining TERM
sleep 3 sleep 3
kill_remaining KILL kill_remaining KILL