mirror of
https://github.com/unraid/webgui.git
synced 2025-12-31 06:30:10 -06:00
30 lines
774 B
Bash
Executable File
30 lines
774 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# usage: disk_size <disk-name> <output-file>
|
|
|
|
# Creates an "ini" output file suitable for php parse_ini_function which describes
|
|
# the size of <user-share> takes up on the selected disk.
|
|
# Since this uses the 'du' command, could take awhile.
|
|
|
|
disk="$1"
|
|
output="/var/local/emhttp/$disk.$2"
|
|
total=0;
|
|
|
|
echo "Computing share usage for $disk..."
|
|
rm -f "$output"
|
|
|
|
function check {
|
|
folder="/mnt/$2/$1"
|
|
if [[ -e "$folder" ]] ; then
|
|
echo "calculating $1 usage..."
|
|
size=$(du -sb "$folder"|cut -f1)
|
|
echo "$1=$size" >>"$output"
|
|
total=$(($total + $size))
|
|
fi
|
|
}
|
|
while IFS=$'\n' read -r share; do
|
|
[[ -d $share ]] && check "$(basename "$share")" "$disk"
|
|
done <<< $(ls -vd /mnt/user/*)
|
|
echo "share.total=$total" >>"$output"
|
|
echo "total disk usage: $total"
|