#!/bin/bash # chkconfig: - 0 99 # description: script to apply cpu microcode # vars: # # START distribution specific way of kicking programs # END distribution specific way of checking return status # PROGRAM the executable to run # ARGUMENTS the argument we're going to call PROGRAM with DEVICE=/dev/cpu/0/microcode ARGUMENTS=-Qu RETVAL=0 PROGRAM=/sbin/microcode_ctl # Lets just be sure we have a device file... if [ ! -e $DEVICE ]; then echo $"$0: microcode device $DEVICE doesn't exist?" exit 1 elif [ ! -c $DEVICE ]; then echo $"$0: $DEVICE not a character device?" exit 1 fi if [ ! -e /etc/firmware/microcode.dat ]; then echo $"$0: microcode datafile not present (/etc/firmware/microcode.dat)" exit 1 fi . /etc/init.d/functions # perform the update function start () { RETVAL=1 # Make sure we are on an intel machine vendor=`cat /proc/cpuinfo | \ grep "^vendor_id" | sort -u | \ awk -F ": " '{ print $2 }'` if [ "$vendor" != "GenuineIntel" ]; then return fi # Microcode wasn't available until 686's. family=`cat /proc/cpuinfo | \ grep "^cpu family" | sort -u | \ awk -F ": " '{ print $2 }'` if [ $family -lt 6 ]; then return fi echo -n $"Applying Intel Microcode update: " /sbin/modprobe microcode lt=0 while [ ! -c /dev/cpu/microcode ]; do lt=$[lt+1]; [ $lt -gt 5 ] && break; sleep 1; done daemon $PROGRAM $ARGUMENTS RETVAL=$? # trap the most common case, errno 19 = no device if [ $RETVAL -eq 19 ]; then echo $"$0: kernel does not have microcode device support" fi /sbin/rmmod microcode echo } case "$1" in start|reload|force-reload|restart) start exit 0 ;; stop) ;; status) ;; *) echo $"Usage: $0 {start|restart}" exit 1 esac