diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-10-06 11:13:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-10-06 11:21:03 +0000 |
commit | 2b5412675ba818b33c810e3da4a1e286937ba121 (patch) | |
tree | fee7628ab0851d24040776d58776d8b46f7f8311 /netapp/bin | |
parent | Adding ldap tools. (diff) | |
download | bfh-tools-2b5412675ba818b33c810e3da4a1e286937ba121.tar.xz bfh-tools-2b5412675ba818b33c810e3da4a1e286937ba121.zip |
Adding netapp tools.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netapp/bin')
-rwxr-xr-x | netapp/bin/bfh-netapp-mount | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/netapp/bin/bfh-netapp-mount b/netapp/bin/bfh-netapp-mount new file mode 100755 index 0000000..2fa7074 --- /dev/null +++ b/netapp/bin/bfh-netapp-mount @@ -0,0 +1,83 @@ +#!/bin/sh + +set -e + +# 192.168 +#vmware-arz.bfh.ch \ +#vmware-be.bfh.ch \ +#vmware-be-ssd.bfh.ch \ +#vmware-bi.bfh.ch \ + +NETAPPS=" \ + app-nfs-arz.bfh.ch \ + app-nfs-be.bfh.ch \ + app-nfs-ssd.bfh.ch \ + backup-be.bfh.ch \ + data-arz.bfh.ch \ + data-be.bfh.ch \ + \ + app-nfs-bi.bfh.ch \ + app-smb-bi.bfh.ch \ + backup-bi.bfh.ch \ + data-bi.bfh.ch \ +" +RED="\033[1;33;31m" +GREEN="\033[1;33;32m" +YELLOW="\033[1;33;33m" +BLUE="\033[1;33;34m" +NORMAL="\033[0m" + +for NETAPP in ${NETAPPS} +do + echo "Mounting ${BLUE}${NETAPP}${NORMAL}:" + + MOUNTS="$(showmount --no-headers -e "${NETAPP}" | awk '{ print $1 }')" + + for MOUNT in ${MOUNTS} + do + case "${MOUNT}" in + /|/bfh_img_01_be) + continue + ;; + + *) + MOUNT_POINT="/mnt/${NETAPP}/${MOUNT}" + ;; + esac + + MOUNT_POINT="$(echo "${MOUNT_POINT}" | sed -e 's|//|/|g')" + + echo -n " * ${NETAPP}:${MOUNT}" + + if mount | grep -qs " ${MOUNT_POINT} " + then + echo " ${YELLOW}already done${NORMAL}" + continue + fi + + set +e + MOUNT_RETURN="" + MOUNT_ERROR="$(mkdir -p "${MOUNT_POINT}" && mount -t nfs -o vers=3,ro "${NETAPP}:${MOUNT}" "${MOUNT_POINT}" 2>&1)" + MOUNT_RETURN="${?}" + set -e + + case "${MOUNT_RETURN}" in + 0) + echo " ${GREEN}done${NORMAL}" + + if ! grep -qs "^${NETAPP}:${MOUNT} " /etc/fstab + then + echo "${NETAPP}:${MOUNT} ${MOUNT_POINT} nfs noatime,noauto,ro,vers=3 0 0" >> /etc/fstab + fi + ;; + + *) + echo " ${RED}failed${NORMAL} (${MOUNT_ERROR})" + + rmdir -p "${MOUNT_POINT}" > /dev/null 2>&1 || true + ;; + esac + done + + echo +done |