#!/bin/bash -x
# revert patch to libertas kernel module

os=`cat /etc/issue|gawk '/OLPC/ {print $3}'`
model=`cat /etc/issue|gawk '/OLPC/ {print $5}'`
if [ "$model" == "XO-1" ]; then
  if [ "$os" == "13.2.0" ]; then
    echo "Updating OS 13.2.0"
    cd /usr/lib/modules/3.3.8_xo1-20130329.1530.olpc.c0f817d/kernel/drivers/net/wireless/libertas
    cp libertas.ko.ORIG libertas.ko
    
  elif [ "$os" == "12.1.0" ]; then
    echo "Updating OS 12.1.0"
    cd /usr/lib/modules/3.3.8_xo1-20120705.1732.olpc.5d48a2f/kernel/drivers/net/wireless/libertas
    cp libertas.ko.ORIG libertas.ko
      
  else
    echo $os
    echo "is not a supported OS"  
  fi
else
    echo "This is only for an XO-1"    
fi

sync
echo ""
echo "           ********************************************"
echo "           *                                          *"
echo "           *  Make sure you read the messages         *"
echo "           *   to see if it worked                    *"
echo "           *                                          *"
echo "           ********************************************"
