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 #!/bin/bash
print_help() { print_help() {
echo "Usage: $0 -h <host> -s <shares>" echo "Usage: $0 -h <host> -s <exports>"
echo "Checks if the specified NFS shares are exported on the given host." echo "Checks if the specified NFS exports are exported on the given host."
echo "" echo ""
echo "-h The IP address or hostname of the NFS server." 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 ""
echo "You can list the exported shares on an NFS server using the command 'showmount -e <host>'" 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." 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 print_help
fi fi
while getopts "h:s:" opt; do while getopts "h:e:" opt; do
case ${opt} in case ${opt} in
h ) h )
host=$OPTARG host=$OPTARG
;; ;;
s ) e )
shares=$OPTARG exports=$OPTARG
;; ;;
\? ) \? )
print_help print_help
@ -38,7 +38,7 @@ done
share_count=0 share_count=0
all_ok=true all_ok=true
IFS=',' read -r -a share_array <<< "$shares" IFS=',' read -r -a share_array <<< "$exports"
for share in "${share_array[@]}"; do for share in "${share_array[@]}"; do
output=$(showmount -e $host | grep $share) output=$(showmount -e $host | grep $share)
@ -50,7 +50,7 @@ for share in "${share_array[@]}"; do
done done
if $all_ok; then 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 fi
exit 0 exit 0