#!/bin/bash

main() {
    start=$(/usr/bin/date +%s)
    # run bigboot.sh to increase boot partition and file system size
    sh /usr/bin/bigboot.sh "{{ bigboot_boot_partition_name }}" "{{ bigboot_next_partition_name }}" "{{ bigboot_increase_bytes }}"
    status=$?
    end=$(/usr/bin/date +%s)
    # write the log file
    if [[ $status -eq 0 ]]; then
        echo "Boot partition {{ bigboot_boot_partition_name }} successfully increased by {{ bigboot_increase_bytes }} ("$((end-start))" seconds)"
    else
        echo "Failed to extend boot partition ("$((end-start))" seconds)"
    fi
}

main "$0" >&2
