[REQUEST] SOL (Shutdown On LAN) python script
#31
That would be very nice!!

I also have two xbox mediacenters and a script like that will be very welcome!

thanks,
Ron

ozNick Wrote:Alternatively you could write a script for the FreeNAS server that pings your XBoxes and when it can't reach either of them after a period of time (say 10 mins) it would shutdown.

Cheers Nick
Reply
#32
Anavatos Wrote:That would be very nice!!

I also have two xbox mediacenters and a script like that will be very welcome!

The shell script would live on the FreeNAS server and be run as a cron job every so often (say 10 mins).

Here is one I use that works with 2 hosts (xboxs), but could easily be expanded to many hosts.

It checks if first host is up, and if not checks if the second is up, and if not calls a shutdown and power off.

Code:
if [ "`id -u`" = "0" ]; then
        touch /var/log/check_if_up.log  # Create log if not exist

        if [ `ls -la /var/log/check_if_up.log | awk '{print $5}'` -gt 1048576 ]; then
                mv /var/log/check_if_up.log /var/log/check_if_up.old    # Backup log >1meg
                touch /var/log/check_if_up.log  # Create a new log

        fi

        ping -c 4 -q 192.168.1.10 > /tmp/check_1.tmp    # Test to see if 1st Host is up
        ping -c 4 -q 192.168.1.3 > /tmp/check_2.tmp     # Test to see if 2nd Host is up

        if [ "`cat /tmp/check_1.tmp | awk '{print $1}' | tail -n 1`" = "round-trip" ]; then
                echo The 1st Host is up... `date "+%Y-%m-%d %H:%M:%S"` >> /var/log/check_if_up.log

        elif [ "`cat /tmp/check_2.tmp | awk '{print $1}' | tail -n 1`" = "round-trip" ]; then
                echo The 1st Host is down... `date "+%Y-%m-%d %H:%M:%S"` >> /var/log/check_if_up.log
                echo The 2nd Host is up... `date "+%Y-%m-%d %H:%M:%S"` >> /var/log/check_if_up.log

        else
                echo All Hosts are down. Shutdown FreeNAS at `date "+%Y-%m-%d %H:%M:%S"` >> /var/log/check_if_up.log
                /bin/sync
                /sbin/shutdown -p now

        fi

fi

Assumption is you know enough to create the shell script, set it executable and run it as root from cron.

Cheers Nick
Reply
#33
I created a tiny little python script for this ages ago which was basically about three lines long. Lacked subtlety Simply used the web interface to switch the other xboxes off.

Simple but it worked. :-)

Mind you I didn't put any timer on it. Just meant that you could click it and switch off all of the xboxes in the house simultaneously. Required the xboxes to be on static IP too though.
Reply
#34
Rainbow 
hehe just read. What you want is obviously different from that tiny thing. I may even post it up if I'm ever back at my normal address. Not that there's anything to my script. There's so little in it I really hasten to count it as a script at atll Smile
Reply
#35
Assumption is you know enough to create the shell script, set it executable and run it as root from cron.

Thanks, i will give it a try!Eek
Reply
#36
With XBMC Scripts being dead, where can I get the python script to remotely shut down my PC via another machine running XBMC, both on the same LAN?
Reply
#37
Good qustion does anyone have a new python script for shutdown4lan?
Reply

Logout Mark Read Team Forum Stats Members Help
[REQUEST] SOL (Shutdown On LAN) python script0