5

I want to be able to shutdown my CentOS 7 machine by pressing the power button. Since it doesn't work out of the box, I tried the following:

yum -y install acpid
service acpid start
chkconfig acpid on

Unfortunately without effect, probably because this was valid for CentOS 6.x only. Does anyone know how to enable shutdown by pressing the power button?

1

I had this problem too.

Essentially, what you'll see in your logs (if systemd is configured properly, either method above works--systemd translates the old 'service' commands for you... at least in CentOS7)

Nov 20 11:12:06 localhost systemd-logind: Power key pressed.
Nov 20 11:12:06 localhost systemd: SELinux policy denies access

So, you then need to cruise on over to /var/log/audit/audit.log and you'll see something like this:

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=?'

OK, why are system configuration files not in /etc anymore? Anyway, I digress....something about /usr/lib/systemd/system/poweroff.target is off?: BTW, I really like how the new automated files obfuscate themselves now... There is no real direction to go now... this file is completely useless. What do any of these options mean? I'm guessing job security for some PFY-admins... and more overtime for me. (must be another 'feature'!)

#  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

OK, at this point, we have enough information to really look for an answer. The problem is an SELinux policy that is preventing systemd from shutting the system down.

Et voila! There is a bug against it: https://bugzilla.redhat.com/show_bug.cgi?id=1224211

Essentially, around comment #60 or so they figure out that there is a policy error. It'll be fixed via regular updates, but I wanted to install only the packages from the 'everything dvd'. So, it looks like I have to wait until 7.2 is released by the CentOS guys to fix this problem!

4

RHEL 7 and therefore Centos 7 have made the switch from System V (SysV) startup scripts and runlevels to systemd. The commands to activate acpid should thus be:

systemctl start acpid
systemctl enable acpid

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.