@@ -97,8 +97,8 @@ display_help() {
9797 echo " container; can be given multiple times [default: not set]"
9898 echo " -r | --repository CFG - configuration file or identifier defining the"
9999 echo " repository to use; can be given multiple times;"
100- echo " CFG may include a suffix ',access={ro,rw}' to"
101- echo " overwrite the global access mode for this repository"
100+ echo " CFG may include suffixes ',access={ro,rw},mode={bind,fuse }' to"
101+ echo " overwrite the global access and/or mount mode for this repository"
102102 echo " [default: software.eessi.io via CVMFS config available"
103103 echo " via default container, see --container]"
104104 echo " -u | --resume DIR/TGZ - resume a previous run from a directory or tarball,"
@@ -756,14 +756,40 @@ for cvmfs_repo in "${REPOSITORIES[@]}"
756756do
757757 unset cfg_repo_id
758758 [[ ${VERBOSE} -eq 1 ]] && echo " add fusemount options for CVMFS repo '${cvmfs_repo} '"
759- # split into name and access mode if ',access=' in $cvmfs_repo
760- if [[ ${cvmfs_repo} == * " ,access=" * ]] ; then
761- cvmfs_repo_name=${cvmfs_repo/ ,access=*/ } # remove access mode specification
762- cvmfs_repo_access=${cvmfs_repo/* ,access=/ } # remove repo name part
763- else
764- cvmfs_repo_name=" ${cvmfs_repo} "
765- cvmfs_repo_access=" ${ACCESS} " # use globally defined access mode
759+ # split into name, access mode, and mount mode
760+ readarray -td, cvmfs_repo_args <<< " $cvmfs_repo"
761+ cvmfs_repo_name=${cvmfs_repo_args[0]}
762+ cvmfs_repo_access=" ${ACCESS} " # initialize to the default access mode
763+ for arg in ${cvmfs_repo_args[@]: 1} ; do
764+ if [[ $arg == " access=" * ]]; then
765+ cvmfs_repo_access=${arg/ access=}
766+ fi
767+ if [[ $arg == " mount=" * ]]; then
768+ cvmfs_repo_mount=${arg/ mount=}
769+ # check if the specified mount mode is a valid one
770+ if [[ ${cvmfs_repo_mount} != " bind" ]] && [[ ${cvmfs_repo_mount} != " fuse" ]]; then
771+ echo -e " ERROR: mount mode '${cvmfs_repo_mount} ' for CVMFS repository\n '${cvmfs_repo_name} ' is not known"
772+ exit ${REPOSITORY_ERROR_EXITCODE}
773+ fi
774+ fi
775+ done
776+ # if a mount mode was not specified, we use a bind mount if the repository is available on the host,
777+ # and otherwise we use a fuse mount
778+ if [[ -z ${cvmfs_repo_mount} ]]; then
779+ cvmfs_repo_mount=" fuse"
780+ if [[ -x $( command -v cvmfs_config) ]] && cvmfs_config probe ${cvmfs_repo_name} >& /dev/null; then
781+ cvmfs_repo_mount=" bind"
782+ fi
783+ fi
784+ [[ ${VERBOSE} -eq 1 ]] && echo " Using a ${cvmfs_repo_mount} mount for /cvmfs/${cvmfs_repo_name} "
785+ # if a bind mount was requested, check if the repository is really available on the host
786+ if [[ ${cvmfs_repo_mount} == " bind" ]]; then
787+ if [[ ! -x $( command -v cvmfs_config) ]] || ! cvmfs_config probe ${cvmfs_repo_name} >& /dev/null; then
788+ echo -e " ERROR: bind mount requested for CVMFS repository\n '${cvmfs_repo_name} ', but it cannot be probed on the host"
789+ exit ${REPOSITORY_ERROR_EXITCODE}
790+ fi
766791 fi
792+
767793 # obtain cvmfs_repo_name from EESSI_REPOS_CFG_FILE if cvmfs_repo is in cfg_cvmfs_repos
768794 if [[ ${cfg_cvmfs_repos[${cvmfs_repo_name}]} ]]; then
769795 [[ ${VERBOSE} -eq 1 ]] && echo " repo '${cvmfs_repo_name} ' is not an EESSI CVMFS repository..."
795821 echo " session. Will use it as left-most directory in 'lowerdir' argument for fuse-overlayfs."
796822
797823 # make the target CernVM-FS repository available under /cvmfs_ro
798- export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name} "
799-
800- EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
824+ if [[ ${cvmfs_repo_mount} == " fuse" ]]; then
825+ export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name} "
826+ EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
827+ elif [[ ${cvmfs_repo_mount} == " bind" ]]; then
828+ BIND_PATHS=" /cvmfs/${cvmfs_repo_name} :/cvmfs_ro/${cvmfs_repo_name} ,${BIND_PATHS} "
829+ fi
801830
802831 # now, put the overlay-upper read-only on top of the repo and make it available under the usual prefix /cvmfs
803832 if [[ " ${OVERLAY_TOOL} " == " fuse-overlayfs" ]]; then
827856 # basic "ro" access that doesn't require any fuseoverlay-fs
828857 echo " Mounting '${cvmfs_repo_name} ' 'read-only' without fuse-overlayfs."
829858
830- export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs/${cvmfs_repo_name} "
859+ if [[ ${cvmfs_repo_mount} == " fuse" ]]; then
860+ export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs/${cvmfs_repo_name} "
861+ EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
862+ export EESSI_FUSE_MOUNTS
863+ elif [[ ${cvmfs_repo_mount} == " bind" ]]; then
864+ BIND_PATHS=" /cvmfs/${cvmfs_repo_name} ,${BIND_PATHS} "
865+ fi
831866
832- EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
833- export EESSI_FUSE_MOUNTS
834867 fi
835868 elif [[ ${cvmfs_repo_access} == " rw" ]] ; then
836869 # use repo-specific overlay directories
840873 [[ ${VERBOSE} -eq 1 ]] && echo -e " TMP directory contents:\n$( ls -l ${EESSI_TMPDIR} ) "
841874
842875 # set environment variables for fuse mounts in Singularity container
843- export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name} "
844-
845- EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
876+ if [[ ${cvmfs_repo_mount} == " fuse" ]]; then
877+ export EESSI_READONLY=" container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name} "
878+ EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
879+ elif [[ ${cvmfs_repo_mount} == " bind" ]]; then
880+ BIND_PATHS=" /cvmfs/${cvmfs_repo_name} :/cvmfs_ro/${cvmfs_repo_name} ,${BIND_PATHS} "
881+ fi
846882
847883 if [[ " ${OVERLAY_TOOL} " == " fuse-overlayfs" ]]; then
848884 EESSI_WRITABLE_OVERLAY=" container:fuse-overlayfs"
0 commit comments