#!/bin/sh
# feisty-fsfn.sh
#############################################################
# Installs fn-key support on Sony FS Series laptops
#
# Max Luebbe - intentionallyobsolete.com
#
# All the tricky stuff was figured out by the Ubuntu Forums,
# I just made the convinience script - much thanks to Zhukov!
#############################################################

# Remove old sony module
sudo rmmod sony_acpi

# Install pre-reqs
sudo apt-get install libasound2-dev build-essential linux-headers-$(uname -r) gcc-3.4 libxosd-dev checkinstall

# Make temporary folder to keep all the stuff we're going to need
mkdir fsfntemp
cd fsfntemp

# Pull in files needed
wget http://download.berlios.de/fsfn/sony_acpi.tar.gz
wget http://student.dei.uc.pt/~jpoa/fsfn/fsfn.conf.txt
wget http://student.dei.uc.pt/~jpoa/fsfn/fsfn.txt
wget http://student.dei.uc.pt/~jpoa/fsfn/fsfn_1.1-1_i386.deb

# Install package
sudo dpkg -i fsfn_1.1-1_i386.deb

# Unpack new sony module and install it
tar xvzf sony_acpi.tar.gz
cd sony_acpi
make
sudo cp sony_acpi.ko /lib/modules/$(uname -r)/kernel/ubuntu/acpi/
sudo modprobe sony_acpi
cd ../

# Add fsfn.conf to the boot process
sudo cp fsfn.conf.txt /etc/fsfn.conf
sudo chown root:root fsfn.txt && sudo chmod +x fsfn.txt && sudo mv fsfn.txt /etc/init.d/fsfn
sudo update-rc.d fsfn defaults

# Clean up temporary files
cd ../
#rm -R fsfntemp


