function include_lirc () { config_file=$1 include_file=$2 grep -q ${include_file} ${config_file} if [ $? = 0 ] then echo ${include_file} already present else echo "include \"${include_file}\"" >> $config_file fi } function unload_all_lirc () { sv stop lircd killall -9 lircd modprobe -r $(lsmod |grep ^lirc |awk '{print $1}') } function udev_trigger () { udevadm settle udevadm trigger udevadm settle udevadm trigger } function setup_ir_remote { case $Remotetype in no_remote) echo "No remote selected" daemon_remove="lircd $daemon_remove" ;; tinker) echo "Remote in tinker mode" ;; *) echo "Start of ir_remote setup" #make backup copy mv ${BASE}/etc/lircd.conf ${BASE}/etc/lircd.conf.`date +%Y-%m-%d-%H-%M` mv ${BASE}/etc/lircrc ${BASE}/etc/lircrc.`date +%Y-%m-%d-%H-%M` if [ $HostBlasterType = pvr150 ] then Remotetype=hauppauge-blaster fi cd $TEMPLATES/remotes/$Remotetype for i in lircd* do include_lirc ${BASE}/etc/lircd.conf $TEMPLATES/remotes/$Remotetype/$i done for i in lircrc* do include_lirc ${BASE}/etc/lircrc $TEMPLATES/remotes/$Remotetype/$i done chmod 755 /etc/lircrc daemon_add="lircd $daemon_add" #standard location for mythtv lircrc if [ ! -e /home/mythtv/.mythtv/lircrc ] then if [ ! -d /home/mythtv/.mythtv ] then mkdir /home/mythtv/.mythtv chown mythtv:mythtv /home/mythtv/.mythtv fi ln -s /etc/lircrc /home/mythtv/.mythtv/lircrc 2> /dev/null fi #standard location for lircrc if [ ! -e /home/mythtv/.lircrc ] then ln -s /etc/lircrc /home/mythtv/.lircrc 2> /dev/null fi # echo "Sending hup to lircd" # sv hup lircd ;; esac } function setup_ir_receiver () { echo "setup_ir_receiver" case $ReceiverType in Serial) echo "setup serial lirc" sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage echo "lirc_serial #lirc" >> ${BASE}/etc/modules.mythvantage load-modules-mythvantage.sh remove_service.sh igdaemon remove_service.sh tatir ;; Usb-imon) echo "setup receiver-usb-imon" sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage echo "lirc_imon #lirc" >> ${BASE}/etc/modules.mythvantage load-modules-mythvantage.sh remove_service.sh igdaemon remove_service.sh tatir ;; Hauppauge) echo "setup hauppauge receiver (lirc_i2c)" sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage echo "lirc_i2c #lirc" >> ${BASE}/etc/modules.mythvantage cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf rmmod lirc_i2c 2>/dev/null load-modules-mythvantage.sh remove_service.sh igdaemon remove_service.sh tatir ;; iguanaIR-usb) echo "setup iguanaIR-usb receiver" sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage add_service.sh igdaemon remove_service.sh tatir ;; tatir) echo "setup tatir receiver" sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage add_service.sh tatir remove_service.sh igdaemon ;; *) sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage remove_service.sh igdaemon remove_service.sh tatir ;; esac } function setup_lcd () { case x$LCDtype in xtinker) echo "do nothing" ;; xno_lcd) echo "disabling lcd" sv down lcdd #sometimes it doesn't want to die killall -9 LCDd load-modules-mythvantage.sh UNLOAD LCD sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage daemon_remove="lcdd $daemon_remove" ;; x) echo "empty lcd" ;; *) echo "setup lcd" if [ -f $TEMPLATES/LCD/$LCDtype/modules ] then sed -i -e '/.*#LCD/d' ${BASE}/etc/modules.mythvantage cat $TEMPLATES/LCD/$LCDtype/modules >> ${BASE}/etc/modules.mythvantage #should also modprobe fi if [ -f $TEMPLATES/LCD/$LCDtype/LCDd.conf ] then cp_and_log $TEMPLATES/LCD/$LCDtype/LCDd.conf /etc # install="lcdproc $install" daemon_add="lcdd $daemon_add" load-modules-mythvantage.sh RESTART_FE="true" RESTART_LCD="true" fi #check if lirc capable,if so then call setupremote #if not in tinker mode check for remote if [ ! x$Remotetype = xtinker ] then if [ -f $TEMPLATES/LCD/$LCDtype/lircrc ] then cd $TEMPLATES/LCD/$LCDtype for i in lircd* do include_lirc ${BASE}/etc/lircd.conf $TEMPLATES/LCD/$LCDtype/$i done for i in lircrc* do include_lirc ${BASE}/etc/lircrc $TEMPLATES/LCD/$LCDtype/$i done cd - fi fi ;; esac } function setup_blaster_proto () { if [ x$HostBlasterType = x ] then HostBlasterType = "crap" fi if [ ! $HostBlasterType = pvr150 -a ! $HostBlasterType = None ] then for i in `seq $Hostnumblaster` do TEMP=HostTransmitproto_$i eval proto=\$${TEMP} if [ -f $TEMPLATES/transmit/${proto}/lircd.conf ] then include_lirc ${BASE}/etc/lircd.conf $TEMPLATES/transmit/${proto}/lircd.conf fi done fi #--------------------------------REVISIT THIS------------------------ #sed -e "s/^REMOTE_NAME=.*$/REMOTE_NAME=${Blastertype} /" $TEMPLATES/change_chan.sh > #${BASE}/usr/bin/change_chan.sh #chmod 755 ${BASE}/usr/bin/change_chan.sh #channel change script change } function setup_blaster_transmiter () { echo "setup_blaster_transmiter" #if it's Reciever type, then these modules have already been loaded. if [ ! x$HostBlasterType = xReceiver ] then case $HostBlasterType in None) echo "no blaster" sed -i -e '/.*#blaster/d' ${BASE}/etc/modules.mythvantage ;; Serial) echo "setup serial lirc blaster" sed -i -e '/.*#blaster/d' ${BASE}/etc/modules.mythvantage echo "lirc_serial #blaster" >> ${BASE}/etc/modules.mythvantage load-modules-mythvantage.sh ;; pvr150) echo "setup hauppauge blaster (lirc_pvr150)" sed -i -e '/.*#blaster/d' ${BASE}/etc/modules.mythvantage sed -i -e '/.*#lirc/d' ${BASE}/etc/modules.mythvantage echo "lirc_pvr150 #blaster" >> ${BASE}/etc/modules.mythvantage echo "lirc_pvr150 #lirc" >> ${BASE}/etc/modules.mythvantage #cp_and_log $TEMPLATES/modules/lirc_i2c.conf ${BASE}/etc/modprobe.d/lirc_i2c.conf rmmod lirc_i2c 2>/dev/null load-modules-mythvantage.sh ;; *) sed -i -e '/.*#blaster/d' ${BASE}/etc/modules.mythvantage ;; esac fi } function setupir () { if [ ! x$Remotetype = xtinker ] then setup_ir_remote setup_ir_receiver unload_all_lirc setup_blaster_proto setup_blaster_transmiter RESTART_FE="true" load-modules-mythvantage.sh udev_trigger sleep 1 sv start lircd fi setup_lcd }