mount_root: prepare base-files
Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 36429v19.07.3_mercusys_ac12_duma
parent
39469dea7f
commit
811d90ff40
@ -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
|
||||||
|
}
|
@ -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
|
||||||
|
|
@ -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
|
|
@ -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
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue