
電源ボタンを押して CentOS 7 マシンをシャットダウンできるようにしたいのですが、そのままでは動作しないので、次のことを試しました。
yum -y install acpid
service acpid start
chkconfig acpid on
残念ながら効果はありませんでした。おそらくこれは CentOS 6.x のみに有効だったためでしょう。電源ボタンを押してシャットダウンを有効にする方法をご存知の方はいらっしゃいますか?
答え1
RHEL 7 および Centos 7 では、System V (SysV) の起動スクリプトと実行レベルから systemd に切り替えられました。acpid をアクティブ化するコマンドは次のようになります。
systemctl start acpid
systemctl enable acpid
答え2
私もこの問題を抱えていました。
基本的に、ログに表示される内容は次のとおりです (systemd が適切に設定されていれば、上記のどちらの方法でも機能します。systemd は古い「サービス」コマンドを変換します...少なくとも CentOS7 では)
Nov 20 11:12:06 localhost systemd-logind: Power key pressed.
Nov 20 11:12:06 localhost systemd: SELinux policy denies access
次に、/var/log/audit/audit.log に移動すると、次のような内容が表示されます。
init_t:s0 msg='avc: denied { start } for auid=-1 uid=0 gid=0 path="/usr/lib/systemd/system/poweroff.target" scontext=system_u:system_r:apmd_t:s0 tcontext=system_u:object_r:power_unit_file_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
さて、システム構成ファイルはなぜ /etc にないのでしょうか? とにかく、話がそれましたが.../usr/lib/systemd/system/poweroff.target の何かがおかしいのでしょうか?: ところで、新しい自動化ファイルが自分自身を難読化するようになったのは本当に気に入っています... 今進むべき方向はありません... このファイルはまったく役に立ちません。 これらのオプションはそれぞれ何を意味するのでしょうか? PFY 管理者の一部には仕事の安定がもたらされると思います... そして私には残業が増えるでしょう。(別の「機能」があるに違いありません!)
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Power-Off
Documentation=man:systemd.special(7)
DefaultDependencies=no
Requires=systemd-poweroff.service
After=systemd-poweroff.service
AllowIsolate=yes
[Install]
Alias=ctrl-alt-del.target
さて、この時点で、答えを探すのに十分な情報が得られました。問題は、systemd がシステムをシャットダウンするのを妨げている SELinux ポリシーです。
すると、なんと!これにはバグがあります: バグ報告
基本的に、コメント #60 あたりで、ポリシー エラーがあることが判明しました。これは通常の更新で修正される予定ですが、私は「everything dvd」のパッケージのみをインストールしたいと考えていました。そのため、この問題を修正するには、CentOS の担当者が 7.2 をリリースするまで待つ必要があるようです。