Chen Qi db15e2d01c volatile-binds: add recipe
This recipe is designed to play a key role in a read-only rootfs
of systemd based systems. It generates service files from a template,
volatile-binds.service.in and the VOLATILE_BINDS variable.

By default, VOLATILE_BINDS takes the value of "/var/volatile/lib /var/lib\n",
which leads to the generation of volatile-var-lib.service file.
This file doesn't have any effect in a read-write system, as it
has "ConditionPathIsReadWrite = !/var/lib" in the [Unit] section.
In other words, this file only has effect in a read-only rootfs.

(From OE-Core rev: ed7d30dc0cdb6d6c56c50ac7a3440c4ed0ee70d3)

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-08-02 09:26:14 +01:00

35 lines
649 B
Bash
Executable File

#!/bin/sh
#
# Perform a bind mount, copying existing files as we do so to ensure the
# overlaid path has the necessary content.
if [ $# -lt 2 ]; then
echo >&2 "Usage: $0 spec mountpoint [OPTIONS]"
exit 1
fi
spec=$1
mountpoint=$2
if [ $# -gt 2 ]; then
options=$3
else
options=
fi
[ -n "$options" ] && options=",$options"
mkdir -p "${spec%/*}"
if [ -d "$mountpoint" ]; then
if [ ! -d "$spec" ]; then
mkdir "$spec"
cp -pPR "$mountpoint"/. "$spec/"
fi
elif [ -f "$mountpoint" ]; then
if [ ! -f "$spec" ]; then
cp -pP "$mountpoint" "$spec"
fi
fi
mount -o "bind$options" "$spec" "$mountpoint"