-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from aacole/check-fs-writable
adding check-fs-writable.sh
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
# checks that all mounts listed in fstab are writeable | ||
|
||
mount_status=0 | ||
|
||
for mount in $( findmnt -sno target | grep -v none ); do | ||
file="${mount}/.tmp-writable-check" | ||
trap '[[ -f "${file}" ]] && rm "${file}"' TERM EXIT | ||
|
||
if ! touch "$file" 2>/dev/null; then | ||
echo "FAIL - Could not create a file into '${mount}' !" | ||
((mount_status++)) | ||
fi | ||
done | ||
|
||
if [[ $mount_status == 0 ]]; then | ||
echo "OK - all fstab mounts are writable" | ||
exit 0 | ||
else | ||
echo "CRITICAL - '${mount_status}' mount(s) failing to write data" | ||
exit 2 | ||
fi |