icinga2-checks/check_not_writable.sh

24 lines
445 B
Bash
Executable File

#!/bin/bash
# Check if argument is provided
if [ $# -eq 0 ]; then
echo "No arguments provided"
echo "./check_writable.sh [path to directory to test]"
exit 3
fi
# Check if directory exists
if [ ! -d "$1" ]; then
echo "UNKNOWN - $1 is not a directory"
exit 3
fi
# Check if directory is not writable
if [ ! -w "$1" ]; then
echo "OK - $1 is not writable"
exit 0
else
echo "CRITICAL - $1 is writable"
exit 2
fi