This commit is contained in:
Cyberes 2024-06-22 20:10:20 -06:00
parent 74a0207f2d
commit b13c7ea8c5
1 changed files with 8 additions and 8 deletions

View File

@ -1,11 +1,11 @@
#!/bin/bash
print_help() {
echo "Usage: $0 -h <host> -s <shares>"
echo "Checks if the specified NFS shares are exported on the given host."
echo "Usage: $0 -h <host> -s <exports>"
echo "Checks if the specified NFS exports are exported on the given host."
echo ""
echo "-h The IP address or hostname of the NFS server."
echo "-s A comma-separated list of NFS shares to check. For example: '/mnt/test,/mnt/export'"
echo "-e A comma-separated list of NFS exports to check. For example: '/mnt/test,/mnt/export'"
echo ""
echo "You can list the exported shares on an NFS server using the command 'showmount -e <host>'"
echo "This script assumes that 'showmount' is installed on the system where it is run."
@ -21,13 +21,13 @@ if [ "$#" -ne 4 ] || [ "$1" == "--help" ]; then
print_help
fi
while getopts "h:s:" opt; do
while getopts "h:e:" opt; do
case ${opt} in
h )
host=$OPTARG
;;
s )
shares=$OPTARG
e )
exports=$OPTARG
;;
\? )
print_help
@ -38,7 +38,7 @@ done
share_count=0
all_ok=true
IFS=',' read -r -a share_array <<< "$shares"
IFS=',' read -r -a share_array <<< "$exports"
for share in "${share_array[@]}"; do
output=$(showmount -e $host | grep $share)
@ -50,7 +50,7 @@ for share in "${share_array[@]}"; do
done
if $all_ok; then
echo "OK - All $share_count shares are exported on $host | share_count=$share_count"
echo "OK - $share_count NFS exports on $host | share_count=$share_count"
fi
exit 0