summaryrefslogtreecommitdiffstats
path: root/abs/core/linhes-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/linhes-scripts')
-rw-r--r--abs/core/linhes-scripts/PKGBUILD14
-rwxr-xr-xabs/core/linhes-scripts/idle.sh114
-rwxr-xr-xabs/core/linhes-scripts/limit-mythcommflag.sh4
-rwxr-xr-xabs/core/linhes-scripts/mythwelcome-config.py2
-rwxr-xr-xabs/core/linhes-scripts/pause-mythcommflag.sh2
5 files changed, 80 insertions, 56 deletions
diff --git a/abs/core/linhes-scripts/PKGBUILD b/abs/core/linhes-scripts/PKGBUILD
index 0dfb4e7..1dfe1ed 100644
--- a/abs/core/linhes-scripts/PKGBUILD
+++ b/abs/core/linhes-scripts/PKGBUILD
@@ -3,12 +3,12 @@
pkgname=linhes-scripts
pkgver=7
-pkgrel=47
+pkgrel=51
pkgdesc="Various scripts that help to make LinHES, LinHES."
arch=('i686' 'x86_64')
license=('GPL2')
depends=('xosd' 'cpulimit' 'screen' 'mencoder' 'tablet-encode' 'mplayer'
- 'normalize' 'handbrake-cli' 'mkvtoolnix')
+ 'normalize' 'handbrake-cli' 'mkvtoolnix' 'gnu-netcat')
url="http://linhes.org/"
install="linhes-scripts.install"
source=(
@@ -59,7 +59,7 @@ build() {
cd ${srcdir}
install -d ${pkgdir}/usr/LH/bin
install -d ${pkgdir}/usr/LH/etc
- install -D -m755 myth2* *.sh *.pl *.py vdpau* run-* pause_* LinHES* ${pkgdir}/usr/LH/bin/
+ install -D -m755 myth2* *.sh *.pl *.py vdpau* run-* LinHES* ${pkgdir}/usr/LH/bin/
install -D -m755 upgrade_screen_rc ${pkgdir}/usr/LH/etc/
mkdir -p ${pkgdir}/etc/sv/pause-mythcommflag/supervise
cp run-pause-mythcommflag ${pkgdir}/etc/sv/pause-mythcommflag/run
@@ -77,15 +77,15 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5'
'f8df7665903ddf822f5148bc8a074e4a'
'18263972b6326e140bbef0bb7dfa2da9'
'410795ef9039e4c6c0484e706ecfd567'
- '0750d7c65109d12aa536f312a38410d1'
+ 'ad98d51e79f83df7c03f828dbeaea7f4'
'ac2a4a6b4100f4d7bfb9ecd9356c8c6e'
'd2b475821f902c5e081e7da43a35e6ac'
'95c092f67036a361ef7a57436f44332e'
- '565ebca7b88bcd083322b7324f8e56e5'
+ '92950f0ffb1faf1ed64c6be2b8fbc3f6'
'3b776bbff68906ddc2f62b7e0dde3fe4'
- '15f3143d2b1369da431e4268029aba40'
+ 'a57641fb63d7bb6d92a438f1ea779a57'
'3d0adf26280cde55a0c47188fff34826'
- '25dd5b8ec0482d561b481bfce051d648'
+ 'c3ada01d3a739abe3f920b02d4ea3f6e'
'b2c3dd48a4abb976eda2d5fbf22a173a'
'b527b01d119d3bc33b8fa69bdf1082bb'
'9d077c24d102fa02e4f417d639d8b00a'
diff --git a/abs/core/linhes-scripts/idle.sh b/abs/core/linhes-scripts/idle.sh
index 70db6f0..4f6174c 100755
--- a/abs/core/linhes-scripts/idle.sh
+++ b/abs/core/linhes-scripts/idle.sh
@@ -1,12 +1,16 @@
#!/bin/bash
usage () {
- echo "Usage: $0 [-h] [-s] [-t <minutes_needed>] [-l] [-v]"
+ echo "Usage: $0 [-h] [-s] [-t <minutes_needed>] [-l] [-w] [-m] [-r] [-v]"
echo
echo "-h - Print this help/usage message and quit"
echo "-s - Run silently (default is verbose)"
echo "-t - Minutes of idle time needed (default is 20)"
echo "-l - Check for user logins (default: false - do not check)"
+ echo "-w - Check for open windows (default: false - do not check)"
+ echo "-m - Include mythshutdown daily wake, locked, & about to start wake in system busy"
+ echo " (default: daily wake, locked & about to start wake is system idle)"
+ echo "-r - Check if mythfrontends are running (default: false - do not check)"
echo "-v - Be more verbose for debugging"
echo
echo "Silent mode is recommended for use in cron jobs or scripts."
@@ -24,15 +28,21 @@ mysql_cmd () {
# Command line argument handling
VERBOSE=1
LOGINS=0
+WINDOWS=0
+DAILY=0
+RUNNING=0
TIME_BEFORE=20
TIME_AFTER=5 # Only adjustable by editing here
-while getopts "hslt:v" OPT ; do
+while getopts "hslwmrt:v" OPT ; do
case $OPT in
h) usage 0 ;;
s) VERBOSE=0 ;;
t) TIME_BEFORE=$OPTARG ;;
l) LOGINS=1 ;;
+ w) WINDOWS=1 ;;
+ m) DAILY=1 ;;
+ r) RUNNING=1 ;;
v) VERBOSE=2 ;;
*) usage 1 ;;
esac
@@ -41,14 +51,18 @@ done
shift $(($OPTIND - 1))
[ -n "$*" ] && usage 1
-msg "Checking what MythTV is doing now or plans within $TIME_BEFORE minutes..."
+msg "Checking what MythTV is doing now or plans to within $TIME_BEFORE minutes..."
msg
-/usr/bin/mythshutdown -s 1
+/usr/bin/mythshutdown --status
BUSY="$?"
msg "mythshutdown returned $BUSY"
-# Ignore certain non-zero flag values
-BUSY=$(($BUSY & 0x2F))
+if [ "$DAILY" -eq 0 ] ; then
+ msg " including daily wake, locked, and about to start wake as system idle"
+ # Ignore daily wake, locked and about to start wake flag values
+ BUSY=$(($BUSY & 0x2F))
+ msg " mythshutdown returned $BUSY"
+fi
SCHEMALOCK=$(mysql_cmd "select count(*) from schemalock")
msg "schemalock $SCHEMALOCK"
@@ -59,60 +73,70 @@ msg "running jobs $JOBS"
INUSE=$(mysql_cmd "select count(*) from inuseprograms")
msg "inuse programs $INUSE"
-POTENTIAL=$(mysql_cmd "select count(*) from recordmatch as rm, program as p
- where rm.chanid = p.chanid and rm.starttime = p.starttime
- and rm.starttime < now() + interval $TIME_BEFORE minute
- and now() < p.endtime + interval $TIME_AFTER minute")
-msg "potential recordings $POTENTIAL"
-# See if any of the potential upcoming recordings are real.
-# This is ugly, but only the backend knows what programs it really
-# plans to record or ignore, so we can't just check the DB. :-(
-if [ "$VERBOSE" -ge 2 ] ; then
- mysql_cmd "select p.starttime, p.endtime, p.title, subtitle
- from recordmatch as rm, program as p
- where rm.chanid = p.chanid and rm.starttime = p.starttime
- and rm.starttime < now() + interval $TIME_BEFORE minute
- and now() < p.endtime + interval $TIME_AFTER minute
- order by p.starttime, p.endtime"
-fi
-UPCOMING=$(/usr/bin/mythbackend --printsched 2>&1 |
- /bin/awk -v potential=$POTENTIAL '
- BEGIN {item=-1;real=0}
- /--- print list start ---/,/--- print list end ---/ {
- if (item>0 && item<=potential && substr($0,70,1) ~ "[0-9]") real+=1;
- item += 1;
- }
- END {print real}
-')
+UPCOMING=$(timeout 3 misc_upcoming_recordings.pl --plain_text --text_format "%rs " --heading "" --minutes $TIME_BEFORE --recordings -1 | wc -w)
msg "planned recordings $UPCOMING"
if [ "$VERBOSE" -ge 2 ] ; then
- /usr/bin/mythbackend --printsched 2>&1 |
- /bin/awk -v potential=$POTENTIAL '
- BEGIN {item=-1}
- /--- print list start ---/,/--- print list end ---/ {
- if (item>0 && item<=potential) print $0;
- item += 1;
- }'
+ msg
+ timeout 3 /usr/LH/bin/misc_upcoming_recordings.pl --plain_text --minutes $TIME_BEFORE --recordings -1
fi
+# Check all host's mythfrontends if they are running and playing
+HOSTNAMES=$(mysql_cmd "select hostname from settings where value = 'FrontendIdleTimeout'")
+FERUNNING=0
+PLAYING=0
+for HOST in $HOSTNAMES
+do
+ if [ "$VERBOSE" -ge 2 ]; then
+ msg "Checking $HOST's mythfrontend status..."
+ fi
+ncOUTPUT=$(timeout 2 nc $HOST 6546 << EOF
+query location
+quit
+EOF
+)
+ if [ "$RUNNING" -ge 1 ] ; then
+ if [[ "$ncOUTPUT" == *"# "* ]]; then
+ FERUNNING=$(( $FERUNNING + 1 ))
+ msg "$HOST's mythfrontend is running $FERUNNING"
+ else
+ msg "$HOST's mythfrontend is NOT running $FERUNNING"
+ fi
+ fi
+ if [[ "$ncOUTPUT" == *"# Playback "* ]]; then
+ PLAYING=$(( $PLAYING + 1 ))
+ msg "$HOST is playing a recording or video $PLAYING"
+ else
+ msg "$HOST is NOT playing a recording or video $PLAYING"
+ fi
+done
+
+# Check for users logged in
if [ "$LOGINS" -ge 1 ] ; then
USERS=`/usr/bin/last | /bin/grep "still logged in" | awk '{ print $1 }'`
if [ -n "$USERS" ] ; then
LOGINS=1
- msg "The following user(s) are still logged in: ${USERS}"
+ msg "The following user(s) are still logged in:"
+ msg "${USERS}"
else
LOGINS=0
- msg "No user(s) are logged in..."
+ msg "No users are logged in $LOGINS"
fi
fi
# Check for open windows
-/usr/LH/bin/xwin_find.sh -q '.*(mythtv@|xterm|Firefox|Namoroka|Opera).*'
-WINDOWS="$?"
-WINDOWS=$(($WINDOWS == 0))
-msg "windows $WINDOWS"
+FOUNDWINDOWS=0
+if [ "$WINDOWS" -ge 1 ] ; then
+ /usr/LH/bin/xwin_find.sh -q '.*(mythtv@|xterm|Firefox|Namoroka|Opera|Chromium).*'
+ FOUNDWINDOWS="$?"
+ FOUNDWINDOWS=$(($FOUNDWINDOWS == 0))
+ if [ "$FOUNDWINDOWS" -eq 0 ] ; then
+ msg "no application windows open $FOUNDWINDOWS"
+ else
+ msg "one or more application windows open $FOUNDWINDOWS"
+ fi
+fi
-activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING + $LOGINS + $WINDOWS))
+activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING + $FERUNNING + $PLAYING + $LOGINS + $FOUNDWINDOWS))
msg
if [ "$activities" -eq 0 ] ; then
msg "System is idle"
diff --git a/abs/core/linhes-scripts/limit-mythcommflag.sh b/abs/core/linhes-scripts/limit-mythcommflag.sh
index 5cd81bb..63a2872 100755
--- a/abs/core/linhes-scripts/limit-mythcommflag.sh
+++ b/abs/core/linhes-scripts/limit-mythcommflag.sh
@@ -48,8 +48,8 @@ cpulimit_pid=0
while true; do
PROCCOMMFLAG=`pidof mythcommflag`
if [ -n "${PROCCOMMFLAG}" ]; then
- BACKENDCPU=`top -bn1u mythtv | grep -m 1 mythbackend | awk '{ print $9 }'`
- FRONTENDCPU=`top -bn1u mythtv | grep -m 1 mythfrontend | awk '{ print $9 }'`
+ BACKENDCPU=`top -bn1u mythtv | grep -m 1 'mythbackend ' | awk '{ print $9 }'`
+ FRONTENDCPU=`top -bn1u mythtv | grep -m 1 'mythfrontend ' | awk '{ print $9 }'`
if [ "$FRONTENDCPU" = "" ]; then
FRONTENDCPU=0
fi
diff --git a/abs/core/linhes-scripts/mythwelcome-config.py b/abs/core/linhes-scripts/mythwelcome-config.py
index a8a8960..5ab24b0 100755
--- a/abs/core/linhes-scripts/mythwelcome-config.py
+++ b/abs/core/linhes-scripts/mythwelcome-config.py
@@ -24,4 +24,4 @@ if mythdb.settings[localhostname].idleTimeoutSecs == u'0':
mythdb.settings.NULL.WakeupTimeFormat = u'yyyy-MM-ddThh:mm:ss'
mythdb.settings.NULL.SetWakeuptimeCommand = u'/usr/bin/mythshutdown --setwakeup $time'
mythdb.settings.NULL.ServerHaltCommand = u'/usr/bin/mythshutdown --shutdown'
-mythdb.settings.NULL.preSDWUCheckCommand = u'/usr/bin/mythshutdown --check'
+mythdb.settings.NULL.preSDWUCheckCommand = u'/usr/LH/bin/idle.sh -s -m -r'
diff --git a/abs/core/linhes-scripts/pause-mythcommflag.sh b/abs/core/linhes-scripts/pause-mythcommflag.sh
index 4da808b..1db6db6 100755
--- a/abs/core/linhes-scripts/pause-mythcommflag.sh
+++ b/abs/core/linhes-scripts/pause-mythcommflag.sh
@@ -29,7 +29,7 @@ while true; do
PROCCOMMFLAG=`pidof mythcommflag`
if [ -n "${PROCCOMMFLAG}" ]
then
- FRONTENDCPU=`top -bn1u mythtv | grep mythfrontend | awk '{ print $9 }'`
+ FRONTENDCPU=`top -bn1u mythtv | grep -m 1 'mythfrontend ' | awk '{ print $9 }'`
if [ $COMMFLAGSTATE -eq 1 ]
then
CPUTHRESHOLD1=$CPUTHRESHOLD