Last active
January 3, 2016 18:49
-
-
Save ergoithz/8504995 to your computer and use it in GitHub Desktop.
Latest wacom driver installer, with rc.local patching for detecting new kernel versions, gksudo if display is available, and kernel-version aware.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
URL="http://downloads.sourceforge.net/project/linuxwacom/xf86-input-wacom/input-wacom/input-wacom-0.20.0.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flinuxwacom%2Ffiles%2Fxf86-input-wacom%2Finput-wacom%2F&ts=`date +%s`&use_mirror=freefr" | |
WORKDIR="/tmp/wacom" | |
TARFILE="$WORKDIR/wacom.tar.bz2" | |
SRCDIR="$WORKDIR/input-wacom-*" | |
SCRIPT=`readlink -e $0` | |
NAME=`basename $SCRIPT` | |
KERNEL=`uname -r` | |
KTYPE=`echo $KERNEL|rev|cut -d "-" -f 1|rev` | |
INSTALLED="/etc/wacom-driver-installer/installed" | |
# Test if running as sudo | |
if [ "$USER" != "root" ]; then | |
echo "Not running as root user." | |
if [ "$DISPLAY" ]; then | |
gksudo --description "$NAME needs superuser rights" -- x-terminal-emulator -e /bin/bash -c "$SCRIPT; read -p 'Press ENTER to exit.'" | |
exit $? | |
fi | |
echo "Run sudo $SCRIPT." | |
exit 1 | |
fi | |
# Add self to /bin | |
if [ "`dirname $SCRIPT`" != "/bin" ]; then | |
if [ ! -f "/bin/$NAME" ]; then | |
echo "Copying script, not in /bin." | |
cp $SCRIPT /bin/$NAME | |
elif [ `md5sum /bin/$NAME | cut -f 1 -d " "` != `md5sum $SCRIPT | cut -f 1 -d " "` ]; then | |
echo "Update script to /bin" | |
cp -f $SCRIPT /bin/$NAME | |
fi | |
echo "Running from /bin/$NAME." | |
/bin/$NAME | |
exit $? | |
fi | |
# Add to rc.local | |
if grep -Fxq $SCRIPT /etc/rc.local; then | |
echo "Skipping, rc.local already patched." | |
else | |
echo "Patching rc.local for running this script on every startup." | |
echo "`tac /etc/rc.local|awk '/exit 0/ {p=1}p'|tac|head -n -1`" > /etc/rc.local | |
echo $SCRIPT >> /etc/rc.local | |
echo "exit 0" >> /etc/rc.local | |
fi | |
# Skip proceture if kernel already patched | |
if grep -Fxq $KERNEL $INSTALLED; then | |
echo "Exiting, module already compiled for current kernel version." | |
exit 0 | |
fi | |
# Install dependencies | |
echo "Installing dependencies" | |
apt-get install build-essential libX11-dev libxi-dev x11proto-input-dev xserver-xorg-dev libxrandr-dev libncurses5-dev autoconf libtool linux-headers-$KTYPE | |
# Create working dir | |
if [ -d "$WORKDIR" ]; then rm -Rf "$WORKDIR"; fi | |
mkdir -p "$WORKDIR" | |
# Install driver | |
echo "Downloading driver." | |
wget --quiet --output-document "$TARFILE" $URL | |
tar -xf "$TARFILE" -C "$WORKDIR" | |
cd $SRCDIR | |
echo "Compiling module for $KERNEL" | |
make clean > /dev/null 2>&1 | |
KOPATH=`./configure --prefix=/usr|grep --context=1 "Your wacom.ko is"|tail -n 1|sed -e 's/^ *//g' -e 's/ *$//g'` | |
cp -f $KOPATH/wacom.ko /lib/modules/$KERNEL/kernel/drivers/input/tablet/wacom.ko | |
depmod -a | |
# Saving current kernel to compiled driver list | |
mkdir -p `dirname $INSTALLED` | |
echo $KERNEL >> $INSTALLED | |
rm -Rf $WORKDIR | |
echo "Finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment