MichaelAnders Posted March 22, 2022 Share Posted March 22, 2022 (edited) Background: My Unraid server runs only when needed and I wake it up via WOL. A UPS powers Unraid server and several other hardware One hardware watches the UPS state and once power failure occurs it initiates SSH connections to other systems and requests them to shutdown Requirement: The Unraid server shall also be told to shutdown - but in a "clean" fashion as if was using the UI. Otherwise, the server will loose power and I'll have an "unclean shutdown" which is not cool and totally unneeded... Problem: No idea how to do that? It's clear that the "Shutdown" button on UI will "initiate" some code - which obviously triggers something in Unraid linux code. I could now spend time on figuring out how to log into my Unraid server using WGET etc., then simulate I am on the UI and pressing the "Shutdown" button to trigger that. But that's pretty stupid to do as the functionallity is available "somehow". Edited March 23, 2022 by MichaelAnders Quote Link to comment
Solution JonathanM Posted March 22, 2022 Solution Share Posted March 22, 2022 powerdown 1 Quote Link to comment
MichaelAnders Posted March 22, 2022 Author Share Posted March 22, 2022 Ah, cool! For my analysis so I understand it: I can find "powerdown" in /usr/local/sbin/powerdown. File content: #!/bin/bash logger "/usr/local/sbin/powerdown has been deprecated" if [[ "$1" == "-r" ]]; then /sbin/reboot else /sbin/init 0 fi So basically "/sbin/init 0" is triggered, which in turns (by Linux itself) triggers "/etc/rc.d/rc.0" which then does all the magic right? Perfect! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.