From 2b5412675ba818b33c810e3da4a1e286937ba121 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 6 Oct 2022 13:13:34 +0200 Subject: Adding netapp tools. Signed-off-by: Daniel Baumann --- netapp/bin/bfh-netapp-mount | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 netapp/bin/bfh-netapp-mount (limited to 'netapp/bin') 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 -- cgit v1.2.3