Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use Mageia ver 4 Linux as server, without X started and without any user login-in during normal operation. This PC has a special card for measuring and control of other devices. This card has its own SH4 Linux on-board, and needs to be shutdown first, before PC shutdown.

There is a set of commands supplied by the card vendor and they works properly. To shutdown the card it is necessary to execute /usr/sbin/io_card stop, wait for proper card shutdown and then execute "ordinary" PC shutdown.

I wrote a special shutdown script and it works properly. But the problem is when I press "Power" button on PC, it executes "ordinary" PC shutdown instead of my script.

I try to change /etc/acpi/events/power and systemd scripts to include my own shutdown script, but it does not work. At this moment /etc/acpi/events/power file contains only entry :

action=/home/serwer/Pobrane/shut

where "shut" is my shutdown script, working good when running manually. So how can I change default power-off action associated with depressing "Power" button?

share|improve this question
    
Please explain exactly how you tried to change ` /etc/acpi/events/power`. –  terdon Mar 17 at 15:36
    
The /etc/acpi/events/power file contains only entry action=/home/serwer/Pobrane/shut where "shut" is my shutdown script, working good when running manually. –  user180586 Mar 17 at 18:55
    
Did you try my answer? Also, please edit your question to add new info, it is easy to miss and hard to read in the comments. –  terdon Mar 17 at 18:57

1 Answer 1

I can't guarantee this will work on Mageia but this is how I got a similar thing to work on my Debian.

There is a script (on my machine, it's /etc/acpi/powerbtn-acpi-support.sh) that is run by default when the power button is pressed. Edit that script, and find this section:

if [ -x /etc/acpi/powerbtn.sh ] ; then
    # Compatibility with old config script from acpid package
    /etc/acpi/powerbtn.sh
elif [ -x /etc/acpi/powerbtn.sh.dpkg-bak ] ; then
        # Compatibility with old config script from acpid package
    # which is still around because it was changed by the admin
        /etc/acpi/powerbtn.sh.dpkg-bak
else
    # Normal handling.
    /sbin/shutdown -h -P now "Power button pressed"

fi

Change /sbin/shutdown -h -P now "Power button pressed" to point to your script instead, save the file and that should now be launched whenever you press the power button.

share|improve this answer
    
May /etc/acpi subdir contains two dirs: "action" and "events". So it is a little bit different to Yours –  user180586 Mar 17 at 18:57
    
OK, I edited my post. At this moment I de facto use the same solution as You described in Your post. The only diffrence is that in Your instalation, shutdown script is located in /etc/acpi/powerbtn-acpi-support.sh, in my Linux distro default location is /etc/acpi/events/power file. And this one was edited by me as described. –  user180586 Mar 18 at 6:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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