blob: 3e65aef9c78f09322a848cf44983d9221079a901 (
plain)
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
|
## vim:ft=zsh
typeset filesystem line IFS=$'\n'
typeset -a filesystems
typeset tune2fs
typeset reboot simulate
function execute {
(( simulate )) || $*
}
while [[ $1 == -* ]] {
case $1 in
-n) simulate=1 ;;
-r) reboot=1 ;;
esac
shift
}
execute uinit stop-all
for line in $(cat /etc/fstab); {
if [[ $line == *[12] ]] {
filesystems+=${${(s: :)line}[1]}
}
}
for filesystem in $filesystems; {
tune2fs=($(sudo tune2fs -l $filesystem | fgrep -i 'mount count' | grep -o '[0-9]*'))
if (( tune2fs[2] - tune2fs[1] < 2 )) {
echo "notice: filesystem $filesystem due to check at next boot"
}
}
if (( reboot )) {
execute sudo reboot
} else {
execute sudo halt
}
|