aniuge007 发表于 2003-9-17 23:00:20

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

这是笔记本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

aniuge007 发表于 2003-9-17 23:03:11

没有acpi脚本,即使kernel里编译了apci模块,开机也不会默认起动的。
这两个模块位于/etc/rc.d/init.d下。好像内核版本要>=2.4.21

cjacker 发表于 2003-9-17 23:54:24

纳入。
系统安装后缺省关闭。

aniuge007 发表于 2003-9-18 00:11:50

内核选项里边kernel hacking可别选,那会导致不稳定。

tonnyxu 发表于 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过来的嘛。

tonnyxu 发表于 2004-10-29 17:48:38

3q,等下就try

不过启动之后怎么样设置呢?比如何时待机等……
页: [1]
查看完整版本: 笔记本acpi模块的起动脚本。