summaryrefslogtreecommitdiff
path: root/scripts/overlay.sh
blob: 090671ceffb3945ffcff31017dedc7fe4d4daec2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

lower=/cfg/preserve/${1}
upper=/cfg/overlay/${1}
work=/cfg/overlay/${1}_work
target=${2}

if [ ! -d "$target" ]; then
	exit
fi

if [ -d "$lower" ]; then
	if [ -d "$upper" ]; then
		mkdir -p "$work"
		mount -t overlay overlay \
			-olowerdir=${lower},upperdir=${upper},workdir=${work} \
			${target}
	else
		mount --bind "$lower" "$target"
	fi
fi