Created
March 29, 2015 22:00
-
-
Save spheromak/55b68d79976a066f4a05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
if [ -z "$BIND_MOUNTS" ] ; then | |
echo "No bindmounts in BIND_MOUNTS env var exiting" | |
exit 0 | |
fi | |
for path in ${BIND_MOUNTS[@]} ; do | |
# remove leading slash, convert other /'s to -'s | |
mnt=`echo $path | sed -e 's/^\///' | tr '\/' '-'` | |
if [ -d "$path" ] ; then | |
mv "$path" "/data/bindmount-$mnt" | |
else | |
mkdir -p "/data/bindmount-$mnt" | |
fi | |
mkdir -p "$path" | |
echo "/data/bindmount-$mnt $path none bind 0 0" | sudo tee -a /etc/fstab | |
mount "/$mnt" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment