-
Notifications
You must be signed in to change notification settings - Fork 11
/
disk-watcher
60 lines (47 loc) · 1.76 KB
/
disk-watcher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#----------------------------------------------------------------------------------
# Project Name - miscellaneous/disk-watcher
# Started On - Sun 28 Jan 00:56:24 GMT 2018
# Last Change - Mon 26 Mar 23:24:53 BST 2018
# Author E-Mail - [email protected]
# Author GitHub - https://github.com/terminalforlife
#----------------------------------------------------------------------------------
# Placeholder for a handy-dandy project idea.
#----------------------------------------------------------------------------------
_VERSION_="2018-03-26"
XERR(){ printf "[L%0.4d] ERROR: %s\n" "$1" "$2" 1>&2; exit 1; }
ERR(){ printf "[L%0.4d] ERROR: %s\n" "$1" "$2" 1>&2; }
#TODO - Use pure shell only! Parse /sys, /proc, and/or /dev.
USAGE(){
while read -r; do
printf "%s\n" "$REPLY"
done <<-EOF
DISK-WATCHER ($_VERSION_)
Written by terminalforlife ([email protected])
Background utility which watches for low storage space.
SYNTAX: disk-watcher [OPTS]
OPTS: --help|-h|-? - Displays this help information.
--version|-v - Output only the version datestamp.
--quiet|-q - Runs in quiet mode. Errors still output.
--debug|-D - Enables the built-in bash debugging.
EOF
}
while [ "$1" ]; do
case "$1" in
--help|-h|-\?)
USAGE; exit 0 ;;
--version|-v)
printf "%s\n" "$_VERSION_"
exit 0 ;;
--quiet|-q)
BEQUIET="true" ;;
--debug|-D)
DEBUGME="true" ;;
*)
XERR "$LINENO" "Incorrect argument(s) specified." ;;
esac
shift
done
[ "$BEQUIET" == "true" ] && exec 1> /dev/null
[ "$DEBUGME" == "true" ] && set -x
# vim: ft=sh noexpandtab colorcolumn=84 tabstop=8 noswapfile nobackup