ffmpeg-mythtv/myth-launch-user-job.sh

60 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/bash
## Usage: myth-launch-user-job.sh script chanid starttime <optional args>
## export variables to subsequent commands
set -a
script="$1"
chanid="$2"
starttime="$3"
shift; shift; shift;
A1=$1;A2=$2;A3=$3;A4=$4;A5=$5;A6=$6;A7=$7;A8=$8;A9=$9;
# set defaults
debug=${debug:-"eval"}
ffmpeg=${ffmpeg:-"/usr/local/bin/ffmpeg"}
recordingsdir=${recordingsdir:-"/var/lib/mythtv/recordings"}
if test -z "$TMP"; then
TMP="/mnt/lvraid5"
fi
workdir=${workdir:-"$TMP/ffmpeg-cut-list.d"}
destdir=${destdir:-"$recordingsdir"}
logdir=${logdir:-"$workdir"}
logfile="$logdir/user-job-${chanid}-${starttime}.log"
if ! test -d $logdir; then
mkdir -p $logdir;
fi
cmd="ionice -c 3 $script $chanid $starttime 2>> $logfile >> $logfile"
cat <<EOF >> $logfile
date: $(date)
\$*: $*
script: $script
chanid: $chanid
starttime: $starttime
optional arguments passed through environment
A1: $A1
A2: $A2
A3: $A3
A4: $A4
A5: $A5
A6: $A6
A7: $A7
A8: $A8
A9: $A9
debug: $debug
ffmpeg: $ffmpeg
recordingsdir: $recordingsdir
TMP: $TMP
workdir: $workdir
destdir: $destdir
logdir: $logdir
logfile: $logfile
cmd: $cmd
EOF
$debug $cmd