Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 46 lines (40 sloc) 1.17 KB
#!/bin/sh
# minc-coat: MINC-container overlay attendant
#
# Copyright (C) 2015 Masami Hiramatsu <masami.hiramatsu@gmail.com>
# This program is released under the MIT License, see LICENSE.
set -e
test "$MINC_DEBUG" && set -x
# usage: minc-coat bind TMPDIR BASEDIR
# minc-coat unbind TMPDIR
CMD=$1
TMPDIR=$2
if [ $CMD = bind ]; then
BASEDIR=$3
# Check parameters
test -d $TMPDIR
test "$BASEDIR"
:
: 'Make working sub-directories'
: 'RD is mountpoint, UD is for upper layer, WD is working space'
:
RD=$TMPDIR/root
UD=$TMPDIR/storage
WD=$TMPDIR/work
mkdir -p $RD $UD $WD
if [ "$MINC_DIRECT" ]; then
:;: 'For direct mode, we just bind given dir to mountpoint';:
mount -o bind $BASEDIR $RD
else
:;: 'Mount overlayed root directory';:
if grep -wq overlay /proc/filesystems || ! grep -q overlay /proc/filesystems; then
mount -t overlay -o upperdir=$UD,lowerdir=$BASEDIR,workdir=$WD overlayfs $RD
else
:;: 'Workaround for ubuntu 14.10 (out-of-tree overlayfs)';:
mount -t overlayfs -o upperdir=$UD,lowerdir=$BASEDIR overlayfs $RD
fi
fi
elif [ $CMD = unbind ]; then
test -d $TMPDIR/root
mountpoint $TMPDIR/root > /dev/null && umount $TMPDIR/root || echo -n ""
fi
You can’t perform that action at this time.