QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1701|回复: 6

笔记本acpi模块的起动脚本。

[复制链接]
发表于 2003-9-17 23:00:20 | 显示全部楼层 |阅读模式
这是笔记本acpi模块开机起动的两个脚本,现附上:
     acpi:
#!/bin/bash
#
# chkconfig: 2345 04 70
# description: Load modules for acpi for fan battery thermal and all \
#               the informations you can get from your laptop

#Sources Functions
. /etc/rc.d/init.d/functions

MODULES="battery ac fan thermal button"

#EXIT
RETVAL=0

[[ -d /proc/acpi ]] || exit 1

function start () {
    for mod in $MODULES;do
        message="Loading ACPI module $mod:"
        modprobe $mod 2>/dev/null >/dev/null
        if [[ $? != 0 ]];then
            message="$message failed"
            RETVAL=1
        else
            message="$message successfull"
        fi
        logger -t "INIT" $message
    done
}

function stop () {
    for mod in $MODULES;do
        modprobe -r $mod 2>/dev/null >/dev/null
    done
}

function status() {
    loaded=
    gprintf "Modules Loaded: \n"
    for mod in $MODULES;do
        if grep -q "^$mod " /proc/modules;then
            loaded="$loaded $mod"
        fi
    done
    if [[ -n $loaded ]];then
        for i in $loaded;do gprintf "\t\t\n" $i;done
    else
        gprintf "\t\tNothing\n"
        RETVAL=1
    fi
}

# see how we were called.
case "$1" in
  start)
        start
        touch /var/lock/subsys/acpi
        ;;
  stop)
        stop
        rm -f /var/lock/subsys/acpi
        ;;
  status)
        status
        ;;
  restart)
        stop
        start
        ;;
  *)
        gprintf "*** Usage: devfsd {start|stop|status|restart|reload}\n"
        exit 1
esac

exit 0

这是acpid----acpi daemon
#!/bin/bash
#
#        /etc/rc.d/init.d/acpid
#
# Starts the acpi daemon
#
# chkconfig: 345 44 56
# description: Listen and dispatch ACPI events from the kernel
# processname: acpid

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

DAEMON=acpi
PROGNAME=${DAEMON}d
test -x /usr/sbin/$PROGNAME || exit 0

RETVAL=0

#
# See how we were called.
#

start() {
        # Check if it is already running
        if [ ! -f /var/lock/subsys/$PROGNAME ]; then
            gprintf "Starting %s daemon: " "$DAEMON"
            daemon /usr/sbin/$PROGNAME
            RETVAL=$?
            [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROGNAME
            echo
        fi
        return $RETVAL
}

stop() {
        gprintf "Stopping %s daemon: " "$DAEMON"
        killproc /usr/sbin/$PROGNAME
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROGNAME
        echo
        return $RETVAL
}


restart() {
        stop
        start
}       

reload() {
        trap "" SIGHUP
        killall -HUP $PROGNAME
}       

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        restart
        ;;
condrestart)
        if [ -f /var/lock/subsys/$PROGNAME ]; then
            restart
        fi
        ;;
status)
        status $PROGNAME
        ;;
*)
        INITNAME=`basename $0`
        gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" "$INITNAME"
        exit 1
esac

exit $RETVAL
 楼主| 发表于 2003-9-17 23:03:11 | 显示全部楼层
没有acpi脚本,即使kernel里编译了apci模块,开机也不会默认起动的。
这两个模块位于/etc/rc.d/init.d下。好像内核版本要>=2.4.21
回复

使用道具 举报

发表于 2003-9-17 23:54:24 | 显示全部楼层
纳入。
系统安装后缺省关闭。
回复

使用道具 举报

 楼主| 发表于 2003-9-18 00:11:50 | 显示全部楼层
内核选项里边kernel hacking可别选,那会导致不稳定。
回复

使用道具 举报

发表于 2004-10-28 14:45:18 | 显示全部楼层
提问,这两个脚本怎么用?保存成.sh文件?运行他?还是别的什么办法?
回复

使用道具 举报

发表于 2004-10-29 17:46:02 | 显示全部楼层
放到/etc/rc.d/init.d下面,然后设置一下开机启动,比如:
#chkconfig --level 12345 on acpid
这个脚本可以直接从其他发行版比如gentoo copy过来的嘛。
回复

使用道具 举报

发表于 2004-10-29 17:48:38 | 显示全部楼层
3q,等下就try

不过启动之后怎么样设置呢?比如何时待机等……
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-3-29 00:27 , Processed in 0.052691 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表