Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

phc-k8.rc

By: a guest on Sep 22nd, 2010  |  syntax: Bash  |  size: 2.69 KB  |  views: 136  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. . /etc/rc.conf
  4. . /etc/rc.d/functions
  5. . /etc/conf.d/phc-k8.conf
  6.  
  7. case "$1" in
  8.     start)
  9.         stat_busy 'Setting PHC-K8 rules'
  10.         if [ ! -d /sys/module/phc_k8 ]; then
  11.             echo "'phc_k8' module is not loaded."
  12.             stat_fail
  13.         elif [ -z "$FIDS" ] && [ -z "$VIDS"]; then
  14.             echo "Nothing to do, please change the config in /etc/conf.d/phc-k8.conf"
  15.             stat_fail
  16.         else
  17.             if [ ! -e /sys/devices/system/cpu/cpu0/cpufreq/phc_fids ] && [ ! -e /sys/devides/system/cpu/cpu0/cpufreq/phc_vids ]; then
  18.                 echo "Can not set rules, devices did not exist."
  19.                 stat_fail
  20.                 exit 0
  21.             fi
  22.             for CPU in /sys/devices/system/cpu/cpu?; do
  23.                 [ -n "$FIDS" ] && echo $FIDS > $CPU/cpufreq/phc_fids 2> /dev/null
  24.                 [ -n "$VIDS" ] && echo $VIDS > $CPU/cpufreq/phc_vids 2> /dev/null
  25.             done
  26.             add_daemon phc-k8
  27.             stat_done
  28.         fi
  29.         ;;
  30.     stop)
  31.         stat_busy 'Resetting PHC-K8 rules to default'
  32.         if [ ! -d /sys/module/phc_k8 ]; then
  33.             echo "'phc_k8' module is not loaded."
  34.             stat_fail
  35.         else
  36.             for CPU in /sys/devices/system/cpu/cpu?; do
  37.                 cat $CPU/cpufreq/phc_default_fids > $CPU/cpufreq/phc_fids 2>/dev/null
  38.                 cat $CPU/cpufreq/phc_default_vids > $CPU/cpufreq/phc_vids 2>/dev/null
  39.             done
  40.             if [ $? -gt 0 ]; then
  41.                 stat_fail
  42.             else
  43.                 rm_daemon phc-k8
  44.                 stat_done
  45.             fi
  46.         fi
  47.         ;;
  48.     restart)
  49.         $0 start
  50.         ;;
  51.     setup)
  52.         if [ ! -n "$INSTALL_DIR" ]; then
  53.             echo "\$INSTALL_DIR is not defined!"
  54.         else
  55.             TMPDIR="/tmp/phc-k8"
  56.             LOG="/var/log/phc-k8.log"
  57.             if ! mkdir -m 0755 -p $TMPDIR 2>/dev/null; then
  58.                 echo "Can not create temp dir!"
  59.                 stat_fail
  60.                 exit 0
  61.             fi
  62.             cp $INSTALL_DIR/* $TMPDIR && cd $TMPDIR
  63.             if find /lib/modules/`uname -r` -name "phc_k8\.*" 2>/dev/null|grep -q phc_k8; then
  64.                 stat_busy "Removing old phc-k8 kernel module"
  65.                 find /lib/modules/`uname -r` -name "phc_k8\.*" 2>/dev/null|xargs rm -f 2>/dev/null
  66.                 stat_done
  67.             fi
  68.             stat_busy "Recompiling phc-k8 kernel modules"
  69.             if ! make install >> $LOG 2>&1;then
  70.                 echo "Look at $LOG to find out what went wrong"
  71.                 stat_fail
  72.                 exit 0
  73.             fi
  74.             stat_done
  75.         fi
  76.         ;;
  77.     *)
  78.     echo "usage: $0 {start|stop|restart|setup}"
  79. esac
  80. exit 0