|
@ -7,6 +7,37 @@ include common |
|
|
include pretty |
|
|
include pretty |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MIN_DISK_SPACE="${MIN_DISK_SPACE:-300M}" |
|
|
|
|
|
## convert human size to bytes using numfmt |
|
|
|
|
|
|
|
|
|
|
|
## Check remaining disk space |
|
|
|
|
|
if [ -n "$MIN_DISK_SPACE" ]; then |
|
|
|
|
|
min_disk_space_kbytes=$(numfmt --from=iec --to-unit=1024 "$MIN_DISK_SPACE") || { |
|
|
|
|
|
err "Invalid format for '\$MIN_DISK_SPACE'." |
|
|
|
|
|
exit 1 |
|
|
|
|
|
} |
|
|
|
|
|
if ! remaining_kbytes=$(df / | awk 'NR==2 {print $4}'); then |
|
|
|
|
|
err "Failed to get remaining disk space." |
|
|
|
|
|
exit 1 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
if [ "$remaining_kbytes" -lt "$min_disk_space_kbytes" ]; then |
|
|
|
|
|
err "Not enough disk space." |
|
|
|
|
|
human_min_dist_space=$(numfmt --to=iec --format="%.2f" --from-unit=1024 "$min_disk_space_kbytes") || { |
|
|
|
|
|
err "Failed to convert '\$MIN_DISK_SPACE' to human readable format." |
|
|
|
|
|
exit 1 |
|
|
|
|
|
} |
|
|
|
|
|
human_remaining_kbytes=$(numfmt --to=iec --format="%.2f" --from-unit=1024 "$remaining_kbytes") || { |
|
|
|
|
|
err "Failed to convert '\$remaining_kbytes' to human readable format." |
|
|
|
|
|
exit 1 |
|
|
|
|
|
} |
|
|
|
|
|
echo " - At least $human_min_dist_space are required." >&2 |
|
|
|
|
|
echo " - Only $human_remaining_kbytes are available." >&2 |
|
|
|
|
|
exit 1 |
|
|
|
|
|
fi |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start=$SECONDS |
|
|
start=$SECONDS |
|
|
|
|
|
|
|
|
if [ -z "$NO_UPDATE" -a -d "/opt/apps/myc-manage" ]; then |
|
|
if [ -z "$NO_UPDATE" -a -d "/opt/apps/myc-manage" ]; then |
|
|