| #!/bin/bash |
| set -o errexit |
| set -o pipefail |
| |
| # This plugin checks if the resize2f partition failed during the boot process. |
| |
| readonly OK=0 |
| readonly NONOK=1 |
| readonly UNKNOWN=2 |
| readonly DISKFRACTIONMINIMUM=90 |
| readonly ROOTDEVICE="sda1" |
| |
| if ! requestedDiskSize="$(grep "${ROOTDEVICE}" /proc/partitions | awk 'NR == 1 {printf $3}')"; then |
| echo "Error retrieving requested disk size" |
| exit "${UNKNOWN}" |
| fi |
| |
| |
| if ! actualDiskSize="$(df -P "/dev/${ROOTDEVICE}" | awk 'NR == 2 {printf $2}')"; then |
| echo "Error retrieving actual disk size" |
| exit "${UNKNOWN}" |
| fi |
| |
| |
| actualDiskSize=$((actualDiskSize*100)) |
| ratio=$((${actualDiskSize}/${requestedDiskSize})) |
| |
| # if the ratio of actualdiskSize to requestedDiskSize is less than 0.9, then it |
| # implies there is a problem occurring during the resize2f partition. |
| if [[ ${ratio} -lt ${DISKFRACTIONMINIMUM} ]]; then |
| echo "DiskSizeCheck failure occurred" |
| exit "${NONOK}" |
| else |
| echo "DiskSizeCheck is successful" |
| exit "${OK}" |
| fi |
| |