CastlesBlog.com

a blog about a blog

Subscribe

MythTV Pre-Shutdown script

Just like my previous post this is here so I won't forget how I setup my MythTV pre shutdown script. This will check for netatalk connections, terminal (via ssh or locally) or if transmission is open.

Script file: /usr/bin/mythpreshutdown.sh

#!/bin/sh

logfile=/var/log/mythtv/mythpreshutdown.log
echo `date` > $logfile

ps_afpd=`ps axo euid,comm,user | grep afpd | grep -v -c root`
ps_who=`who | grep -c pts`
ps_transmission=`ps aux | grep transmission | grep -v -c grep`

SD=0

if [ $ps_who != 0 ]; then
  echo "user logged in" >> $logfile
  SD=1
fi

if [ $ps_afpd != 0 ]; then
  echo "afpd connection exists" >> $logfile
  SD=1
fi

if [ $ps_transmission != 0 ]; then
  echo "transmission running" >> $logfile
  SD=1
fi

exit $SD
Post Comment