|
308 | 308 | for cvmfs_repo in "${REPOSITORIES[@]}" |
309 | 309 | do |
310 | 310 | # split into name and access mode if ',access=' in $cvmfs_repo |
311 | | - if [[ ${cvmfs_repo} == *",access="* ]] ; then |
312 | | - cvmfs_repo_name=${cvmfs_repo/,access=*/} # remove access mode specification |
| 311 | + if [[ ${cvmfs_repo} == *","* ]] ; then |
| 312 | + cvmfs_repo_name=${cvmfs_repo/,*/} # remove access mode specification |
313 | 313 | else |
314 | 314 | cvmfs_repo_name="${cvmfs_repo}" |
315 | 315 | fi |
|
322 | 322 | declare -A listed_repos=() |
323 | 323 | for cvmfs_repo in "${REPOSITORIES[@]}" |
324 | 324 | do |
325 | | - cvmfs_repo_name=${cvmfs_repo/,access=*/} # remove access mode |
| 325 | + cvmfs_repo_name=${cvmfs_repo/,*/} # remove access mode |
326 | 326 | [[ ${VERBOSE} -eq 1 ]] && echo "checking for duplicates: '${cvmfs_repo}' and '${cvmfs_repo_name}'" |
327 | 327 | # if cvmfs_repo_name is not in eessi_cvmfs_repos, assume it's in cfg_cvmfs_repos |
328 | 328 | # and obtain actual repo_name from config |
|
748 | 748 | unset cfg_repo_id |
749 | 749 | [[ ${VERBOSE} -eq 1 ]] && echo "add fusemount options for CVMFS repo '${cvmfs_repo}'" |
750 | 750 | # split into name and access mode if ',access=' in $cvmfs_repo |
751 | | - if [[ ${cvmfs_repo} == *",access="* ]] ; then |
752 | | - cvmfs_repo_name=${cvmfs_repo/,access=*/} # remove access mode specification |
753 | | - cvmfs_repo_access=${cvmfs_repo/*,access=/} # remove repo name part |
754 | | - else |
755 | | - cvmfs_repo_name="${cvmfs_repo}" |
756 | | - cvmfs_repo_access="${ACCESS}" # use globally defined access mode |
757 | | - fi |
| 751 | + #IFS=',' read -r -a array <<< "$cvmfs_repo" |
| 752 | + readarray -td, cvmfs_repo_args <<<"$cvmfs_repo" |
| 753 | + cvmfs_repo_name=${cvmfs_repo_args[0]} |
| 754 | + cvmfs_repo_access="${ACCESS}" |
| 755 | + cvmfs_repo_mount="fuse" |
| 756 | + for arg in ${cvmfs_repo_args[@]:1}; do |
| 757 | + if [[ $arg == "access="* ]]; then |
| 758 | + cvmfs_repo_access=${arg/access=} |
| 759 | + fi |
| 760 | + if [[ $arg == "mount="* ]]; then |
| 761 | + cvmfs_repo_mount=${arg/mount=} |
| 762 | + fi |
| 763 | + done |
| 764 | + |
758 | 765 | # obtain cvmfs_repo_name from EESSI_REPOS_CFG_FILE if cvmfs_repo is in cfg_cvmfs_repos |
759 | 766 | if [[ ${cfg_cvmfs_repos[${cvmfs_repo_name}]} ]]; then |
760 | 767 | [[ ${VERBOSE} -eq 1 ]] && echo "repo '${cvmfs_repo_name}' is not an EESSI CVMFS repository..." |
|
769 | 776 | # always create a directory for the repository (e.g., to store settings, ...) |
770 | 777 | mkdir -p ${EESSI_TMPDIR}/${cvmfs_repo_name} |
771 | 778 |
|
772 | | - # add fusemount options depending on requested access mode ('ro' - read-only; 'rw' - read & write) |
773 | | - if [[ ${cvmfs_repo_access} == "ro" ]] ; then |
774 | | - # need to distinguish between basic "ro" access and "ro" after a "rw" session |
775 | | - if [[ -d ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper ]]; then |
776 | | - # the overlay-upper directory is only created in a read-write-session, thus |
777 | | - # we are resuming from such a session here (otherwise there shouldn't be such |
778 | | - # directory yet as it is only created for read-write-sessions a bit further |
779 | | - # below); the overlay-upper directory can only exist because it is part of |
780 | | - # the ${RESUME} directory or tarball |
781 | | - # to be able to see the contents of the read-write session we have to mount |
782 | | - # the fuse-overlayfs (in read-only mode) on top of the CernVM-FS repository |
783 | | - |
784 | | - echo "While processing '${cvmfs_repo_name}' to be mounted 'read-only' we detected an overlay-upper" |
785 | | - echo " directory (${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper) likely from a previous" |
786 | | - echo " session. Will use it as left-most directory in 'lowerdir' argument for fuse-overlayfs." |
787 | | - |
788 | | - # make the target CernVM-FS repository available under /cvmfs_ro |
| 779 | + if [[ ${cvmfs_repo_mount} == "fuse" ]]; then |
| 780 | + # add fusemount options depending on requested access mode ('ro' - read-only; 'rw' - read & write) |
| 781 | + if [[ ${cvmfs_repo_access} == "ro" ]] ; then |
| 782 | + # need to distinguish between basic "ro" access and "ro" after a "rw" session |
| 783 | + if [[ -d ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper ]]; then |
| 784 | + # the overlay-upper directory is only created in a read-write-session, thus |
| 785 | + # we are resuming from such a session here (otherwise there shouldn't be such |
| 786 | + # directory yet as it is only created for read-write-sessions a bit further |
| 787 | + # below); the overlay-upper directory can only exist because it is part of |
| 788 | + # the ${RESUME} directory or tarball |
| 789 | + # to be able to see the contents of the read-write session we have to mount |
| 790 | + # the fuse-overlayfs (in read-only mode) on top of the CernVM-FS repository |
| 791 | + |
| 792 | + echo "While processing '${cvmfs_repo_name}' to be mounted 'read-only' we detected an overlay-upper" |
| 793 | + echo " directory (${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper) likely from a previous" |
| 794 | + echo " session. Will use it as left-most directory in 'lowerdir' argument for fuse-overlayfs." |
| 795 | + |
| 796 | + # make the target CernVM-FS repository available under /cvmfs_ro |
| 797 | + export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name}" |
| 798 | + |
| 799 | + EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") |
| 800 | + |
| 801 | + # now, put the overlay-upper read-only on top of the repo and make it available under the usual prefix /cvmfs |
| 802 | + EESSI_READONLY_OVERLAY="container:fuse-overlayfs" |
| 803 | + # The contents of the previous session are available under |
| 804 | + # ${EESSI_TMPDIR} which is bind mounted to ${TMP_IN_CONTAINER}. |
| 805 | + # Hence, we have to use ${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper |
| 806 | + # the left-most directory given for the lowerdir argument is put on top, |
| 807 | + # and with no upperdir=... the whole overlayfs is made available read-only |
| 808 | + EESSI_READONLY_OVERLAY+=" -o lowerdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper:/cvmfs_ro/${cvmfs_repo_name}" |
| 809 | + EESSI_READONLY_OVERLAY+=" /cvmfs/${cvmfs_repo_name}" |
| 810 | + export EESSI_READONLY_OVERLAY |
| 811 | + |
| 812 | + EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY_OVERLAY}") |
| 813 | + export EESSI_FUSE_MOUNTS |
| 814 | + else |
| 815 | + # basic "ro" access that doesn't require any fuseoverlay-fs |
| 816 | + echo "Mounting '${cvmfs_repo_name}' 'read-only' without fuse-overlayfs." |
| 817 | + |
| 818 | + export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs/${cvmfs_repo_name}" |
| 819 | + |
| 820 | + EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") |
| 821 | + export EESSI_FUSE_MOUNTS |
| 822 | + fi |
| 823 | + elif [[ ${cvmfs_repo_access} == "rw" ]] ; then |
| 824 | + # use repo-specific overlay directories |
| 825 | + mkdir -p ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper${EESSI_DEV_PROJECT:+/$EESSI_DEV_PROJECT} |
| 826 | + mkdir -p ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-work${EESSI_DEV_PROJECT:+/$EESSI_DEV_PROJECT} |
| 827 | + |
| 828 | + [[ ${VERBOSE} -eq 1 ]] && echo -e "TMP directory contents:\n$(ls -l ${EESSI_TMPDIR})" |
| 829 | + |
| 830 | + # set environment variables for fuse mounts in Singularity container |
789 | 831 | export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name}" |
790 | 832 |
|
791 | 833 | EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") |
792 | 834 |
|
793 | | - # now, put the overlay-upper read-only on top of the repo and make it available under the usual prefix /cvmfs |
794 | | - EESSI_READONLY_OVERLAY="container:fuse-overlayfs" |
795 | | - # The contents of the previous session are available under |
796 | | - # ${EESSI_TMPDIR} which is bind mounted to ${TMP_IN_CONTAINER}. |
797 | | - # Hence, we have to use ${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper |
798 | | - # the left-most directory given for the lowerdir argument is put on top, |
799 | | - # and with no upperdir=... the whole overlayfs is made available read-only |
800 | | - EESSI_READONLY_OVERLAY+=" -o lowerdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper:/cvmfs_ro/${cvmfs_repo_name}" |
801 | | - EESSI_READONLY_OVERLAY+=" /cvmfs/${cvmfs_repo_name}" |
802 | | - export EESSI_READONLY_OVERLAY |
803 | | - |
804 | | - EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY_OVERLAY}") |
805 | | - export EESSI_FUSE_MOUNTS |
806 | | - else |
807 | | - # basic "ro" access that doesn't require any fuseoverlay-fs |
808 | | - echo "Mounting '${cvmfs_repo_name}' 'read-only' without fuse-overlayfs." |
| 835 | + EESSI_WRITABLE_OVERLAY="container:fuse-overlayfs" |
| 836 | + EESSI_WRITABLE_OVERLAY+=" -o lowerdir=/cvmfs_ro/${cvmfs_repo_name}" |
| 837 | + EESSI_WRITABLE_OVERLAY+=" -o upperdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper" |
| 838 | + EESSI_WRITABLE_OVERLAY+=" -o workdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-work" |
| 839 | + EESSI_WRITABLE_OVERLAY+=" /cvmfs/${cvmfs_repo_name}" |
| 840 | + export EESSI_WRITABLE_OVERLAY |
809 | 841 |
|
810 | | - export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs/${cvmfs_repo_name}" |
811 | | - |
812 | | - EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") |
| 842 | + EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_WRITABLE_OVERLAY}") |
813 | 843 | export EESSI_FUSE_MOUNTS |
| 844 | + else |
| 845 | + echo -e "ERROR: access mode '${cvmfs_repo_access}' for CVMFS repository\n '${cvmfs_repo_name}' is not known" |
| 846 | + exit ${REPOSITORY_ERROR_EXITCODE} |
814 | 847 | fi |
815 | | - elif [[ ${cvmfs_repo_access} == "rw" ]] ; then |
816 | | - # use repo-specific overlay directories |
817 | | - mkdir -p ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-upper${EESSI_DEV_PROJECT:+/$EESSI_DEV_PROJECT} |
818 | | - mkdir -p ${EESSI_TMPDIR}/${cvmfs_repo_name}/overlay-work${EESSI_DEV_PROJECT:+/$EESSI_DEV_PROJECT} |
819 | | - |
820 | | - [[ ${VERBOSE} -eq 1 ]] && echo -e "TMP directory contents:\n$(ls -l ${EESSI_TMPDIR})" |
821 | | - |
822 | | - # set environment variables for fuse mounts in Singularity container |
823 | | - export EESSI_READONLY="container:cvmfs2 ${cvmfs_repo_name} /cvmfs_ro/${cvmfs_repo_name}" |
824 | | - |
825 | | - EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_READONLY}") |
826 | | - |
827 | | - EESSI_WRITABLE_OVERLAY="container:fuse-overlayfs" |
828 | | - EESSI_WRITABLE_OVERLAY+=" -o lowerdir=/cvmfs_ro/${cvmfs_repo_name}" |
829 | | - EESSI_WRITABLE_OVERLAY+=" -o upperdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-upper" |
830 | | - EESSI_WRITABLE_OVERLAY+=" -o workdir=${TMP_IN_CONTAINER}/${cvmfs_repo_name}/overlay-work" |
831 | | - EESSI_WRITABLE_OVERLAY+=" /cvmfs/${cvmfs_repo_name}" |
832 | | - export EESSI_WRITABLE_OVERLAY |
833 | | - |
834 | | - EESSI_FUSE_MOUNTS+=("--fusemount" "${EESSI_WRITABLE_OVERLAY}") |
835 | | - export EESSI_FUSE_MOUNTS |
| 848 | + elif [[ ${cvmfs_repo_mount} == "bind" ]]; then |
| 849 | + BIND_PATHS="/cvmfs/${cvmfs_repo_name},${BIND_PATHS}" |
836 | 850 | else |
837 | | - echo -e "ERROR: access mode '${cvmfs_repo_access}' for CVMFS repository\n '${cvmfs_repo_name}' is not known" |
| 851 | + echo -e "ERROR: mount type '${cvmfs_repo_mount}' for CVMFS repository\n '${cvmfs_repo_name}' is not known" |
838 | 852 | exit ${REPOSITORY_ERROR_EXITCODE} |
839 | 853 | fi |
| 854 | + |
840 | 855 | # create repo_settings.sh file in ${EESSI_TMPDIR}/${cvmfs_repo_name} to store |
841 | 856 | # (intention is that the file could be just sourced to obtain the settings) |
842 | 857 | # repo_name = ${cvmfs_repo_name} |
|
848 | 863 | settings="${settings}repo_name = ${cvmfs_repo_name}\n" |
849 | 864 | settings="${settings}repo_id = ${cfg_repo_id}\n" |
850 | 865 | settings="${settings}repo_access = ${cvmfs_repo_access}\n" |
| 866 | + settings="${settings}repo_mount = ${cvmfs_repo_mount}\n" |
851 | 867 | # TODO iterate over host_injections (first need means to define them (globally and/or per repository) |
852 | 868 | # settings="${settings}repo_host_injections = ${host_injections}\n" |
853 | 869 | echo -e "${settings}" > ${EESSI_TMPDIR}/${cvmfs_repo_name}/repo_settings.sh |
|
0 commit comments