#!/bin/sh
if [ "$(id -u)" != "0" ]; then
    echo "Error: You must be root to run this script!" >&2
    exit 1
fi

if ! [ -x /usr/bin/git ]; then
    apt-get update && apt-get --yes install git
fi

dkms remove rtl8192eu/0.1.0 --all
rm -rf /usr/src/rtl8192eu-0.1.0

if [ "$1" = "-u" ]; then
    echo "Uninstall complete!"
    exit 2
fi

git clone git://github.com/luizsanches/rtl8192eu.git /usr/src/rtl8192eu-0.1.0
dkms add rtl8192eu/0.1.0

for x in /boot/vmlinuz-*;do
    /usr/lib/dkms/dkms_autoinstaller start ${x#/boot/vmlinuz-}
done
