mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-04-21 12:27:27 +03:00
add preinit modularization work by Daniel Dickinson (cshore)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@19331 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
10
package/base-files/files/lib/firstboot/05_firstboot_skip
Normal file
10
package/base-files/files/lib/firstboot/05_firstboot_skip
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
check_skip() {
|
||||
if [ "$firsboot_skip_next" = "true" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
46
package/base-files/files/lib/firstboot/10_determine_parts
Normal file
46
package/base-files/files/lib/firstboot/10_determine_parts
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
set_mtd_part() {
|
||||
partname="rootfs_data"
|
||||
mtdpart="$(find_mtd_part $partname)"
|
||||
}
|
||||
|
||||
set_rom_part() {
|
||||
rom=$(awk '/squashfs/ {print $2}' /proc/mounts)
|
||||
}
|
||||
|
||||
set_jffs_part() {
|
||||
jffs=$(awk '/jffs2/ {print $2}' /proc/mounts)
|
||||
}
|
||||
|
||||
determine_mtd_part() {
|
||||
set_mtd_part
|
||||
if [ -z "$mtdpart" ]; then
|
||||
echo "MTD partition not found."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
determine_rom_part() {
|
||||
check_skip || {
|
||||
set_rom_part
|
||||
if [ -z "$rom" ]; then
|
||||
echo "You do not have a squashfs partition; aborting"
|
||||
echo "(firstboot cannot be run on jffs2 based firmwares)"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
determine_jffs2_part() {
|
||||
check_skip || {
|
||||
set_jffs_part
|
||||
}
|
||||
}
|
||||
|
||||
boot_hook_add switch2jffs determine_mtd_part
|
||||
boot_hook_add jffs2reset determine_mtd_part
|
||||
boot_hook_add switch2jffs determine_rom_part
|
||||
boot_hook_add jffs2reset determine_rom_part
|
||||
boot_hook_add switch2jffs determine_jffs2_part
|
||||
boot_hook_add jffs2reset determine_jffs2_part
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
no_fo_clear_overlay() {
|
||||
# switch back to squashfs temporarily
|
||||
pivot /rom /mnt
|
||||
|
||||
# get rid of the old overlay
|
||||
umount -l /mnt
|
||||
|
||||
# another umount to get rid of the bind from /tmp/root
|
||||
umount -l /mnt
|
||||
}
|
||||
|
||||
boot_hook_add no_fo no_fo_clear_overlay
|
||||
12
package/base-files/files/lib/firstboot/10_reset_has_mini_fo
Normal file
12
package/base-files/files/lib/firstboot/10_reset_has_mini_fo
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
reset_check_for_mini_fo() {
|
||||
if grep -q mini_fo /proc/filesystems; then
|
||||
reset_has_fo=true
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add jffs2reset reset_check_for_mini_fo
|
||||
13
package/base-files/files/lib/firstboot/20_has_mini_fo
Normal file
13
package/base-files/files/lib/firstboot/20_has_mini_fo
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
check_for_mini_fo() {
|
||||
if ! grep -q mini_fo /proc/filesystems; then
|
||||
boot_run_hook no_fo
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add switch2jffs check_for_mini_fo
|
||||
15
package/base-files/files/lib/firstboot/20_no_fo_mount_jffs
Normal file
15
package/base-files/files/lib/firstboot/20_no_fo_mount_jffs
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
no_fo_mount_jffs() {
|
||||
# initialize jffs2
|
||||
mount "$mtdpart" /jffs -t jffs2 || exit
|
||||
|
||||
# workaround to ensure that union can attach properly
|
||||
sync
|
||||
ls /jffs >/dev/null
|
||||
}
|
||||
|
||||
boot_hook_add no_fo no_fo_mount_jffs
|
||||
14
package/base-files/files/lib/firstboot/20_reset_clear_jffs
Normal file
14
package/base-files/files/lib/firstboot/20_reset_clear_jffs
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
reset_clear_jffs() {
|
||||
[ "$reset_has_fo" = "true" ] && {
|
||||
rm -rf $jffs/* 2>&-
|
||||
mount -o remount $jffs / 2>&-
|
||||
exit 0
|
||||
} || reset_has_fo=false
|
||||
}
|
||||
|
||||
boot_hook_add jffs2reset reset_clear_jffs
|
||||
10
package/base-files/files/lib/firstboot/30_is_rootfs_mounted
Normal file
10
package/base-files/files/lib/firstboot/30_is_rootfs_mounted
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
skip_if_rootfs_mounted() {
|
||||
mount "$mtdpart" /rom/jffs -t jffs2 || exit
|
||||
}
|
||||
|
||||
boot_hook_add switch2jffs skip_if_rootfs_mounted
|
||||
11
package/base-files/files/lib/firstboot/30_no_fo_pivot
Normal file
11
package/base-files/files/lib/firstboot/30_no_fo_pivot
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
no_fo_pivot() {
|
||||
# switch to the new (empty) jffs2
|
||||
fopivot /jffs /rom 1
|
||||
}
|
||||
|
||||
boot_hook_add no_fo no_fo_pivot
|
||||
13
package/base-files/files/lib/firstboot/30_reset_copy_rom
Normal file
13
package/base-files/files/lib/firstboot/30_reset_copy_rom
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
reset_copy_rom() {
|
||||
[ "$reset_has_fo" != "true" ] && {
|
||||
dupe $jffs $rom
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
boot_hook_add jffs2reset reset_copy_rom
|
||||
15
package/base-files/files/lib/firstboot/40_copy_ramoverlay
Normal file
15
package/base-files/files/lib/firstboot/40_copy_ramoverlay
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
copy_ramoverlay() {
|
||||
# try to avoid fs changing while copying
|
||||
mount -o remount,ro none / 2>&-
|
||||
# copy ramoverlay to jffs2
|
||||
echo -n "copying files ... "
|
||||
cp -a /tmp/root/* /rom/jffs 2>&-
|
||||
echo "done"
|
||||
}
|
||||
|
||||
boot_hook_add switch2jffs copy_ramoverlay
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
no_fo_copy_ramoverlay() {
|
||||
# copy ramoverlay to jffs2, must be done after switching
|
||||
# to the new rootfs to avoid creating opaque directories
|
||||
echo -n "copying files ... "
|
||||
cp -a /tmp/root/* / >/dev/null 2>&1
|
||||
sync
|
||||
}
|
||||
|
||||
boot_hook_add no_fo no_fo_ramoverlay
|
||||
17
package/base-files/files/lib/firstboot/50_pivot
Normal file
17
package/base-files/files/lib/firstboot/50_pivot
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
with_fo_pivot() {
|
||||
# switch back to squashfs (temporarily)
|
||||
# and park the ramdisk ontop of /tmp/root
|
||||
pivot /rom /mnt
|
||||
mount -o move /mnt /tmp/root
|
||||
|
||||
# /jffs is the overlay
|
||||
# /rom is the readonly
|
||||
fopivot /jffs /rom
|
||||
}
|
||||
|
||||
boot_hook_add switch2jffs with_fo_pivot
|
||||
13
package/base-files/files/lib/firstboot/99_10_no_fo_cleanup
Normal file
13
package/base-files/files/lib/firstboot/99_10_no_fo_cleanup
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
no_fo_cleanup() {
|
||||
echo "done"
|
||||
umount -l /jffs
|
||||
umount -l /tmp/root
|
||||
exit 0
|
||||
}
|
||||
|
||||
boot_hook_add no_fo no_fo_cleanup
|
||||
13
package/base-files/files/lib/firstboot/99_10_with_fo_cleanup
Normal file
13
package/base-files/files/lib/firstboot/99_10_with_fo_cleanup
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/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
|
||||
mount /tmp/root 2>&-
|
||||
exit 0
|
||||
}
|
||||
|
||||
boot_hook_add switch2jffs with_fo_cleanup
|
||||
Reference in New Issue
Block a user