summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh')
-rw-r--r--meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh b/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh
new file mode 100644
index 0000000..1a0328d
--- /dev/null
+++ b/meta/recipes-core/initscripts/initscripts-1.0/read-only-rootfs-hook.sh
@@ -0,0 +1,38 @@
1#!/bin/sh
2
3. /etc/default/rcS
4
5[ "$ROOTFS_READ_ONLY" = "no" ] && exit 0
6
7is_on_read_only_partition () {
8 DIRECTORY=$1
9 dir=`readlink -f $DIRECTORY`
10 while true; do
11 if [ ! -d "$dir" ]; then
12 echo "ERROR: $dir is not a directory"
13 exit 1
14 else
15 for flag in `awk -v dir=$dir '{ if ($2 == dir) { print "FOUND"; split($4,FLAGS,",") } }; \
16 END { for (f in FLAGS) print FLAGS[f] }' < /proc/mounts`; do
17 [ "$flag" = "FOUND" ] && partition="read-write"
18 [ "$flag" = "ro" ] && { partition="read-only"; break; }
19 done
20 if [ "$dir" = "/" -o -n "$partition" ]; then
21 break
22 else
23 dir=`dirname $dir`
24 fi
25 fi
26 done
27 [ "$partition" = "read-only" ] && echo "yes" || echo "no"
28}
29
30if [ "$1" = "start" ] ; then
31 if [ `is_on_read_only_partition /var/lib` = "yes" ]; then
32 grep -q "tmpfs /var/volatile" /proc/mounts || mount /var/volatile
33 mkdir -p /var/volatile/lib
34 cp -a /var/lib/* /var/volatile/lib
35 mount --bind /var/volatile/lib /var/lib
36 fi
37fi
38