mount_root: prepare base-files
Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 36429
This commit is contained in:
parent
39469dea7f
commit
811d90ff40
33 changed files with 80 additions and 71 deletions
20
package/base-files/files.old/etc/init.d/done
Executable file
20
package/base-files/files.old/etc/init.d/done
Executable 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
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
with_fo_cleanup() {
|
||||
# try to get rid of /tmp/root
|
||||
# this will almost always fail
|
||||
umount /tmp/root 2>&-
|
||||
umount -l /tmp/root 2>&-
|
||||
grep -q overlay /proc/filesystems && {
|
||||
cd /
|
||||
(
|
||||
|
|
44
package/base-files/files.old/sbin/firstboot
Executable file
44
package/base-files/files.old/sbin/firstboot
Executable 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
|
||||
|
|
@ -5,7 +5,7 @@ START=95
|
|||
boot() {
|
||||
[ -d /tmp/root ] && {
|
||||
lock /tmp/.switch2jffs
|
||||
firstboot switch2jffs
|
||||
switch2jffs
|
||||
lock -u /tmp/.switch2jffs
|
||||
}
|
||||
|
||||
|
|
|
@ -14,5 +14,5 @@ then
|
|||
elif [ "$SEEN" -gt 5 ]
|
||||
then
|
||||
echo "FACTORY RESET" > /dev/console
|
||||
firstboot && reboot &
|
||||
jffs2reset -y && reboot &
|
||||
fi
|
||||
|
|
|
@ -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
|
|
@ -3,7 +3,16 @@
|
|||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
do_mount_root() {
|
||||
boot_run_hook preinit_mount_root
|
||||
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
|
||||
|
|
|
@ -1,44 +1,3 @@
|
|||
#!/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
|
||||
|
||||
/sbin/jffs2reset
|
||||
|
|
|
@ -179,6 +179,8 @@ fi
|
|||
|
||||
run_hooks "" $sysupgrade_pre_upgrade
|
||||
|
||||
ubus call system upgrade
|
||||
|
||||
kill_remaining TERM
|
||||
sleep 3
|
||||
kill_remaining KILL
|
||||
|
|
Loading…
Reference in a new issue