From 406086a11948053a90bf336e031007443c737b95 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Sun, 18 Feb 2024 00:38:45 -0700 Subject: [PATCH] add check writable --- check_not_writable.sh | 23 +++++++++++++++++++++++ check_writable.sh | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 check_not_writable.sh create mode 100755 check_writable.sh diff --git a/check_not_writable.sh b/check_not_writable.sh new file mode 100755 index 0000000..1cc756a --- /dev/null +++ b/check_not_writable.sh @@ -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 diff --git a/check_writable.sh b/check_writable.sh new file mode 100755 index 0000000..880b009 --- /dev/null +++ b/check_writable.sh @@ -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