Here is simplified version of the script:
#! /bin/bash
DRV_PKG_NAME="e1000e-3.0.4.tar.gz"
DRV_PKG_URL="http://downloadmirror.intel.com/15817/eng/e1000e-3.0.4.tar.gz"
ERR_LOG="err.log"
# Redirecting all stderr
exec 2>$ERR_LOG
# Function declaration
error_action () {
echo "Failed!"
exit 1
}
# Downloading driver and extracting it to the current directory
echo "Downloading and extracting driver package..."
wget -q ${DRV_PKG_URL} && tar zxf ${DRV_PKG_NAME} || error_action
# Installing required build dependencies if necessary
echo "Installing build dependencies..."
apt-get install -y build-essential linux-headers-$(uname -r) >/dev/null || error_action
# Going into the driver source directory
cd e1000e-3.0.4/src/
# Building driver and updating initramfs
echo "Building module and updating initramfs..."
{ make install && update-initramfs -k all -u; } >/dev/null || error_action
echo "Purging unnecessary build dependencies..."
apt-get -y purge build-essential >/dev/null || error_action
# Restarting iface
echo "Restarting iface..."
{ ifdown eth0 && ifup eth0; } &>/dev/null || error_action
# Checking installed driver version
if [[ $(modinfo -F version e1000e) == "3.0.4-NAPI" ]]; then
echo "Driver successfully installed!"
else
echo "Something wrong... Try depmod -a or re-install again!"
exit 1
fi
exit 0