Add code to shut down when no network connection

Hi.
I use mycloud for one specific purpose, that it is connected directly to my Playstation 2 and stores games that are loaded via smb share. No other use. Only thing I dont like is that it is powered all the time.

Im wondering if it is possible to edit a script to power off the mycloud when it no longer detects a network. Turning off the PS2 causes network loss.

When it detects lose of network, the white led starts flashing, whatever script initiates this behaviour, I would like to add the power off/shutdown command also.

Anyone know of such a script, and what the shutdown command is?

So after a bit of searching I found the script that detects the network is down, enables the white flashing led and logs the message “networkLinkDown”.

\etc\ifplugd\action.d\ifupdown

#!/bin/sh
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

. /etc/nas/config/share-param.conf
. /etc/nas/alert-param.sh
[ -f /usr/local/sbin/ledConfig.sh ] && . /usr/local/sbin/ledConfig.sh

set -e

link_up=/tmp/link_up
link_down_after_up=/tmp/link_down_after_up

case “$2” in
up)
#ITR# 69883 found that Apache needed to be restarted(not just reloaded) to
#support forcing UI access to only occur on same network.
#ITR# 75893 found that when host name is changed and interface goes up and
#down, Apache task doing rename is not allowed to finish and all services
#are not restarted with new name.
#/tmp/restartApache is used to signal when Apache needs to be restarted.
touch /tmp/restartApache
/sbin/ifup -v $1
rm /tmp/restartApache || true
touch $link_up
if [ “getSystemHealth.sh” == “good” ] && [ “getSystemState.sh” == “ready” ]; then
## change led color to ok (green)
ledCtrl.sh LED_EV_NETWORK LED_STAT_OK
fi
if [ -f $link_down_after_up ]; then
sendAlert.sh “${networkLinkDown}”
rm $link_down_after_up
fi
;;
down)
/sbin/ifdown --force -v $1

## change led color to error
ledCtrl.sh LED_EV_NETWORK LED_STAT_ERR

if [ -f $link_up ]; then
    touch $link_down_after_up
    rm $link_up
fi
;;

esac

Question: How can I add the shutdown command to execute after the change led color to error?
ledCtrl.sh LED_EV_NETWORK LED_STAT_ERR

Note: I am using WDMyCloud, single bay, Firmware v04.05.00-320.

It appears that I put in the below line:

##change led color to error
ledCtrl.sh LED_EV_NETWORK LED_STAT_ERR

##power off
/sbin/shutdown -h -P now