#!/usr/bin/env bash

# chkboot-initcpio: on Arch Linux (and possibly other systems with mkinitcpio), copy this
#                   to '/usr/lib/initcpio/install/chkboot', then add 'chkboot' to the end
#                   of the 'HOOKS' array, and rerun mkinitcpio to generate with this  included
#
# author: ju (ju at heisec dot de)
# contributors: inhies, prurigro
#
# license: GPLv2

build() {
    echo "Updating chkboot hashes of your boot files..."

    #TEST TO SEE IF BOOT FILES WERE MODIFIED WITHOUT THE USER'S ACKNOWLEDGEMENT (BY RUNNING 'chkboot') AND ALERT THEM IF IT HAS BEEN
    chkboot-check
    if [ "$?" = 1 ]; then echo -e "\n### WARNING: Previously modified files were not acknowledged ###"; echo "### Check the issues log at ${CHANGES_LOG} for details ###"; fi

    #RUN CHKBOOT TO UPDATE THE HASHES WITHOUT CREATING THE ALERT FILE
    chkboot -u
    sync
}

help() {
    cat <<HELPEOF
    Update the the collection of hashes for files on the boot partition
HELPEOF
}
