@@ -97,8 +97,8 @@ display_help() {
97
97
echo " container; can be given multiple times [default: not set]"
98
98
echo " -r | --repository CFG - configuration file or identifier defining the"
99
99
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"
102
102
echo " [default: software.eessi.io via CVMFS config available"
103
103
echo " via default container, see --container]"
104
104
echo " -u | --resume DIR/TGZ - resume a previous run from a directory or tarball,"
@@ -756,14 +756,40 @@ for cvmfs_repo in "${REPOSITORIES[@]}"
756
756
do
757
757
unset cfg_repo_id
758
758
[[ ${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
766
791
fi
792
+
767
793
# obtain cvmfs_repo_name from EESSI_REPOS_CFG_FILE if cvmfs_repo is in cfg_cvmfs_repos
768
794
if [[ ${cfg_cvmfs_repos[${cvmfs_repo_name}]} ]]; then
769
795
[[ ${VERBOSE} -eq 1 ]] && echo " repo '${cvmfs_repo_name} ' is not an EESSI CVMFS repository..."
795
821
echo " session. Will use it as left-most directory in 'lowerdir' argument for fuse-overlayfs."
796
822
797
823
# 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
801
830
802
831
# now, put the overlay-upper read-only on top of the repo and make it available under the usual prefix /cvmfs
803
832
if [[ " ${OVERLAY_TOOL} " == " fuse-overlayfs" ]]; then
827
856
# basic "ro" access that doesn't require any fuseoverlay-fs
828
857
echo " Mounting '${cvmfs_repo_name} ' 'read-only' without fuse-overlayfs."
829
858
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
831
866
832
- EESSI_FUSE_MOUNTS+=(" --fusemount" " ${EESSI_READONLY} " )
833
- export EESSI_FUSE_MOUNTS
834
867
fi
835
868
elif [[ ${cvmfs_repo_access} == " rw" ]] ; then
836
869
# use repo-specific overlay directories
840
873
[[ ${VERBOSE} -eq 1 ]] && echo -e " TMP directory contents:\n$( ls -l ${EESSI_TMPDIR} ) "
841
874
842
875
# 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
846
882
847
883
if [[ " ${OVERLAY_TOOL} " == " fuse-overlayfs" ]]; then
848
884
EESSI_WRITABLE_OVERLAY=" container:fuse-overlayfs"
0 commit comments