I made this 2 script on my Ubuntu.
The first one (Startup_Nas.sh) is to start up the NAS, the second one is to keep it running while the user have the share connected. When the user dismount the share, the script does not send WOL anymore, and after a while, the NAS shutdown.
I'd like to link the first script to the Place-bookmark link, but I don't find a way for it....
So, the user must call the first script, wait the NAS is up&running, before trying to access the share.
The second script can be started at user logon, and must be executed with users's permissions and settings: nobody else can access the $HOME/.gvfs to see if the share is alive.
In test, I started it as
nohup su - user_name -c /usr/local/sbin/KeepUp_NAS.sh > /dev/null &
one for every user_name.
Any suggestion is appreciated! :)
Oscar
Startup_Nas.sh
#!/bin/bash
for (( i=0; i<3; i++ )) ;
do
/usr/bin/wakeonlan -i ip_address mac_address
done
exit
----------
KeepUp_NAS.sh
#!/bin/bash
while (/bin/true) ;
do
if [[ -d "/home/$LOGNAME/.gvfs/NAME_OF_SHARE" ]] ; then
for (( i=0; i<3; i++ )) ;
do
/usr/bin/wakeonlan -i ip_address mac_address
done
else
echo "Nothing to do!";
fi
sleep 30
done
exit