
compat-wireless
By:
swiftgeek on
May 4th, 2012 | syntax:
Bash | size: 2.03 KB | hits: 183 | expires: Never
#!/bin/bash
# Author: Swift Geek ‹ swiftgeek (at) gmail (dot) com › 😸
# Includes
. /etc/rc.conf
. /etc/rc.d/functions
# Make package outdated ;)
function MakePackageOutdated
{
___COMPAT_VERSION="`echo /var/lib/pacman/local/compat-wireless-patched*/ | awk -F'[/,-]' '{print $9 "-" $10}'`"
sed -i "s/$___COMPAT_VERSION/0.1-1/" /var/lib/pacman/local/compat-wireless-patched-$___COMPAT_VERSION/desc
[ "$?" != "0" ] && return 1
mv /var/lib/pacman/local/compat-wireless-patched-$___COMPAT_VERSION /var/lib/pacman/local/compat-wireless-patched-0.1-1
[ "$?" != "0" ] && return 1
# echo "Package is now outdated"
return 0
}
# Check if a currently running kernel is the official one and upgraded (after upgrade it is NOT) — otherwise skip (use stat -L)
# It does a false positive when package is reinstalled with the same build
function IsKernelCurrent
{
if [ -e "/var/lib/pacman/sync/core.db" ]; then
___KERNEL_VERSION="`uname -r | awk -F"-A" '{print $1}'`"
if [ -d "/var/lib/pacman/local/linux-$___KERNEL_VERSION" ]; then
# echo "Kernel is current"
return 0
else
return 69
fi
else
return 96
fi
}
# Main part of daemon – no reusable code down here
case "$1" in
start)
IsKernelCurrent
case "$?" in
"0")
if [ "`modinfo -n mac80211 | awk -F'/' '{print $5}'`" = "extramodules" ]; then
stat_busy "Compat-wireless is up and running"
stat_done
else
stat_busy "Compat-wireless needs recompiling"
MakePackageOutdated
if [ "$?" = "0" ]; then
stat_done
else
stat_fail
fi
fi
;;
"96")
stat_busy "Compat-wireless: pacman-cage or /var partition not mounted"
stat_fail
;;
"69")
stat_busy "Compat-wireless: reboot needed — kernel is outdated"
stat_fail
;;
esac
;;
restart)
$0 start
;;
*)
echo "usage: $0 {start}"
;;
esac