forked from rwbaumg/admin-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-fsck.sh
More file actions
executable file
·45 lines (36 loc) · 813 Bytes
/
check-fsck.sh
File metadata and controls
executable file
·45 lines (36 loc) · 813 Bytes
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
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <partition>"
exit 1
fi
# check if superuser
if [[ $EUID -ne 0 ]]; then
echo >&2 "This script must be run as root."
exit 1
fi
function showInfo() {
if [ -z "$1" ]; then
echo >&2 "ERROR: No device specified."
return 1
fi
if ! output=$(tune2fs -l "$1"); then
return 1
fi
if ! last=$(echo "$output" | grep Last\ c); then
return 1
fi
if ! count=$(echo "$output" | grep Mount); then
return 1
fi
if ! max=$(echo "$output" | grep Max); then
return 1
fi
echo "$last"
echo "$count"
echo "$max"
return 0
}
if ! showInfo "$1"; then
exit 1
fi
exit 0