summaryrefslogtreecommitdiffstats
path: root/abs/core/linhes-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/linhes-scripts')
-rwxr-xr-xabs/core/linhes-scripts/LinHES-osd19
-rw-r--r--abs/core/linhes-scripts/PKGBUILD36
-rw-r--r--abs/core/linhes-scripts/find_orphans.py2
-rwxr-xr-xabs/core/linhes-scripts/get_airplay_key6
-rwxr-xr-xabs/core/linhes-scripts/idle.sh114
-rwxr-xr-xabs/core/linhes-scripts/limit-mythcommflag.sh4
-rw-r--r--abs/core/linhes-scripts/myth2mkv12
-rwxr-xr-xabs/core/linhes-scripts/myth2mp34
-rwxr-xr-xabs/core/linhes-scripts/myth2x2645
-rwxr-xr-xabs/core/linhes-scripts/myth2xvid7
-rwxr-xr-xabs/core/linhes-scripts/mythwelcome-config.py2
-rwxr-xr-xabs/core/linhes-scripts/pause-mythcommflag.sh2
-rwxr-xr-xabs/core/linhes-scripts/ripD_eject.sh125
-rw-r--r--abs/core/linhes-scripts/screenshooter.sh.orig224
14 files changed, 265 insertions, 297 deletions
diff --git a/abs/core/linhes-scripts/LinHES-osd b/abs/core/linhes-scripts/LinHES-osd
new file mode 100755
index 0000000..85f4a40
--- /dev/null
+++ b/abs/core/linhes-scripts/LinHES-osd
@@ -0,0 +1,19 @@
+#!/bin/bash
+# /usr/local/bin/KnoppMyth-osd
+# A script to put up text for on screen.
+#
+########################################################################
+FONT="-adobe-helvetica-bold-r-*-*-34-*-*-*-*-*-*-*" # Default
+OPTS="-f $FONT -s 2 -p bottom -A left -i 50 -l 5" # values.
+#-----------------------------------------------------------------------
+[ -r /etc/rip.cfg ] && . /etc/rip.cfg
+########################################################################
+# $1=text, $2=color, $3=delay.
+JUNK=$(killall osd_cat >& /dev/null)
+color='' ; delay=''
+[ -z "$1" ] && exit 0
+[ -n "$2" ] && color="--color=$2"
+[ -n "$3" ] && delay="--delay=$3"
+JUNK=$(echo -e "$1" | osd_cat $OPTS $color $delay &)
+########################################################################
+# End
diff --git a/abs/core/linhes-scripts/PKGBUILD b/abs/core/linhes-scripts/PKGBUILD
index 829694b..c325101 100644
--- a/abs/core/linhes-scripts/PKGBUILD
+++ b/abs/core/linhes-scripts/PKGBUILD
@@ -3,12 +3,12 @@
pkgname=linhes-scripts
pkgver=7
-pkgrel=41
+pkgrel=50
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' 'perl' 'perl-shell')
url="http://linhes.org/"
install="linhes-scripts.install"
source=(
@@ -48,42 +48,47 @@ xwin_find.sh
upgrade_screen_rc
upgrade_linhes_script.sh
find_orphans.py
-acl_fix_fstab.py
+acl_fix_fstab.py
stop_xss.sh
myth2mkv
+LinHES-osd
+ripD_eject.sh
+get_airplay_key
)
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_* ${pkgdir}/usr/LH/bin/
+ install -D -m755 myth2* *.sh *.pl *.py vdpau* run-* pause_* LinHES* get_airplay_key ${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
mkdir -p ${pkgdir}/etc/sv/limit-mythcommflag/supervise
cp run-limit-mythcommflag ${pkgdir}/etc/sv/limit-mythcommflag/run
mkdir -p ${pkgdir}/etc/logrotate.d/
- cp pause_mythcommflag ${pkgdir}/etc/logrotate.d/
+# cp pause_mythcommflag ${pkgdir}/etc/logrotate.d/
+ install -m644 -D pause_mythcommflag $startdir/pkg/etc/logrotate.d/pause_mythcommflag
+
}
-md5sums=('f56985b2d602e11dc1e10d3e7848b2a5'
+md5sums=('47a66238d95259d75c9c5cbcbb6da19f'
'10ad1a4da669adccd01e0be6e5e4a3ed'
'9ae2cd7a0c42d57ad8b5f515d7d60196'
'1274bad3fb7296f00acd2d44804bad14'
'47225fa9b6c953d56f6ede84d921a300'
'6b6e7d34a4bda6d608d150039adefd07'
- 'f8df7665903ddf822f5148bc8a074e4a'
+ '4a1fda884dcd7d65fb2690fbdbd92a83'
'18263972b6326e140bbef0bb7dfa2da9'
'410795ef9039e4c6c0484e706ecfd567'
- '0750d7c65109d12aa536f312a38410d1'
- 'ac2a4a6b4100f4d7bfb9ecd9356c8c6e'
+ 'ad98d51e79f83df7c03f828dbeaea7f4'
+ '3b1c44a0818b35b6939c3cb2b723ce9e'
'd2b475821f902c5e081e7da43a35e6ac'
'95c092f67036a361ef7a57436f44332e'
- '565ebca7b88bcd083322b7324f8e56e5'
+ '92950f0ffb1faf1ed64c6be2b8fbc3f6'
'3b776bbff68906ddc2f62b7e0dde3fe4'
- '15f3143d2b1369da431e4268029aba40'
+ 'a57641fb63d7bb6d92a438f1ea779a57'
'3d0adf26280cde55a0c47188fff34826'
- '25dd5b8ec0482d561b481bfce051d648'
+ 'c3ada01d3a739abe3f920b02d4ea3f6e'
'b2c3dd48a4abb976eda2d5fbf22a173a'
'b527b01d119d3bc33b8fa69bdf1082bb'
'9d077c24d102fa02e4f417d639d8b00a'
@@ -101,7 +106,10 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5'
'a94fe6d980f4b810f2e2ae5352084b39'
'974c137d3fcb85942ba8945a1bc815fe'
'f454faeabfa153b10389a9a3bfd51c4a'
- 'd8838461af9d446a1fd7e7883fdc75d1'
+ '34fc1f58ad1eabf4eff4979d420760c0'
'cc9cdabcdfc969c2829b58c0e513488c'
'54a478660d0f8150fe10112a9ecf2740'
- '980423e07c8c6ffd0ea1bf9a1959fdc2')
+ '503df99218373dfc75e7e7f5e449a44e'
+ 'b608044c9e7530a400d8f5b88fdfe6e6'
+ 'e2e24dd59d5d576cc33feafb329fa302'
+ '33fbebbd546672cedd3c5e7350ab414e')
diff --git a/abs/core/linhes-scripts/find_orphans.py b/abs/core/linhes-scripts/find_orphans.py
index ec2cae1..cdc03d4 100644
--- a/abs/core/linhes-scripts/find_orphans.py
+++ b/abs/core/linhes-scripts/find_orphans.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
from MythTV import MythDB, MythBE, Recorded, MythError
from socket import timeout
diff --git a/abs/core/linhes-scripts/get_airplay_key b/abs/core/linhes-scripts/get_airplay_key
new file mode 100755
index 0000000..89a40dd
--- /dev/null
+++ b/abs/core/linhes-scripts/get_airplay_key
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+. /usr/MythVantage/bin/install_functions.sh
+curl https://raw.github.com/juhovh/shairplay/master/airport.key > $MYTHHOME/.mythtv/RAOPKey.rsa
+chmod 755 $MYTHHOME/.mythtv/RAOPKey.rsa
+chown mythtv:mythtv $MYTHHOME/.mythtv/RAOPKey.rsa \ No newline at end of file
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/myth2mkv b/abs/core/linhes-scripts/myth2mkv
index 5035748..aedccff 100644
--- a/abs/core/linhes-scripts/myth2mkv
+++ b/abs/core/linhes-scripts/myth2mkv
@@ -2,7 +2,7 @@
#
# Convert video to AVC-1 / h264
#
-# version 0.25-001
+# version 0.25-004
#
# Prerequisites:
# - mythtv >= 0.25
@@ -156,6 +156,11 @@ if [[ ${FPS} = "29.970" ]] ; then
FPS="29.97"
fi
+# HandBrake does not like a framerate of 59.940, so let's drop the 0
+if [[ ${FPS} = "59.940" ]] ; then
+ FPS="59.94"
+fi
+
# A rough guestimation that if the video width is 1920, 1440, 852, 704, 640 or
# 528 pixels it is probably interlaced.
if [[ ${DEINT} = Y ]] ; then
@@ -199,10 +204,13 @@ if [[ ${QUALITY} = HQ ]] ; then
if [[ -n ${CROP} ]] ; then
CROP="--crop ${CROP}"
else
- CROP="--crop 0:0:0:0"
+ CROP="--crop 0:0:0:0 --strict-anamorphic"
fi
HB_OPTS="-o ${TMPFILE} -f mkv -m -e x264 ${TUNING} -x b-adapt=2:rc-lookahead=50 -b 5000 -2 -T ${WIDTH} ${HEIGHT} -r ${FPS} --cfr ${CROP} ${DEINT} -a 1 -E copy -s 1"
else
+ if [[ ${CROP} = "--crop 0:0:0:0" ]] ; then
+ CROP="${CROP} --strict-anamorphic"
+ fi
if [[ ${QUALITY} = LQ ]] ; then
HB_OPTS="-o ${TMPFILE} -f mkv -m -e x264 ${TUNING} -b 1250 ${WIDTH} ${HEIGHT} -r ${FPS} --pfr ${CROP} ${DEINT} -a 1 -E lame -B 128 -Q 8 -6 stereo -s 1"
else
diff --git a/abs/core/linhes-scripts/myth2mp3 b/abs/core/linhes-scripts/myth2mp3
index 5ce72c1..69d5d3f 100755
--- a/abs/core/linhes-scripts/myth2mp3
+++ b/abs/core/linhes-scripts/myth2mp3
@@ -1,6 +1,6 @@
#!/bin/sh
# convert recordings to as mp3 audio only
-# version 1.1.2
+# version 1.1.3
# usage:
# first parameter must be %DIR%/%FILE% of the recording
@@ -37,7 +37,7 @@ beforetime="$(date +%s)"
# check if using cutlist
if [ $USECUTLIST = Y ];then
- MYTHCOMMFRAMES=`mythcommflag --getcutlist -f "$FFINPUTFILE" | grep 'Cutlist:' | cut -d \ -f 2`
+ MYTHCOMMFRAMES=`mythutil --getcutlist --chanid "$3" --starttime "$4" | grep 'Cutlist:' | cut -d \ -f 2`
if [ -n "$MYTHCOMMFRAMES" ]; then
echo "Extracting Cutlist..." >> $LOGFILE
/usr/bin/nice -n19 /usr/bin/mythtranscode --chanid "$3" --starttime "$4" --outfile "$TMPCUTFILE" --mpeg2 --honorcutlist
diff --git a/abs/core/linhes-scripts/myth2x264 b/abs/core/linhes-scripts/myth2x264
index 014fcbe..4c234d5 100755
--- a/abs/core/linhes-scripts/myth2x264
+++ b/abs/core/linhes-scripts/myth2x264
@@ -1,6 +1,7 @@
#!/bin/sh
# convert recording to x264 encoded avi
-# version 0.6
+# version 0.7
+# consider using myth2mkv instead of this script
# usage:
# first parameter must be %DIR%/%FILE% of the recording
@@ -154,7 +155,7 @@ check_myth_jobcmds
# check if using cutlist
if [ $USECUTLIST = Y ]; then
- MYTHCOMMFRAMES=`mythcommflag --getcutlist -f $MENINPUTFILE | grep 'Cutlist:' | cut -d \ -f 2`
+ MYTHCOMMFRAMES=`mythutil --getcutlist --chanid "$3" --starttime "$4" | grep 'Cutlist:' | cut -d \ -f 2`
if [ -n "$MYTHCOMMFRAMES" ]; then
echo "Extracting Cutlist..." >> $LOGFILE
update_comment "Extracting Cutlist"
diff --git a/abs/core/linhes-scripts/myth2xvid b/abs/core/linhes-scripts/myth2xvid
index d0fcb42..033026d 100755
--- a/abs/core/linhes-scripts/myth2xvid
+++ b/abs/core/linhes-scripts/myth2xvid
@@ -1,6 +1,7 @@
#!/bin/sh
# convert recording to xvid encoded avi
-# version 1.3
+# version 1.4
+# consider using myth2mkv instead of this script
# usage:
# first parameter must be %DIR%/%FILE% of the recording
@@ -154,7 +155,7 @@ check_myth_jobcmds
# check if using cutlist
if [ $USECUTLIST = Y ]; then
- MYTHCOMMFRAMES=`mythcommflag --getcutlist -f $MENINPUTFILE | grep 'Cutlist:' | cut -d \ -f 2`
+ MYTHCOMMFRAMES=`mythutil --getcutlist --chanid "$3" --starttime "$4" | grep 'Cutlist:' | cut -d \ -f 2`
if [ -n "$MYTHCOMMFRAMES" ]; then
echo "Extracting Cutlist..." >> $LOGFILE
update_comment "Extracting Cutlist"
@@ -220,4 +221,4 @@ else
echo "ERROR: $ERROR" >> $LOGFILE
fi
-clean_up_files \ No newline at end of file
+clean_up_files
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
diff --git a/abs/core/linhes-scripts/ripD_eject.sh b/abs/core/linhes-scripts/ripD_eject.sh
new file mode 100755
index 0000000..99947a8
--- /dev/null
+++ b/abs/core/linhes-scripts/ripD_eject.sh
@@ -0,0 +1,125 @@
+#!/bin/bash
+# /usr/LH/bin/ripD_eject.sh
+# A DVD rip and eject script.
+########################################################################
+DEV='/dev/sr0' # DVD device
+MPNT='media/cdrom' # Mount Point
+Ddir='/myth/video' # DVD output dir List
+Bsnd='/usr/share/sounds/init.wav' # Begin sound file
+Esnd='/usr/share/sounds/complete.wav' # End sound file
+DATE=$(date +%Y%m%d_%H%M) # current date/time
+LOG='/var/log/mythtv/ripD.log' # name of Log file.
+TRACK=$(lsdvd | grep -i longest | awk '{print $3}') #Finds longest track
+FILE=$TITLE
+#-----------------------------------------------------------------------
+FONT="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*"
+OPTS="-f $FONT -s 2 -p bottom -A left -i 50 -l 4"
+#-----------------------------------------------------------------------
+[ -r /etc/rip.cfg ] && . /etc/rip.cfg
+#-----------------------------------------------------------------------
+LOCK=/tmp/.ripLock.$$
+[ "$DISPLAY" == "" ] && export DISPLAY=:0
+########################################################################
+function osd { # $1=text, $2=color, $3=delay
+ cmd="osd_cat $OPTS"
+ [ -n "$2" ] && cmd="$cmd --color=$2"
+ [ -n "$3" ] && cmd="$cmd -d $3"
+ killall osd_cat
+ echo -e "$1" | $cmd
+} >& /dev/null
+function osd_loop() {
+ FN=$1 ; shift
+# TXT="$MAX to $dir"
+ TXT="$MAX to $dir/$FILE"
+ N=0
+ while [ -f "$LOCK" ]; do
+ #osd "\nbacking up DVD: '$@'\n$TXT" gray 60
+ osd "\nbacking up DVD: '$TITLE'\n$TXT" gray 60
+ N=$(($N+1))
+ [ -d "$FN" ] && SIZE=$(du -sh $FN | awk '{print $1}')
+# TXT="$SIZE of $MAX @ $N min. elapsed"
+ TXT="$N min. elapsed"
+ done
+}
+########################################################################
+LinHES-osd "\nDetecting DVD" gray20 5 &
+echo "`date` detected DVD" >> $LOG
+rm -f /tmp/.ripLock.*
+#=======================================================================
+for dir in $Ddir ; do
+ if [ -d $dir -a -w $dir ]; then
+ break
+ fi
+done
+#-----------------------------------------------------------------------
+if [ ! -d "$dir" ]; then
+ echo "no $dir" >> $LOG
+ osd "\ndirectory: $dir\nnot found!" red 10 &
+ eject ; eject
+ exit 0
+fi
+if [ ! -w "$dir" ]; then
+ echo "$dir not writable" >> $LOG
+ osd "\ndirectory: $Cdir\nnot writable!" red 10 &
+ eject ; eject
+ exit 0
+fi
+#-----------------------------------------------------------------------
+mount $DEV >& /dev/null
+dev=$(readlink $DEV)
+df=$(df -h /dev/$dev | grep /dev/$dev)
+MAX=$(echo $df | while read d v r ; do echo $v ; done)
+echo " backup $MAX to $dir" >> $LOG
+#=======================================================================
+# first make sure DMA is on:
+sudo hdparm -d1 -u1 $DEV >& /dev/null
+# attempt to get the DVD information:
+TITLE=$(dvdbackup -i /dev/sr0 -I | grep information | awk '{ s = ""; for (i = 8; i <= NF; i++) s = s $i " "; print s }' | tr -d '"' | sed 's/ /_/g' | sed 's/_$//g')
+if [ "$TITLE" == "DVD_VIDEO" -o "$TITLE" == "" \
+ -o "$TITLE" == " " -o "$TITLE" == "[ ].*" ]; then
+ # if not a good title,
+ TITLE="dvdbackup_$DATE"
+fi
+echo " $TITLE" >> $LOG
+if [ $1 = m ]
+then
+ COMMAND="dvdbackup -M -i $DEV -o $dir -n $TITLE"
+ elif [ $1 = h ]
+ then
+# COMMAND="mencoder dvd://$TRACK -alang en -oac mp3lame -lameopts br=320:cbr -ovc lavc -lavcopts vcodec=mpeg4:vhq -vf scale -zoom -xy 720 -o $dir/$TITLE.avi"
+ COMMAND="HandBrakeCLI -i $DEV -o $dir/$TITLE.mp4 --preset "High\ Profile" --main-feature"
+ FILE=$TITLE.mp4
+ elif [ $1 = n ]
+ then
+# COMMAND="mencoder dvd://$TRACK -alang en -oac mp3lame -lameopts br=160:cbr -ovc lavc -lavcopts vcodec=mpeg4:vhq -vf scale -zoom -xy 512 -o $dir/$TITLE.avi"
+ COMMAND="HandBrakeCLI -i $DEV -o $dir/$TITLE.mp4 --preset "Normal" --main-feature"
+ FILE=$TITLE.mp4
+ elif [ $1 = l ]
+ then
+# COMMAND="mencoder dvd://$TRACK -alang en -oac mp3lame -lameopts br=96:cbr -ovc lavc -lavcopts vcodec=mpeg4:vhq -vf scale -zoom -xy 320 -o $dir/$TITLE.avi"
+ COMMAND="HandBrakeCLI -i $DEV -o $dir/$TITLE.mp4 --preset "Classic" --main-feature"
+ FILE=$TITLE.mp4
+ elif [ $1 = i ]
+ then
+ COMMAND="dd if=$DEV of=$dir/$TITLE.iso bs=2048"
+ FILE=$TITLE.iso
+fi
+{ # for the redir below:
+ # Begin:
+ touch $LOCK
+ osd_loop "$dir/$TITLE" "$TITLE" &
+ dvdbackup -i $DEV -I
+ sleep 1 ; aplay $Bsnd
+ $COMMAND
+ # Finish:
+ rm -f $LOCK
+ osd "\nfinish DVD: '$TITLE'\ninto $dir/$FILE" gray20 5 &
+ sleep 1 ; aplay $Esnd
+ # Eject the media:
+ sudo eject ; sudo eject
+} > $dir/.$TITLE.log 2>&1
+echo " `du -sh $dir/$FILE`" >> $LOG
+echo " `date` finished DVD" >> $LOG
+exit 0
+########################################################################
+# End
diff --git a/abs/core/linhes-scripts/screenshooter.sh.orig b/abs/core/linhes-scripts/screenshooter.sh.orig
deleted file mode 100644
index 72f6cc0..0000000
--- a/abs/core/linhes-scripts/screenshooter.sh.orig
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/bin/bash
-
-# Written by Bob Igo from the MythTV Store at http://MythiC.TV
-# with contributions from TJC and Sarah Hayes
-# Email: bob@stormlogic.com
-#
-# If you run into problems with this script, please send me email
-
-# This is alpha code to auto-generate thumbnails for previews in MythVideo.
-# It won't currently work on some filenames that have spaces in them.
-# It's surely just a matter of escaping or quoting, but I have yet to find
-# the right incantation.
-
-# example usage:
-# find -L /myth/video -wholename '*.covers' -prune -o -name '*.resume' -o -type f -exec screenshooter.sh -v {} \;
-
-# limitations:
-# --
-# In an MBE/SBE/FE setup this might get the settings for the wrong machine...
-# The script has no AI to know if a grabbed frame is useful to identify the video, only that it was able to grab it.
-# Doesn't clean up after itself if videos are deleted, though MythTV may do this on its own.
-# Minimum theoretical compatible video length is 4 seconds. Shorter videos will not work with this version.
-# Surely more limitations I can't think of because it's my baby :)
-
-Usage() {
- echo "USAGE:"
- echo `basename $0` "-v PATHNAME [-s SECONDS] [-c] [-b HOSTNAME] [-u USERNAME] [-p PASSWORD] [-o]"
- echo "-v: pathname to Video"
- echo "-s: number of Seconds to skip before capturing (270 by default)"
- echo "-c: Clobber any previous screenshot found for this video (off by default)"
- echo "-b: mysql server (Backend) hostname (localhost by default)"
- echo "-u: mysql Username (mythtv by default)"
- echo "-p: mysql Password (mythtv by default)"
- echo "-o: verbOse mode (off by default)"
- echo "-x: check for valid video eXtension (off by default)"
- echo
- echo "EXAMPLE: $0 -v /myth/video/HDTV/shuttle.mpg -c -s 30"
- exit 3
-}
-
-if [ -z $1 ]; then
- Usage
-fi
-
-V_MISSING=1
-
-while getopts "v:sbupochx" FLAG ; do
- case "$FLAG" in
- v) VIDEO_PATHNAME="$OPTARG"
- V_MISSING=0;;
- s) SKIPAHEAD="$OPTARG";;
- c) CLOBBER=1;;
- b) BACKEND_HOSTNAME="$OPTARG";;
- u) DBUSERNAME="$OPTARG";;
- p) DBPASSWORD="$OPTARG";;
- o) VERBOSE=1;;
- x) EXTENSION_CHECK=1;;
- *) Usage;;
- esac
-done
-
-if [ $V_MISSING == 1 ]; then
- Usage
-fi
-
-# Declaring Variables here and assigning sensible defaults.
-
-# SKIPAHEAD is the number of seconds to skip ahead before starting the frame capture.
-# Set it to an arbitrary value if none is specified.
-SKIPAHEAD=${SKIPAHEAD:-"270"}
-BACKEND_HOSTNAME=${BACKEND_HOSTNAME:-"localhost"}
-DBUSERNAME=${DBUSERNAME:-"mythtv"}
-DBPASSWORD=${DBPASSWORD:-"mythtv"}
-# Defaults to quiet.
-VERBOSE=${VERBOSE:-0}
-# Unless otherwise told, do not clobber existing cover files.
-CLOBBER=${CLOBBER:-0}
-# Unless otherwise told, do not check the file extension against
-# MythTV's list of registered video file types.
-EXTENSION_CHECK=${EXTENSION_CHECK:-0}
-
-VIDEO_CAPTURE_HOME=$(mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -sNBe "select data from settings where value='VideoArtworkDir' limit 1")
-if [ ! -d "$VIDEO_CAPTURE_HOME" ] ; then
- echo "Directory $VIDEO_CAPTURE_HOME does not exist, nowhere to put the screen shot!"
- echo "Have you configured MythVideo yet?"
- exit 1
-fi
-
-VIDEO_HOME=$(mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -sNBe "select data from settings where value='VideoStartupDir' limit 1")
-if [ ! -d "$VIDEO_HOME" ] ; then
- echo "Directory $VIDEO_HOME does not exist, nowhere to put the screen shot!"
- echo "Have you configured MythVideo yet?"
- exit 1
-fi
-
-VIDEO_FILENAME=$(basename "$VIDEO_PATHNAME")
-VIDEO_EXTENSION=${VIDEO_FILENAME##*.}
-# Since we cron'd lets first make sure the validity of the file
-if [ "$EXTENSION_CHECK" == "1" ]; then
- EXCHECK=$(mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -sNBe "select f_ignore from videotypes where extension=\"$VIDEO_EXTENSION\";")
- #excheck returns blank, it found nothing.
- if [ "$EXCHECK" == "" ]; then
- if [ "$VERBOSE" == "1" ]; then
- echo "$VIDEO_EXTENSION does not appear to be a valid media file, skipping."
- fi
- exit 1
- else
- # It is valid, but should we ignore it. If so then excheck will equal 1.
- if [ "EXCHECK" == "1" ]; then
- if [ "$VERBOSE" == "1" ]; then
- echo "$VIDEO_EXTENSION is set to ignore."
- fi
- exit 1
- fi
- # It is valid, it's not set to ignore.
- if [ "$VERBOSE" == "1" ]; then
- echo "$VIDEO_EXTENSION appears in the Database, checking further."
- fi
- EXCHECK=$(mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -sNBe "select title from videometadata where filename=\"$VIDEO_PATHNAME\";")
- #Right, the file is supposed to be playable. Has it been imported to the Db yet?
- if [ "$EXCHECK" == "" ] ; then
- if [ "$VERBOSE" == "1" ]; then
- echo "$VIDEO_FILENAME does not exist in the database."
- fi
- exit 1
- # If you decide you want the system to 'auto import' the video then comment out
- # the exit line and uncomment the rest of it. Bewarned, this is sucky SQL at
- # the best but will give sensible defaults.
- #
- # if [ "$VERBOSE" == "1" ]; then
- # echo "Importing $VIDEO_FILENAME in to database."
- # fi
- # mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -sNBe "insert into videometadata (intid, title, director, plot, rating, inetref, year, userrating, length, showlevel, filename, coverfile, childid, browse, playcommand, category) values (' ', '$VIDEO_FILENAME', 'Unknown', 'Unknown', 'NR', '00000000', 1895, 0.0, 0, 1, '$VIDEO_PATHNAME', 'No Cover', -1, 1, ' ', 0);"
- fi
- fi
-fi
-
-if [ "$CLOBBER" -eq 0 ]; then
- # Since we're not clobbering, first check to see if this video already has a coverfile entry in MySQL:
- SQL_CMD="select coverfile from videometadata where filename=\"$VIDEO_PATHNAME\";"
- CURRENT_COVERFILE=`mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -B -e "$SQL_CMD" | tail -1`
-
- if [[ "$CURRENT_COVERFILE" != "" ]] && [[ "$CURRENT_COVERFILE" != "No Cover" ]]; then
- # there's already a cover file for this video
- if [ "$VERBOSE" == "1" ]; then
- echo "$VIDEO_FILENAME has cover file, skipping."
- fi
- exit 2
- fi
-fi
-
-
-# Swap the video file extension for png. Should work assuming the extension only appears ONCE!
-VIDEO_CAPTURE_PATHNAME="$VIDEO_CAPTURE_HOME/$VIDEO_FILENAME.png"
-
-# How many frames of video to capture. We'll grab the last frame as our screenshot.
-if [ "$VIDEO_EXTENSION" == "m4v" ]; then
- FRAMES_TO_CAPTURE="90"
-else
- FRAMES_TO_CAPTURE="05"
-fi
-
-SHOTFILE="000000"$FRAMES_TO_CAPTURE".png"
-VIDEO_STATS="/tmp/screenshooter_video_stats.txt"
-
-cd /tmp
-
-# The video we're processing may be shorter than SKIPAHEAD seconds.
-# Keep trying to capture until we find a SKIPAHEAD value within the length of the video.
-# Give up if we reach 0 seconds.
-while [ ! -f "$SHOTFILE" ]; do
- /usr/bin/mplayer -ss $SKIPAHEAD -vf scale=640:-2 -ao null -vo png -quiet -frames $FRAMES_TO_CAPTURE -identify "$VIDEO_PATHNAME" &> $VIDEO_STATS &
- TIMEOUT=9
-
- # Some video formats will play audio only. This loop gives the above command 20 seconds to
- # finish, otherwise it gets killed.
- while [ -n "`ps -p $! --no-heading`" ]; do
- TIMEOUT=$(expr $TIMEOUT - 1)
- if [ "$TIMEOUT" -le 0 ]; then
- kill -9 $!
- break
- fi
- sleep 1
- done
-
- SKIPAHEAD=$(expr $SKIPAHEAD / 2)
- if [ "$SKIPAHEAD" -le 0 ]; then
- break
- fi
-done
-
-if [ -f "$SHOTFILE" ]; then
- # Now, the video_capture is taken, and the name of the shot is in $SHOTFILE
- # Rename it and move it to the place where video_captures live.
- /bin/mv -f "$SHOTFILE" "$VIDEO_CAPTURE_PATHNAME"
- /bin/rm -f 000000*png
- chown mythtv: "$VIDEO_CAPTURE_PATHNAME"
-
- # We've got the shotfile nailed, now calculate video run length.
- VIDEO_LENGTH_IN_SECONDS=`grep ID_LENGTH $VIDEO_STATS | awk -F'=' '{print $2}'`
- VIDEO_LENGTH_IN_INTEGER_SECONDS=${VIDEO_LENGTH_IN_SECONDS/%.*/}
- if [ $VIDEO_LENGTH_IN_INTEGER_SECONDS -lt 60 ]; then
- VIDEO_LENGTH_IN_MINUTES="1"
- else
- VIDEO_LENGTH_IN_MINUTES=$(expr $VIDEO_LENGTH_IN_INTEGER_SECONDS / 60)
- fi
-
- SQL_CMD="update videometadata set length=\"$MIN_LENGTH\" where filename=\"$VIDEO_PATHNAME\";"
- mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -e "$SQL_CMD"
-
-
- # put the screenshot pathname and any runlength info into videometadatatable
-
- # Pre-escape any single or double quotes for the SQL command.
-
- VIDEO_CAPTURE_PATHNAME=`echo $VIDEO_CAPTURE_PATHNAME | sed -e "s/'/\\\'/g" -e 's/"/\\\"/g' `
- VIDEO_PATHNAME=`echo $VIDEO_PATHNAME | sed -e "s/'/\\\'/g" -e 's/"/\\\"/g' `
- SQL_CMD="update videometadata set coverfile=\"$VIDEO_CAPTURE_PATHNAME\", length=\"$VIDEO_LENGTH_IN_MINUTES\" where filename=\"$VIDEO_PATHNAME\";"
-
- mysql -u $DBUSERNAME --password=$DBPASSWORD -h $BACKEND_HOSTNAME mythconverg -e "$SQL_CMD"
-else
- echo "No image could be captured from $VIDEO_PATHNAME"
- exit 1
-fi