diff options
author | Brent Baude <bbaude@redhat.com> | 2020-10-05 08:42:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 08:42:15 -0500 |
commit | caace52d54c846c948c88a62f973f4d11808532e (patch) | |
tree | 41ef903d08193a4f6ff0edba9727f54a1e0583d5 /contrib/cirrus/add_second_partition.sh | |
parent | 436dda23852a367807d86e98b7a59f09a82c1802 (diff) | |
parent | 2c9084e2245834094e14e9105e64b6062d70a0f1 (diff) | |
download | podman-caace52d54c846c948c88a62f973f4d11808532e.tar.gz podman-caace52d54c846c948c88a62f973f4d11808532e.tar.bz2 podman-caace52d54c846c948c88a62f973f4d11808532e.zip |
Merge pull request #6784 from cevich/new_ci_cd
Cirrus: Make efficient and performant
Diffstat (limited to 'contrib/cirrus/add_second_partition.sh')
-rw-r--r-- | contrib/cirrus/add_second_partition.sh | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/contrib/cirrus/add_second_partition.sh b/contrib/cirrus/add_second_partition.sh index d0407be86..322dd2512 100644 --- a/contrib/cirrus/add_second_partition.sh +++ b/contrib/cirrus/add_second_partition.sh @@ -3,6 +3,11 @@ # N/B: This script could mega f*!@up your disks if run by mistake. # it is left without the execute-bit on purpose! +set -eo pipefail + +# shellcheck source=./lib.sh +source $(dirname $0)/lib.sh + # $SLASH_DEVICE is the disk device to be f*xtuP SLASH_DEVICE="/dev/sda" # Always the case on GCP @@ -11,21 +16,18 @@ SLASH_DEVICE="/dev/sda" # Always the case on GCP NEW_PART_START="50%" NEW_PART_END="100%" -set -eo pipefail - -source $(dirname $0)/lib.sh if [[ ! -r "/root" ]] || [[ -r "/root/second_partition_ready" ]] then - echo "Warning: Ignoring attempted execution of $(basename $0)" + warn "Ignoring attempted execution of $(basename $0)" exit 0 fi -[[ -n "type -P parted" ]] || \ - die 2 "The parted command is required." +[[ -x "$(type -P parted)" ]] || \ + die "The parted command is required." [[ ! -b ${SLASH_DEVICE}2 ]] || \ - die 5 "Found unexpected block device ${SLASH_DEVICE}2" + die "Found unexpected block device ${SLASH_DEVICE}2" PPRINTCMD="parted --script ${SLASH_DEVICE} print" FINDMNTCMD="findmnt --source=${SLASH_DEVICE}1 --mountpoint=/ --canonicalize --evaluate --first-only --noheadings" @@ -34,28 +36,28 @@ trap "rm -f $TMPF" EXIT if $FINDMNTCMD | tee $TMPF | egrep -q "^/\s+${SLASH_DEVICE}1" then - echo "Repartitioning original partition table:" + msg "Repartitioning original partition table:" $PPRINTCMD else - die 6 "Unexpected output from '$FINDMNTCMD': $(<$TMPF)" + die "Unexpected output from '$FINDMNTCMD': $(<$TMPF)" fi echo "Adding partition offset within unpartitioned space." parted --script --align optimal /dev/sda unit % mkpart primary "" "" "$NEW_PART_START" "$NEW_PART_END" -echo "New partition table:" +msg "New partition table:" $PPRINTCMD -echo "Growing ${SLASH_DEVICE}1 meet start of ${SLASH_DEVICE}2" +msg "Growing ${SLASH_DEVICE}1 meet start of ${SLASH_DEVICE}2" growpart ${SLASH_DEVICE} 1 FSTYPE=$(findmnt --first-only --noheadings --output FSTYPE ${SLASH_DEVICE}1) echo "Expanding $FSTYPE filesystem on ${SLASH_DEVICE}1" case $FSTYPE in ext*) resize2fs ${SLASH_DEVICE}1 ;; - *) die 11 "Script $(basename $0) doesn't know how to resize a $FSTYPE filesystem." ;; + *) die "Script $(basename $0) doesn't know how to resize a $FSTYPE filesystem." ;; esac # Must happen last - signals completion to other tooling -echo "Recording newly available disk partition device into /root/second_partition_ready" +msg "Recording newly available disk partition device into /root/second_partition_ready" echo "${SLASH_DEVICE}2" > /root/second_partition_ready |