#!/bin/bash # "Constants" # Which interface is the HDHR on? IFACE=eth0 # Path to config tool HDHR=/usr/local/bin/hdhomerun_config # ID of the Home Run HDID=FFFFFFFF # Which tuner [0|1] ? TUNER=0 ### # The string to throw the user when they need a bone usage="Usage: $(basename $0) [-i ID] [-t 0|1] -m mode -c channel -p program [-r] [-f filename] [-l length]" if [ $# == 0 ] then echo $usage exit 1 fi # Parse all the command line args while getopts "i:t:m:c:p:f:l:rh" parm do case $parm in m) MODE=$OPTARG;; c) CHAN=$OPTARG;; p) PROG=$OPTARG;; f) OUTFILE=$OPTARG;; l) LENGTH=$OPTARG;; r) RECORD=true;; i) HDID=$OPTARG;; t) TUNER=$OPTARG;; h) echo $usage;; \?) echo $usage exit 1 ;; *) echo $usage exit 1;; esac done # Sanity checking should be here someday # Figure out what my IP is MYIP=$(ifconfig ${IFACE} | awk -F: '/inet addr:/{print $2}' | cut -d' ' -f1) PORT=1234 ${HDHR} ${HDID} set /tuner${TUNER}/channel $MODE:$CHAN ${HDHR} ${HDID} set /tuner${TUNER}/program $PROG if [ "$RECORD" == "true" ] then if [ "$OUTFILE" == "" ] then echo "Please specify a filename to record to with the -f flag" exit 1 fi if [ "$LENGTH" != "" ] then ${HDHR} ${HDID} save ${TUNER} $OUTFILE & RECPID=$! echo "Recorder process is $RECPID. Recording for $LENGTH." sleep $LENGTH kill $RECPID else echo "Recording in foreground. Ctrl-C to stop." ${HDHR} ${HDID} save ${TUNER} $OUTFILE fi else vlc udp://@:${PORT} & sleep 3s ${HDHR} ${HDID} set /tuner${TUNER}/target ${MYIP}:${PORT} fi