On shutdown, computer reboots when started via wake on lan

Here's the situation:

I start my main computer from another pc via wake on lan "wakeonlan ". All works fine. When I'm done doing what I did, I run "sudo shutdown -h now" (in the ssh terminal in which I was working) to shutdown the computer. But instead of shutting down, it reboots. I then have to reconnect to it via ssh and run the shutdown command again, and then it shuts down and stays off. I can then start it again via wake on lan...

does anyone know, why my computer actually reboots when I type "sudo shutdown -h now" when started via wake on lan?

Some information about the computer:

Ubuntu 13.04
Moterboard: Gigabyte GA-Z77X-UD3H
Ethernet Controller (as reported by "lspci"): Qualcomm Atheros AR8151 v2.0 Gigabit Ethernet (rev c0)


Solution 1:

There's one dirty solution

a) create /etc/init.d/reshutdown with the contents

#!/bin/sh
# force shutdown (due to bug in wakeonlan)
#


case "$1" in
reshutdown)
  touch /home/shutdown.chk
  shutdown -r now
;;

start)
 if [ -f /home/shutdown.chk ];
 then
    rm /home/shutdown.chk
    shutdown -h now
 fi
;;
esac

b) Execute: sudo chmod ugo+x /etc/init.d/reshutdown
b) Execute: sudo update-rc.d reshutdown start 1 1 2 3 4 5 6 .

c) Then to shutdown execute: sudo service reshutdown reshutdown

Solution 2:

I had this issue too, using the Intel DQ77MK motherboard, which has 2 onboard Intel GB ethers. I fixed it by enabling the power bios entry "Native ACPI OS PCIe Support", which I guess allowed Ubuntu to reset the flag saying WOL has been triggered, probably with it disabled Ubuntu was not allowed by the BIOS to reset the flag.