-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AutoNFS v1.4.2: Added support for new loglevels
fixes #7 Signed-off-by: Martin Seener <[email protected]>
- Loading branch information
1 parent
263abdf
commit 3031d91
Showing
4 changed files
with
24 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
# AutoNFS v1.4.1 | ||
# AutoNFS v1.4.2 | ||
|
||
# (c) 2012-2014 by Martin Seener ([email protected]) | ||
# Licensed under the GPLv2 | ||
|
||
# Code can be found at github.com/martinseener/autonfs | ||
|
||
# Hints: | ||
# - only limited logging is active; for debug logging, uncomment all "logger" lines | ||
|
||
# Load the configuration file | ||
if [ -f "/etc/default/autonfs" ]; then | ||
. /etc/default/autonfs | ||
else | ||
logger -t autonfs "Cannot find configuration file. Exiting." | ||
if [ $LOGLEVEL -ge 1 ]; then logger -t autonfs "Cannot find configuration file. Exiting."; fi | ||
exit 3 | ||
fi | ||
|
||
|
@@ -28,12 +25,12 @@ while true; do | |
/usr/bin/rpcinfo -t "$FILESERVER" nfs $NFSVERS &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
# First check failed, therefore doing it twice after a second | ||
logger -t autonfs "Fileserver[${FILESERVER}] seems to be down - Rechecking in a second" | ||
if [ $LOGLEVEL -ge 1 ]; then logger -t autonfs "Fileserver[${FILESERVER}] seems to be down - Rechecking in a second"; fi | ||
sleep 1 | ||
/usr/bin/rpcinfo -t "$FILESERVER" nfs $NFSVERS &>/dev/null | ||
if [ $? -eq 0 ]; then | ||
# Second check was succssful, checking if all NFS Shares are mounted | ||
logger -t autonfs "Fileserver[${FILESERVER}] is up" | ||
if [ $LOGLEVEL -ge 1 ]; then logger -t autonfs "Fileserver[${FILESERVER}] is up"; fi | ||
for MOUNT in ${MOUNTS[@]}; do | ||
# Split the share if it has a different remote and local mountpoint | ||
# Both will be the same if the mountpoints are so too | ||
|
@@ -44,13 +41,13 @@ while true; do | |
mount | grep -E "^${FILESERVER}:${RMNTPATH} on .*$" &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
# The actual NFS Share is not mounted, so it will be done now | ||
#logger -t autonfs "NFS-Share[${MOUNT}] not mounted - attempting to mount it from: ${FILESERVER}:${MOUNT}" | ||
if [ $LOGLEVEL -eq 2 ]; then logger -t autonfs "NFS-Share[${MOUNT}] not mounted - attempting to mount it from: ${FILESERVER}:${MOUNT}"; fi | ||
mount -t nfs ${MOUNTOPT} ${FILESERVER}:${RMNTPATH} ${LMNTPATH} | ||
fi | ||
done | ||
else | ||
# The Fileserver was not reachable two times, unmounting shares which are still mounted | ||
logger -t autonfs "Fileserver(${FILESERVER}) is down." | ||
if [ $LOGLEVEL -ge 1 ]; then logger -t autonfs "Fileserver(${FILESERVER}) is down."; fi | ||
for MOUNT in ${MOUNTS[@]}; do | ||
# Split the share if it has a different remote and local mountpoint | ||
# Both will be the same if the mountpoints are so too | ||
|
@@ -60,14 +57,14 @@ while true; do | |
# Let's check if its already mounted | ||
mount | grep -E "^${FILESERVER}:${RMNTPATH} on .*$" &>/dev/null | ||
if [ $? -eq 0 ]; then | ||
logger -t autonfs "Cannot reach ${FILESERVER}, therefore unmounting NFS-Share[${LMNTPATH}]" | ||
if [ $LOGLEVEL -ge 1 ]; then logger -t autonfs "Cannot reach ${FILESERVER}, therefore unmounting NFS-Share[${LMNTPATH}]"; fi | ||
umount -f ${LMNTPATH} | ||
fi | ||
done | ||
fi | ||
else | ||
# First check succeeded, so just checking if all NFS-Shares are mounted | ||
#logger -t autonfs "Fileserver[${FILESERVER}] is up" | ||
if [ $LOGLEVEL -eq 2 ]; then logger -t autonfs "Fileserver[${FILESERVER}] is up"; fi | ||
for MOUNT in ${MOUNTS[@]}; do | ||
# Split the share if it has a different remote and local mountpoint | ||
# Both will be the same if the mountpoints are so too | ||
|
@@ -78,7 +75,7 @@ while true; do | |
mount | grep -E "^${FILESERVER}:${RMNTPATH} on .*$" &>/dev/null | ||
if [ $? -ne 0 ]; then | ||
# The actual NFS Share is not mounted, so it will be done now | ||
#logger -t autonfs "NFS-Share[${MOUNT}] not mounted - attempting to mount it from: ${FILESERVER}:${MOUNT}" | ||
if [ $LOGLEVEL -eq 2 ]; then logger -t autonfs "NFS-Share[${MOUNT}] not mounted - attempting to mount it from: ${FILESERVER}:${MOUNT}"; fi | ||
mount -t nfs ${MOUNTOPT} ${FILESERVER}:${RMNTPATH} ${LMNTPATH} | ||
fi | ||
done | ||
|