add check writable

This commit is contained in:
Cyberes 2024-02-18 00:38:45 -07:00
parent 871cdbda13
commit 406086a119
2 changed files with 46 additions and 0 deletions

23
check_not_writable.sh Executable file
View File

@ -0,0 +1,23 @@
#!/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

23
check_writable.sh Executable file
View File

@ -0,0 +1,23 @@
#!/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 writable
if [ -w "$1" ]; then
echo "OK - $1 is writable"
exit 0
else
echo "CRITICAL - $1 is not writable"
exit 2
fi