Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > b7e8b4744017b3450a043405d3c98c86 > files > 1

i8kutils-1.33-1.fc15.i686.rpm

#!/bin/bash
#
# i8k          Make the system information and fan control available on Dell
#              laptops. Also enable multimedia buttons (volume up/down, mute)
#              usage on older laptops.
#
# chkconfig: - 10 90
# description: Make the system information and fan control available on Dell
#              laptops. Also enable multimedia buttons (volume up/down, mute)
#              usage on older laptops.

# Source function library.
. /etc/init.d/functions

# Source configuration (ENABLE_I8KBUTTONS)
. /etc/sysconfig/i8k

prog=i8kbuttons
amixer=/usr/bin/amixer
amount="10%"
module=i8k

RETVAL=0

start() {
	echo -n $"Loading $module kernel module: "
	if /sbin/modprobe i8k force=1 &>/dev/null; then
		echo_success
		RETVAL=0
		echo
	else
		echo_failure
		RETVAL=1
		echo
	fi

	# Start daemon only if ENABLE_I8KBUTTONS was set by the user
	if [ "${ENABLE_I8KBUTTONS}" = "yes" ]; then
		echo -n $"Starting $prog: "
		# If it's already running, then fail
		if pidofproc $prog &>/dev/null; then
			echo_failure
			RETVAL=1
		else
			$prog --up "$amixer -q set Master $amount+" --down "$amixer -q set Master $amount-" --mute "$amixer -q set Master 0" &
			echo_success
			touch /var/lock/subsys/i8k
			RETVAL=0
		fi
		echo
	fi
}

stop() {
	# Don't bother unloading the module, it doesn't make much sense...

	# Stop daemon only if ENABLE_I8KBUTTONS was set by the user or if
	# it is found to probably be running...
	if [ "${ENABLE_I8KBUTTONS}" = "yes" -o -f /var/lock/subsys/i8k ]; then
		echo -n $"Stopping $prog: "
		killproc $prog
		RETVAL=$?
		echo
		[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/i8k
	fi
}

i8kstatus() {
	# Check if the i8k module is leaded
	if [ -n "`lsmod | grep ^$module`" ]; then
		echo $"Module $module is loaded."
	else
		echo $"Module $module isn't loaded."
	fi
	# Status daemon only if ENABLE_I8KBUTTONS was set by the user
	if [ "${ENABLE_I8KBUTTONS}" = "yes" ]; then
		status $prog
	fi
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	i8kstatus
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|status}"
	exit 1
esac

exit $RETVAL