#!/bin/bash

# small script to check if files under /boot changed
# Author: https://github.com/sercxanto
#
# License: GPLv2 or later

source /etc/default/chkboot.conf

chgfile=${CHKBOOT_DATA}/${CHANGES_ALERT}

XMESSAGE=/usr/bin/xmessage
ZENITY=/usr/bin/zenity
NOTIFICATION="This notification will continue to appear until you either run chkboot again as root or restart your computer"

if [ -s $chgfile ]; then
    if [ -x $ZENITY ]; then
        cat $chgfile | $ZENITY --title "ALERT: Boot changes" --text-info --width 550 --height 300
        $ZENITY --title "chkboot" --info --text="$NOTIFICATION"
    elif [ -x $XMESSAGE ]; then
        cat $chgfile | $XMESSAGE -default okay -file -
        $XMESSAGE -default okay $NOTIFICATION
    else
        exit 1
    fi
fi
