我的系统无头运行,在通电时启动,并在启动结束时通过/etc/init中的.conf文件自动启动一些软件。这将启动启动软件的脚本。该脚本会一直等到最后一个应用程序退出(其他应用程序已经退出),然后尝试停止计算机以便它可以安全地关机。
我无法停止工作。如果计算机没有正确关闭,它可能会在下次供电时挂起,因为它显然会永远等待响应。
我尝试编辑/etc/sudoers以允许/sbin/halt不需要密码,尝试对包含命令/sbin/halt的脚本执行相同操作,但没有任何效果;最后一个应用程序运行、退出,然后什么也没有发生。
如何设计一个脚本来自动停止机器?
/etc/init 配置文件:
description "Copies fireimager executeables to the ram disk and executes them."
author "Robert Lockwood"
start on net-device-up
stop on shutdown
script
echo "[`date`] Fireimager initializing Started" >> /var/log/fireimager.log
exec /home/programmer/bin/init/inittest
end script
/home/programmer/bin/init/inittest(片段)
#!/bin/bash
# this script is extecuted by root when the interfaces become active.
# when the last application shuts down the computer is commanded to shut down.
# start the micro-server
su -c "/home/programmer/bin/startServer &" user-name password -
# start fireimager controller
su -c "/home/programmer/bin/startController" user-name password -
# following appears in the log
echo "[`date '+%a %b %2d %T.%3N %Z %Y'`] Starting poweroff" >> /var/log/fireimager.log
# when the controller shuts down, then poweroff FAILS
su -c "sudo /home/programer/bin/halt" user-name password -
~/bin/暂停脚本
#!/bin/bash
# This should halt the computer
/sbin/halt