URL Shutdown

MickeiHudik
MickeiHudik Posts: 7  Freshman Member
edited November 2019 in Personal Cloud Storage
Can I send a url command to NSA325v2 for shutdown?
Does anyone out there know this?

/Micke


#NAS_Nov_2019
«1

All Replies

  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
    Not that I'm aware of. What is your goal?
  • MickeiHudik
    MickeiHudik Posts: 7  Freshman Member
    edited November 2019
    I want to shutdown NSA325v2 when power goes down.
    The UPS I use is not supported by the USB-port on NSA325v2.
    Only APC-UPS is supported, and I have a EATON 3S UPS 700VA/420W UPS.
    My Telldus SmartHome system can detect power down, and can send a URL command.
  • MickeiHudik
    MickeiHudik Posts: 7  Freshman Member
    edited November 2019
    I have found an URL command for remote shutdown on Lacie Ethernet Disk mini:
    URL = "http://admin:******@192.168.1.XXXX/cgi-bin/admin/reboot?action=shutdown"

    That URL don´t seem to work on my NSA325v2,
    but that´s why I hope there is a similar URL command for my NSA325v2.
  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
    There are some URL's available on the 325, from which the most used is the telnet backdoor, (which AFAIK needs you to first login, before it will work on the same browser). There are a few more, but none of the cgi files contain a string 'shutdown' or 'halt' or 'poweroff'. So I don't think you can shutdown the NAS this way.

    If your SmartHome system can also use ssh, you could use the command 'ssh root@nsa325 poweroff', provided that you can install keys on both the NAS and the SmartHome.

    If you also shutdown other systems, and your UPS lasts a few minutes longer, you can also use the Shutdown Daemon in Tweaks, which can shutdown the box if some extern IP address if no longer pingable. To install Tweaks you'll first have to install MetaRepository.

  • MickeiHudik
    MickeiHudik Posts: 7  Freshman Member
    First of all...
    Thank you, Mijzelf, for your help!

    I have earlier tested SSH from my computer, and succeeded with remote shutdown on my NSA325v2 with use the command "ssh root@192.168.10.21 poweroff".
    But I have not found out a way to send SSH command from my SmartHome controller.

    By the way ... A question about SSH ...
    When I send the command "ssh root@192.168.10.21 poweroff",
    I get a password question "root@192.168.10.21's password:."
    Can you send the password in the ssh command line?

    Your suggestion with "Shutdown Daemon in Tweaks" sounds interesting.
    I'll check that out.
    There should be some suitable unit in the house to ping that always is on, but that turns off in the event of a power failure.
  • MickeiHudik
    MickeiHudik Posts: 7  Freshman Member
    The next question is how to get the NSA325v2 up and running when the power has returned.
    I can start the NSA 325v2 manually with WakeOnLan from my computer.
    But then I might as well go and press the power button on NSA325v2.
    After all, I want the NSA325v2 to shut down in orderly form when there is a power outage, and I want it to start automatically when the power comes back.

    My idea is that I should be able to use the "Power On After Power Failure" feature in NSA325v2 and set "Always Power On. The system automatically restarts when the power is restored.".
    This can fail if the power returns before the UPS turns off. Then NSA325v2 will not feel that incoming power has disappeared and then returned, and will not restart.
    One solution could be that with the SmartHome controller, the power to NSA325v2 automatically switches off with a remote switch a few minutes after a power failure, to allow time for orderly shutdown. And when the power returns, SmartHome turns on the remote switch to NSA325v2, which then senses that the power has returned and starts automatically.

    Are there other ideas to solve this?
  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
    Can you send the password in the ssh command line?
    Officially not. There are some work-arounds, like using expect or sshpass, but I don't think your SmartHome will support that.

    Are there other ideas to solve this?
    Have another box send a wakeonlan message, after boot?

  • MickeiHudik
    MickeiHudik Posts: 7  Freshman Member
    I looked at your expect or sshpass link, but I haven't tested. The description was for Linux and I have Windows on my computers, so I don't know if these options work on my computers either.

    And as you write, I don't think these solutions work with my Telldus Znet SmartHome controls. Although I do not know, Telldus Znet can run Lua script, and is Linux based, so maybe there is a solution. But I haven't delved into Lua programming and don't know what opportunities there are.
  • MickeiHudik
    MickeiHudik Posts: 7  Freshman Member
    On my question about "start up when the power is back" you write: "Have another box send a wakeonlan message, after boot?".

    What kind of box are you thinking of?
    When I use WakeOnLan, I have used the WakeMeOnLan program on my computer or the WakeOnLan feature in my Asus router. Both of these options are manual.
    Do you have any tips on how to automate the WakeOnLan command?
  • Mijzelf
    Mijzelf Posts: 2,598  Guru Member
    First Anniversary 10 Comments Friend Collector First Answer
    Telldus Znet can run Lua script, and is Linux based, so maybe there is a solution. But I haven't delved into Lua programming and don't know what opportunities there are.

    AFAIK lua is Turing complete, so the question is not 'can lua do it', but, 'will the VM lua is running in let me do it'.

    What kind of box are you thinking of?

    Well, anything which knows the power is back (either by sensing or by being powered up or because the UPS said so) which can run a user provided script.

    Do you have shell access to any (linux) box which is aware of the power return?

    That Asus router, can that work automatic? I know that Fritzbox supports 'wake on access', as soon as someone accesses an IP a WOL signal is send. If the Asus can do that, and if the Telldus supports URL commands on power up, you could access the NAS that way.

    Or if the Asus supports URL commands to send a wake on lan, you can use that. The most elegant way would be if the Telldus could send the wol packet. I tried to find some information about that device, but unfortunately all interesting community activity seems to be in Swedish, like this thread.

    BTW, there is a problem with wol on the 325. A wol packet is any packet which has a few copies of the MAC address of the device inside, starting at a certain offset. Normally it's handled by the NIC itself. Problem is that the NIC on a 325 doesn't know it's own MAC address. The address is stored in flash, where it is read by some script during Linux boot, and written to the NIC. From then  the NIC knows it, even when you shutdown the box. But when you cut the power for more than a few minutes, it will be forgotten, and the MAC will return to it's powerup default, 00:00:00:00:00:30. So in your case you'll have to send the magic packet to 2 MAC addresses, as you can't know which one will listen.

    Although, if you enable both boot up on power up, only the 'real' MAC address is enough.



Consumer Product Help Center