blob: 56e25921996c1d3d270c68637047f3a5a48c00e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/sh
# format a number into a bytes, kibibytes, mebibytes, or gibibytes
#
format_bytes () {
case "1" in
"$(($1>=1<<30))") printf "$(($1>>30))GiB";;
"$(($1>=1<<20))") printf "$(($1>>20))MiB";;
"$(($1>=1<<10))") printf "$(($1>>10))kiB";;
*) printf "$1B";;
esac
}
# ensure that the user is a root user
#
checkroot () {
[ "$(id -u)" = "0" ] || {
printf "${RED}Please run as root!\n"
exit 1
}
}
|