The other day (after a power outage and a complete discharge of the UPS battery)
there was a need besides the automatic shutdown of the router at low
Charge UPS'a, also shutdown sabzhevoj storage.
It was decided to do this when the router itself was turned off.
by adding the necessary set of commands to rc.shutdown.
After picking cgi-scripts, the cherished command was received:
curl -d "powerAction=2" <storage_ip>:80/cgi/power/powerHandler.cgi
Moreover, if you pass authorization:
curl -d "username=admin&password=_passwd_here_" <storage_ip>:80/loginHandler.cgi
,
then we get the following parameters:
<input type = "hidden" name = "username" value = "admin">
<input type = "hidden" name = "sessionId" value = "q1pOmWykGFZUnSAjWG9189d1jnZGXBQcr5QDPcLmHB4Uhu21YZTUZWK68zCTYgV">
The most amazing thing about this is that powerHandler doesn't even try
pull off data from cookies when NAS storage is turned off / on,
despite the presence of the same LoginUser.
')
Everything described above is typical for firmware 2.6.3-20080530.
And finally, what is added to /etc/rc.shutdown:
if [ `ping -qc 3 <storage_ip> | awk '/packets/ { if ( $4 > 0 ) { print 1; } else { print 0; } }'` -eq 1 ]; then
echo "Send shutdown signal to storage"
curl -d "powerAction=2" <storage_ip>:80/cgi/power/powerHandler.cgi >/dev/null 2>&1
fi