49 lines
1.1 KiB
Bash
Executable File
49 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
P="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/run/current-system/sw/bin"
|
|
PL="/usr/sbin:/usr/bin:/sbin:/bin:/run/current-system/sw/bin"
|
|
|
|
container_supported_filesystems=(
|
|
"ext2"
|
|
"ext3"
|
|
"ext4"
|
|
"ext4dev"
|
|
"btrfs"
|
|
"xfs"
|
|
"vfat"
|
|
"nfs"
|
|
"nfs3"
|
|
"nfs4"
|
|
"cifs"
|
|
"smb"
|
|
"smb3"
|
|
"bind"
|
|
)
|
|
|
|
while getopts "t:" opt; do
|
|
case "$opt" in
|
|
t)
|
|
if [[ "x${USE_HOST_MOUNT_TOOLS}" == "x" ]]; then
|
|
[[ "${OPTARG,,}" == "zfs" ]] && USE_HOST_MOUNT_TOOLS=1
|
|
[[ "${OPTARG,,}" == "lustre" ]] && USE_HOST_MOUNT_TOOLS=1
|
|
[[ "${OPTARG,,}" == "onedata" ]] && USE_HOST_MOUNT_TOOLS=1
|
|
#(printf '%s\0' "${container_supported_filesystems[@]}" | grep -Fqxz -- "${OPTARG}") || USE_HOST_MOUNT_TOOLS=1
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ ${USE_HOST_MOUNT_TOOLS} -eq 1 ]]; then
|
|
for p in $(echo $P | cut -d ":" -f 1- --output-delimiter=" "); do
|
|
if [[ -f "/host${p}/mount" ]]; then
|
|
chroot /host "${p}/mount" "${@:1}"
|
|
exit $?
|
|
fi
|
|
done
|
|
chroot /host /usr/bin/env -i PATH="${P}" mount "${@:1}"
|
|
exit $?
|
|
else
|
|
/usr/bin/env -i PATH="${PL}" mount "${@:1}"
|
|
exit $?
|
|
fi
|