home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- #
- # chkconfig: - 90 90
- # description: Starts and stops "laptop-mode" - tweaks system behavior
- # to extend battery life.
- #
- # config: /etc/laptop-mode/laptop-mode.conf
-
- ### BEGIN INIT INFO
- # Provides: laptop-mode
- # Should-Start: $all
- # Required-Start: $remote_fs
- # Required-Stop: $remote_fs
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Enable laptop-mode-tools power management functions
- # Description: Enable laptop-mode-tools power management functions
- ### END INIT INFO
-
-
- test -f /usr/sbin/laptop_mode || exit 0
-
- . /lib/lsb/init-functions
-
- # Check that laptop-mode is enabled
- if [ -f /etc/default/laptop-mode ]; then
- . /etc/default/laptop-mode;
- fi
-
- # FIXME: this shouldn't be configured there
- if [ -f /etc/default/acpi-support ]; then
- . /etc/default/acpi-support;
- fi
-
- if [ x$ENABLE_LAPTOP_MODE = xfalse ]; then
- exit 0;
- fi
-
- # Enable laptop mode when the system is booted when running on battery.
-
- case $1 in
- start)
- log_action_begin_msg "Enabling laptop mode"
- mkdir -p /var/run/laptop-mode-tools
- touch /var/run/laptop-mode-tools/enabled
- RESULT=`/usr/sbin/laptop_mode init auto`
- log_action_end_msg $? "$RESULT"
- ;;
-
- restart|reload|force-reload)
- # Full restart: first stop laptop mode completely (to restore default mount options etc.)
- log_action_begin_msg "Disabling laptop mode"
- mkdir -p /var/run/laptop-mode-tools
- rm -f /var/run/laptop-mode-tools/enabled
- RESULT=`/usr/sbin/laptop_mode init stop`
- log_action_end_msg $? "$RESULT"
-
- # Now remove files containing stored status, re-enable, and start it up again.
- log_action_begin_msg "Enabling laptop mode"
- rm -f /var/run/laptop-mode-tools/*
- touch /var/run/laptop-mode-tools/enabled
- RESULT=`/usr/sbin/laptop_mode init auto force`
- log_action_end_msg $? "$RESULT"
- ;;
-
- stop)
- log_action_begin_msg "Disabling laptop mode"
- rm -f /var/run/laptop-mode-tools/enabled
- RESULT=`/usr/sbin/laptop_mode init stop`
- log_action_end_msg $? "$RESULT"
- ;;
-
- status)
- echo "Laptop mode status:"
- echo
- /usr/sbin/laptop_mode status
- ;;
-
- *)
- echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
- exit 2
- ;;
- esac
-
- exit 0
-