#!/bin/bash
function fail {
    echo $1 > /home/eeg/.update_failure
    exit 0
}

if ! grep -E "Lexi DR" /etc/eeg/product
then
    fail "This update is intended for a Lexi DR."
fi

if [[ $(cat /etc/eeg/build) < "5.2.0" ]]
then
    fail "Build 5.2.0 or newer required."
fi

cat /etc/eeg/build > /tmp/old_build

if [ -e /var/www/cgi-bin/log/log_patterns.conf ]
then
    cp /var/www/cgi-bin/log/log_patterns.conf /tmp/old_log_patterns.conf
fi

if [ -e /boot/grub/menu.lst ]
then
    cp /boot/grub/menu.lst /tmp/old_menu.lst
fi

cp -a /etc/shadow /tmp/shadow.org
