mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 09:39:58 -06:00
repo reorg
This commit is contained in:
33
emhttp/plugins/dynamix/scripts/share_size
Executable file
33
emhttp/plugins/dynamix/scripts/share_size
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# usage: share_size <user-share> <output-file>
|
||||
|
||||
# Creates an "ini" output file suitable for php parse_ini_function which describes
|
||||
# the size <user-share> takes up on the cache disk and each data disk. Since this
|
||||
# uses the 'du' command, could take awhile.
|
||||
|
||||
share="$1"
|
||||
output="/var/local/emhttp/$share.$2"
|
||||
pools=${3//,/ }
|
||||
total=0;
|
||||
|
||||
echo "Computing disk usage for $share..."
|
||||
rm -f "$output"
|
||||
|
||||
function check {
|
||||
if [[ -e "$1/$2" ]] ; then
|
||||
echo "calculating $1 usage..."
|
||||
size=$(du -sb "$1/$2"|cut -f1)
|
||||
echo "$(basename "$1")=$size" >>"$output"
|
||||
total=$(($total + $size))
|
||||
fi
|
||||
}
|
||||
|
||||
for pool in $pools; do
|
||||
check "/mnt/$pool" "$share"
|
||||
done;
|
||||
while IFS=$'\n' read -r disk; do
|
||||
check "$disk" "$share"
|
||||
done <<< $(ls -vd /mnt/disk[0-9]*)
|
||||
echo "disk.total=$total" >>"$output"
|
||||
echo "total disk usage: $total"
|
||||
Reference in New Issue
Block a user