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 | |
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>
-rw-r--r-- | netapp/Makefile | 78 | ||||
-rwxr-xr-x | netapp/bin/bfh-netapp-mount | 83 |
2 files changed, 161 insertions, 0 deletions
diff --git a/netapp/Makefile b/netapp/Makefile new file mode 100644 index 0000000..41e9755 --- /dev/null +++ b/netapp/Makefile @@ -0,0 +1,78 @@ +# Copyright (C) 2013-2022 Daniel Baumann <daniel@debian.org> +# +# SPDX-License-Identifier: GPL-3.0+ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +SHELL := sh -e + +SCRIPTS = bin/* + +all: build + +test: + @echo -n "Checking for syntax errors with sh... " + @for SCRIPT in $(SCRIPTS); \ + do \ + sh -n $${SCRIPT}; \ + echo -n "."; \ + done + @echo " done." + + @echo -n "Checking for bashisms... " + @if [ -x /usr/bin/checkbashisms ]; \ + then \ + for SCRIPT in $(SCRIPTS); \ + do \ + checkbashisms -f -x $${SCRIPT}; \ + echo -n "."; \ + done; \ + else \ + echo "Note: devscripts not installed, skipping checkbashisms."; \ + fi + @echo " done." + + @echo -n "Checking with shellcheck... " + @if [ -x /usr/bin/shellcheck ]; \ + then \ + for SCRIPT in $(SCRIPTS); \ + do \ + shellcheck -e SC2039 $${SCRIPT}; \ + echo -n "."; \ + done; \ + else \ + echo "Note: shellcheck not installed, skipping shellcheck."; \ + fi + @echo " done." + +build: + +install: build + mkdir -p $(DESTDIR)/usr/bin + cp -r bin/* $(DESTDIR)/usr/bin + +uninstall: + for FILE in bin/*; \ + do \ + rm -f $(DESTDIR)/usr/bin/$$(basename $${FILE}); \ + done + rmdir --ignore-fail-on-non-empty --parents $(DESTDIR)/usr/bin || true + + rmdir --ignore-fail-on-non-empty --parents $(DESTDIR) || true + +clean: + +distclean: + +reinstall: uninstall install 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 |