diff options
Diffstat (limited to 'package/base-files/files/lib/firstboot')
31 files changed, 1028 insertions, 0 deletions
diff --git a/package/base-files/files/lib/firstboot/.svn/entries b/package/base-files/files/lib/firstboot/.svn/entries new file mode 100644 index 0000000..4faa8cf --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/entries @@ -0,0 +1,538 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/firstboot +svn://svn.openwrt.org/openwrt + + + +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +30_no_fo_pivot +file + + + + +2013-03-17T12:13:21.000000Z +05dcf8be4db74ee8bf91ec6cc9290a8c +2010-03-21T17:16:50.184472Z +20356 +florian + + + + + + + + + + + + + + + + + + + + + +212 + +10_determine_parts +file + + + + +2013-03-17T12:13:21.000000Z +7f4e5a91337ee98efcaf044da7a46ea0 +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +932 + +99_10_with_fo_cleanup +file + + + + +2013-03-17T12:13:21.000000Z +933a1c84006796789185495083cfe600 +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + + + + + + + + +501 + +99_10_no_fo_cleanup +file + + + + +2013-03-17T12:13:21.000000Z +13db248c34fa69a6b000921a1e76da9e +2010-03-21T17:16:50.184472Z +20356 +florian + + + + + + + + + + + + + + + + + + + + + +224 + +30_reset_copy_rom +file + + + + +2013-03-17T12:13:21.000000Z +c906820b468d1bc036969053ecc84e2a +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +228 + +20_no_fo_mount_jffs +file + + + + +2013-03-17T12:13:21.000000Z +93874189d29461ca4c5538a9c8281f1f +2012-12-19T16:07:46.450520Z +34792 +mirko + + + + + + + + + + + + + + + + + + + + + +332 + +40_no_fo_copy_ramoverlay +file + + + + +2013-03-17T12:13:21.000000Z +ccce2620aa1dafc38d4a3831b32f65f7 +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +365 + +20_reset_clear_jffs +file + + + + +2013-03-17T12:13:21.000000Z +8dfe331ce8ca348071cecfe496c58dfe +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +287 + +30_is_rootfs_mounted +file + + + + +2013-03-17T12:13:21.000000Z +066662c53f60a607cbaba59c235586cf +2012-12-19T16:07:46.450520Z +34792 +mirko + + + + + + + + + + + + + + + + + + + + + +236 + +50_pivot +file + + + + +2013-03-17T12:13:21.000000Z +287023c3965c0a0c060dcb974c56e4f7 +2010-03-21T17:16:50.184472Z +20356 +florian + + + + + + + + + + + + + + + + + + + + + +383 + +05_firstboot_skip +file + + + + +2013-03-17T12:13:21.000000Z +3e218d08ebd04fa51c73d6a0bbce0361 +2012-04-27T16:49:16.916618Z +31492 +florian + + + + + + + + + + + + + + + + + + + + + +115 + +10_no_fo_clear_overlay +file + + + + +2013-03-17T12:13:21.000000Z +6bf3c0e457e23f335337ea54e566fd4e +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +356 + +20_has_mini_fo +file + + + + +2013-03-17T12:13:21.000000Z +8f0c67354bd0b422d58579d6cb10b25d +2011-03-17T19:09:39.292493Z +26207 +nbd + + + + + + + + + + + + + + + + + + + + + +262 + +10_reset_has_mini_fo +file + + + + +2013-03-17T12:13:21.000000Z +5e47572006d901d63617729a6a35fb5b +2011-03-17T19:09:39.292493Z +26207 +nbd + + + + + + + + + + + + + + + + + + + + + +261 + +40_copy_ramoverlay +file + + + + +2013-03-17T12:13:21.000000Z +8f418a269c3912825daae204264a8f9b +2010-03-21T17:16:50.184472Z +20356 +florian + + + + + + + + + + + + + + + + + + + + + +361 + diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base new file mode 100644 index 0000000..5f44df6 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base @@ -0,0 +1,10 @@ +#!/bin/sh + +check_skip() { + if [ "$firstboot_skip_next" = "true" ]; then + return 0 + else + return 1 + fi +} + diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base new file mode 100644 index 0000000..3f56e32 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base @@ -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 diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base new file mode 100644 index 0000000..8a7d9b0 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base @@ -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 diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base new file mode 100644 index 0000000..4e28584 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base @@ -0,0 +1,12 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +reset_check_for_overlay() { + if grep -qE '(mini_fo|overlay)' /proc/filesystems; then + reset_has_fo=true + fi +} + +boot_hook_add jffs2reset reset_check_for_overlay diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base new file mode 100644 index 0000000..8ca6a4f --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +check_for_overlay() { + if ! grep -qE '(mini_fo|overlay)' /proc/filesystems; then + boot_run_hook no_fo + exit 1 + fi +} + +boot_hook_add switch2jffs check_for_overlay diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base new file mode 100644 index 0000000..c03714f --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base @@ -0,0 +1,15 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_mount_jffs() { + # initialize jffs2 + mount -o noatime "$mtdpart" /overlay -t jffs2 || exit + + # workaround to ensure that union can attach properly + sync + ls /overlay >/dev/null +} + +boot_hook_add no_fo no_fo_mount_jffs diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base new file mode 100644 index 0000000..a3cd24f --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base @@ -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 diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base new file mode 100644 index 0000000..7233fd9 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base @@ -0,0 +1,10 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +skip_if_rootfs_mounted() { + mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit +} + +boot_hook_add switch2jffs skip_if_rootfs_mounted diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base new file mode 100644 index 0000000..b5c2601 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base @@ -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 /overlay /rom 1 +} + +boot_hook_add no_fo no_fo_pivot diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base new file mode 100644 index 0000000..d91c689 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base @@ -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 diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base new file mode 100644 index 0000000..39c2eda --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base @@ -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/overlay 2>&- + echo "done" +} + +boot_hook_add switch2jffs copy_ramoverlay diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base new file mode 100644 index 0000000..ced7c1b --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base @@ -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 diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base new file mode 100644 index 0000000..53801d7 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base @@ -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 + + # /overlay is the overlay + # /rom is the readonly + fopivot /overlay /rom +} + +boot_hook_add switch2jffs with_fo_pivot diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base new file mode 100644 index 0000000..6dedcb1 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_cleanup() { + echo "done" + umount -l /overlay + umount -l /tmp/root + exit 0 +} + +boot_hook_add no_fo no_fo_cleanup diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base new file mode 100644 index 0000000..5601699 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base @@ -0,0 +1,25 @@ +#!/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 diff --git a/package/base-files/files/lib/firstboot/05_firstboot_skip b/package/base-files/files/lib/firstboot/05_firstboot_skip new file mode 100644 index 0000000..5f44df6 --- /dev/null +++ b/package/base-files/files/lib/firstboot/05_firstboot_skip @@ -0,0 +1,10 @@ +#!/bin/sh + +check_skip() { + if [ "$firstboot_skip_next" = "true" ]; then + return 0 + else + return 1 + fi +} + diff --git a/package/base-files/files/lib/firstboot/10_determine_parts b/package/base-files/files/lib/firstboot/10_determine_parts new file mode 100644 index 0000000..3f56e32 --- /dev/null +++ b/package/base-files/files/lib/firstboot/10_determine_parts @@ -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 diff --git a/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay b/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay new file mode 100644 index 0000000..8a7d9b0 --- /dev/null +++ b/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay @@ -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 diff --git a/package/base-files/files/lib/firstboot/10_reset_has_mini_fo b/package/base-files/files/lib/firstboot/10_reset_has_mini_fo new file mode 100644 index 0000000..4e28584 --- /dev/null +++ b/package/base-files/files/lib/firstboot/10_reset_has_mini_fo @@ -0,0 +1,12 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +reset_check_for_overlay() { + if grep -qE '(mini_fo|overlay)' /proc/filesystems; then + reset_has_fo=true + fi +} + +boot_hook_add jffs2reset reset_check_for_overlay diff --git a/package/base-files/files/lib/firstboot/20_has_mini_fo b/package/base-files/files/lib/firstboot/20_has_mini_fo new file mode 100644 index 0000000..8ca6a4f --- /dev/null +++ b/package/base-files/files/lib/firstboot/20_has_mini_fo @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +check_for_overlay() { + if ! grep -qE '(mini_fo|overlay)' /proc/filesystems; then + boot_run_hook no_fo + exit 1 + fi +} + +boot_hook_add switch2jffs check_for_overlay diff --git a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs new file mode 100644 index 0000000..c03714f --- /dev/null +++ b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs @@ -0,0 +1,15 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_mount_jffs() { + # initialize jffs2 + mount -o noatime "$mtdpart" /overlay -t jffs2 || exit + + # workaround to ensure that union can attach properly + sync + ls /overlay >/dev/null +} + +boot_hook_add no_fo no_fo_mount_jffs diff --git a/package/base-files/files/lib/firstboot/20_reset_clear_jffs b/package/base-files/files/lib/firstboot/20_reset_clear_jffs new file mode 100644 index 0000000..a3cd24f --- /dev/null +++ b/package/base-files/files/lib/firstboot/20_reset_clear_jffs @@ -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 diff --git a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted new file mode 100644 index 0000000..7233fd9 --- /dev/null +++ b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted @@ -0,0 +1,10 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +skip_if_rootfs_mounted() { + mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit +} + +boot_hook_add switch2jffs skip_if_rootfs_mounted diff --git a/package/base-files/files/lib/firstboot/30_no_fo_pivot b/package/base-files/files/lib/firstboot/30_no_fo_pivot new file mode 100644 index 0000000..b5c2601 --- /dev/null +++ b/package/base-files/files/lib/firstboot/30_no_fo_pivot @@ -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 /overlay /rom 1 +} + +boot_hook_add no_fo no_fo_pivot diff --git a/package/base-files/files/lib/firstboot/30_reset_copy_rom b/package/base-files/files/lib/firstboot/30_reset_copy_rom new file mode 100644 index 0000000..d91c689 --- /dev/null +++ b/package/base-files/files/lib/firstboot/30_reset_copy_rom @@ -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 diff --git a/package/base-files/files/lib/firstboot/40_copy_ramoverlay b/package/base-files/files/lib/firstboot/40_copy_ramoverlay new file mode 100644 index 0000000..39c2eda --- /dev/null +++ b/package/base-files/files/lib/firstboot/40_copy_ramoverlay @@ -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/overlay 2>&- + echo "done" +} + +boot_hook_add switch2jffs copy_ramoverlay diff --git a/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay b/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay new file mode 100644 index 0000000..ced7c1b --- /dev/null +++ b/package/base-files/files/lib/firstboot/40_no_fo_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 diff --git a/package/base-files/files/lib/firstboot/50_pivot b/package/base-files/files/lib/firstboot/50_pivot new file mode 100644 index 0000000..53801d7 --- /dev/null +++ b/package/base-files/files/lib/firstboot/50_pivot @@ -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 + + # /overlay is the overlay + # /rom is the readonly + fopivot /overlay /rom +} + +boot_hook_add switch2jffs with_fo_pivot diff --git a/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup new file mode 100644 index 0000000..6dedcb1 --- /dev/null +++ b/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_cleanup() { + echo "done" + umount -l /overlay + umount -l /tmp/root + exit 0 +} + +boot_hook_add no_fo no_fo_cleanup diff --git a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup new file mode 100644 index 0000000..5601699 --- /dev/null +++ b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup @@ -0,0 +1,25 @@ +#!/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 |