Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions skel/share/lib/pool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ getSizeOfPool() # in $1 = pool path
local size

size=$(getPoolSetting "$path" "set max diskspace" max)

if [ -z "$size" ]; then
size=$(getProperty pool.size "$domain" "$cell")
fi
Expand All @@ -38,6 +39,13 @@ getSizeOfPool() # in $1 = pool path
"")
echo "-"
;;
*%)
total=$(getTotalSpace "$path")
percent=$(echo "${size}" | tr -d "%")
size=$((${total}*${percent}/100))
stringToGiB "${size}G" size
echo "${size}G"
;;
*)
stringToGiB "$size" size
echo "${size}G"
Expand Down
6 changes: 6 additions & 0 deletions skel/share/lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ getFreeSpace() # in $1 = path
[ -d "$1" ] && ( df -k "${1}" | awk 'NR == 2 { if (NF < 4) { getline; x = $3 } else { x = $4 }; printf "%d", x / (1024 * 1024)}' )
}

# Extracts the amount of free space in GiB.
getTotalSpace() # in $1 = path
{
[ -d "$1" ] && ( df -k "${1}" | awk 'NR == 2 { if (NF < 4) { getline; x = $1 } else { x = $2 }; printf "%d", x / (1024 * 1024)}' )
}

# Reads configuration file into shell variables. The shell variable
# names can optionally be prefixed. Returns 1 if file does not exist.
readconf() # in $1 = file in $2 = prefix
Expand Down