github.com/cvmfs/docker-graphdriver@v0.0.0-20181206110523-155ec6df0521/plugins/entrypoint.sh (about) 1 #!/bin/sh 2 3 PLUGINS_DIR="/usr/bin" 4 DRIVER_GUARD="/driver" 5 6 test_unionfs() { 7 driver=$1 8 cat /proc/filesystems | grep $driver > /dev/null 9 } 10 11 load_unionfs() { 12 driver=$1 13 modprobe $driver > /dev/null 14 } 15 16 run_binary() { 17 driver=$1 18 19 if [ -f $DRIVER_GUARD ]; then 20 if [ x"$(cat $DRIVER_GUARD)" != x"$driver" ]; then 21 echo "This plugin was used with driver $(cat $DRIVER_GUARD) before." 22 echo "Cannot switch to $driver, exiting" 23 return 1 24 fi 25 fi 26 27 echo "runing binary: $driver" 28 echo "$driver" > $DRIVER_GUARD 29 30 if [ x"$driver" == x"overlay" ]; then 31 exec $PLUGINS_DIR/overlay2_cvmfs 32 elif [ x"$driver" == x"aufs" ]; then 33 exec $PLUGINS_DIR/aufs_cvmfs 34 fi 35 } 36 37 fail() { 38 echo "ERROR: aufs and overlayfs modules not available!" 39 exit 1 40 } 41 42 start_plugin() { 43 driver=$1 44 (test_unionfs $driver || load_unionfs $driver) && run_binary $driver 45 } 46 47 init_config() { 48 cp -a /cvmfs_ext_config/* /etc/cvmfs/ 49 } 50 51 init_config 52 if uname -r | grep cernvm; then 53 start_plugin "aufs" || fail 54 fi 55 start_plugin "overlay" || start_plugin "aufs" || fail