Drop ioctl
[apc.git] / apc-linux.run
blob3e43a8f27020d6c58f5c932f8493ab81dae65167
1 #!/bin/sh
3 set -e
5 dev="/dev/itc"
7 su() {
8 shift
9 sudo $*
12 ! test `uname -s` = "Linux" && {
13 echo `uname -s` is not Linux
14 exit 1
17 case `uname -r | cut -d. -f1,2` in
18 2.6) kms=ko; syms=/proc/kallsyms;;
19 2.4) kms=o; syms=/proc/ksyms;;
20 *) echo "unknown kernel version"; exit 1;;
21 esac
23 apc=./apc
25 test -e "build/itc.$kms" && kmod=build/itc.$kms
26 test -z "$kmod" && test -e "mod/itc.$kms" && kmod=mod/itc.$kms
27 test -e "$apc" || apc="build/apc"
28 test -e "$apc" || {
29 echo "APC is not found in usual places"
30 exit 1
33 test -z "$kmod" && {
34 echo "Kernel module does not exist"
35 exit 1
38 case `uname -m` in
39 i[3456]86)
40 func=$(awk '/default_idle$/ {print "0x" $1}' $syms)
41 args="idle_func=$func"
45 args=
47 esac
49 if ! test -c $dev; then
50 echo "ITC kernel module is not running. Will try to load $kmod."
51 su -c "insmod $kmod $args"
54 if ! test -r $dev; then
55 echo "ITC is not readable. Will try to change mode."
56 su -c "chmod +r $dev"
59 $apc -d $dev & disown
60 echo "apc should be running now"