NAS540: How to make Wake on Lan work after UPS shutdown?

MarkusDesk
MarkusDesk Posts: 31
First Comment First Anniversary
 Freshman Member
Hello,
I have a NAS540 connected to an APC UPS. The automatically shutdown works fine when it detects that the UPS battery is going low. The problem is that the Wake on Lan does not work after this shutdown and I have to power it up again manually. Does anyone have any clue(maybe a script?) of how can I maintain the Wake on Lan activated after a UPS commanded shutdown?

All Replies

  • Mijzelf
    Mijzelf Posts: 2,215
    100 Answers 1000 Comments Friend Collector Fifth Anniversary
     Guru Member
    Wake on lan works when you just execute shutdown from the command line. So apparently the UPS daemon shuts down in another way. Don't know which daemon the 540 uses, if it uses apcupsd, it will call /etc/init.d/halt, or something like that. So maybe you can just edit that script to execute shutdown.
  • MarkusDesk
    MarkusDesk Posts: 31
    First Comment First Anniversary
     Freshman Member
    Hello Mijzelf, thanks for replying. Seems the file locations are a little different, but it does use the apcupsd. I will try to make some tests. If I edit it, will it persist after a reboot?
  • Mijzelf
    Mijzelf Posts: 2,215
    100 Answers 1000 Comments Friend Collector Fifth Anniversary
     Guru Member
    Depends on where the script is located. If it's inside /etc/zyxel/ or /i-data/ it will persist, in most other cases it won't.
  • MarkusDesk
    MarkusDesk Posts: 31
    First Comment First Anniversary
     Freshman Member
    edited November 2022
    Hello, thanks. I just found a weird thing: If the NAS shuts off automatically when it detects that the UPS battery is low and I turn it on again with the power button(as the wake on lan does not work after this shut off). The wake on lan will never work again even if I shut it down by the web interface or by the poweroff command. The wake on lan will only work again if I shut it down, disconnect the power supply and connect it again! Any tips how to solve it? 

    Another question: how can I make the changes in the script permanent if it is not inside /etc/zyxel/ or /i-data/ ?

    Seems the /etc/apcupsd contains the config files.
    one of the files is the apccontrol. Here are some of this file contents:
    prefix=/usr
    exec_prefix=${prefix}

    APCPID=/var/run/apcupsd.pid
    APCUPSD=apcupsd
    SHUTDOWN=/sbin/halt
    SCRIPTSHELL=/bin/sh
    SCRIPTDIR=/etc/apcupsd
    WALL="zylogger -s 18 -p 5 -f 18"

  • Mijzelf
    Mijzelf Posts: 2,215
    100 Answers 1000 Comments Friend Collector Fifth Anniversary
     Guru Member
    I just found a weird thing

    That looks like an electrical problem. Is the UPS earthed?

    Another question: how can I make the changes in the script permanent if it is not inside /etc/zyxel/ or /i-data/ ?

    By executing a script on boot, which replaces the file. And maybe restarts apcupsd. Do you have any 3th party software installed?


  • MarkusDesk
    MarkusDesk Posts: 31
    First Comment First Anniversary
     Freshman Member
    Hi, thanks for replying. I am sure it is not an electrical issue. I also tested it without connecting the power supply to the UPS, just the USB cable and simulating as power loss and same happens.  Seems that the shutdown command issued by the apcupsd disables the wake on lan and it is only possible to reactivate it(the wake on lan) if I remove the power supply and connect it again. Maybe it is issuing some command to the network chip?

    I have the MetaRepository repository and I am only using only the following firmware tweaks:
    cdsdaemon.pyc    
    NSU agent    
    /bin/rbm.sh    
    MZCA_auto_install.pyc    
    /sbin/ntpdate_sync.sh 

    And I also have the RandomTools installed.







  • Mijzelf
    Mijzelf Posts: 2,215
    100 Answers 1000 Comments Friend Collector Fifth Anniversary
     Guru Member
    It's hard to imagine that you could shutdown the box by software, in a way that WOL doesn't work, and that situation survives a new, know-good shutdown.

    According to your config file apcupsd calls '/sbin/halt' to shutdown. There used to be a difference between 'halt' and 'poweroff'. Halt just brings the OS down, while poweroff also switches off the box. It sends different signals to the kernel. Years ago I studied the kernel sources for the NSA325, and found that there the signals were treated the same, due to a ZyXEL patch, but I don't know how it is for the NAS series. *If* halt doesn't actually poweroff the box, then it's possible that for that reason WOL doesn't work. But after a powerup by button that should be repaired.

    Anyway, it's easy to test if 'halt' is the culprit. Just execute halt from the commandline, and look if WOL works.

    Both Tweaks and RandomTools are able to run custom scripts on boot. For Tweaks you can use the cron daemon, with time @reboot you can execute a script as soon as Tweaks starts. RandomTools has it's own directory with scripts which are executed on boot. These scripts install the tools on each boot. If you add your own scripts they will be executed either. The directory is /i-data/sysvol/.PKG/RandomTools/etc/custom_scripts/ or something like that.

  • MarkusDesk
    MarkusDesk Posts: 31
    First Comment First Anniversary
     Freshman Member
    edited November 2022
    Hello Mijzelf, thanks again for replying. I tried the halt command, but the wake on lan works after it...
    But a few months ago I noticed that after I updated the NAS firmware from AATB.7 to the AATB.8, sometimes after a software reboot, I cannot access the the NAS and I need to shut it down using the power button(it shuts down gracefully). So I am thinking about downgrading the firmware(I already know how to do it). But before doing that, let me ask you: If I downgrade to AATB.7, is there any risk of affecting my Raid5 array that I created after upgrading to AATB.8 or the MetaRepository or Random tools?
  • Mijzelf
    Mijzelf Posts: 2,215
    100 Answers 1000 Comments Friend Collector Fifth Anniversary
     Guru Member
    A such a small downgrade shouldn't have any impact on those items, not more than the corresponding upgrade.
  • MarkusDesk
    MarkusDesk Posts: 31
    First Comment First Anniversary
     Freshman Member
    Hello Mijzelf, thank you very much! Downgraded to AATB.7 and all problems problems are solved!

Consumer Product Help Center