#!/bin/bash . /etc/profile disk=$2 mountpoint=new_boot #------------------------------------------- MYTHDBUSER=mythtv MYTHTVPASSWD=mythtv CMDLINE=$(cat /proc/cmdline) hostname=`hostname` MYSQLCMD_C="mysql -u$MYTHDBUSER -p$MYTHTVPASSWD mythconverg -B --exec" BASE="" function update_db_settings () { printhl " setting database value $1 to $2 for $hostname" $MYSQLCMD_C "delete from settings where value='${1}' and hostname=\"$hostname\";" $MYSQLCMD_C "REPLACE INTO settings set value='${1}', data='${2}' , hostname=\"$hostname\";" } function random_theme () { THEMES="basic-blue basic-green basic-red basic-purple basic-amber" theme=($THEMES) # Read into array variable. num_themes=${#theme[*]} # Count how many elements. pick=${theme[$((RANDOM%num_themes))]} printhl " Selected $pick as the theme" update_db_settings Theme "$pick" } function parse_cmdline_2_db(){ echo $CMDLINE | grep -q displayres if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*displayres=} update_db_settings HostXres $TEMPVAR fi } function bootsplash_setup (){ echo $CMDLINE | grep -q splash=silent if [ $? -eq 0 ] then update_db_settings Hostbootsplash 1 else update_db_settings Hostbootsplash 0 fi } function setupremote { [ -e $BASE/etc/lircd.conf ] && mv -f $BASE/etc/lircd.conf $BASE/etc/lircd.conf.`date +%Y-%m-%d-%H-%M` if [ -d $TEMPLATES/remotes/$Remotetype ] then cd $TEMPLATES/remotes/$Remotetype for i in lircd* do cat $i >> $BASE/etc/lircd.conf done cp -f lircrc* $BASE/etc/lircrc 2> /dev/null [ -e /etc/lircrc ] && chmod 755 /etc/lircrc update_db_settings HostRemoteType "$Remotetype" #special case for special remote printhl "Starting with support for $Remotetype" if [ "$Remotetype" == "dvico" ] then /usr/sbin/lircd -d /dev/usb/hiddev0 else /usr/sbin/lircd -d /dev/lirc0 fi [ -e /root/.mythtv ] || mkdir /root/.mythtv 2>/dev/null ln -s /etc/lircrc /root/.mythtv/lircrc 2>/dev/null else echo "Couldn't open directory $TEMPLATES/remotes/$Remotetype" fi } function scan_for_hpg_receiver() { printhl " Scanning for Hauppauge receiver" for hpgid in `lspci -nm -d4444: |cut -d" " -f6- |tr -d '"'|tr " " :` do line=`grep $hpgid $TEMPLATES/remotes/i2c.id` if [ $? -eq 0 ] then modprobe lirc_i2c FoundReceiverType=`echo "$line"|cut -d"|" -f2` Remotetype=`echo "$line"|cut -d"|" -f4` statusline=`echo "$line"|cut -d"|" -f2,4` #echo "Found $statusline , $Remotetype" echo "Found Hauppauge" echo "-------------------" echo " 1) Hauppauge black" echo " 2) Hauppauge silver" echo " 3) hauppauge-grey-g3" echo "" read -p "Which Hauppauge remote (5 sec): " -t 5 ans echo if [ "$?" != "0" ]; then echo echo "Using default $Remotetype" else case $ans in 1) Remotetype="hauppauge-black";; 2) Remotetype="hauppauge-silver";; 3) Remotetype="hauppauge-grey-g3" ;; *) echo "Using default $Remotetype";; esac fi update_db_settings HostReceiverType $FoundReceiverType setupremote break fi done } function scan_for_usb_remote () { found_remote=1 printhl " Scanning for usb receiver/remote" while read line do USBID=`echo "$line"|cut -d"|" -f1` lsusb -d "$USBID" > /dev/null 2>/dev/null if [ $? -eq 0 ] then Remotetype=`echo "$line"|cut -d"|" -f2` printhl "Found $Remotetype" setupremote found_remote=0 break fi done <$BASE/$TEMPLATES/remotes/receiver_usb.id if [ $found_remote -eq 1 ] then scan_for_hpg_receiver fi printhl " Scanning for TatIR" if lsusb | grep 04d8:0004 > /dev/null 2>/dev/null then /usr/bin/PyroUsb.py > /dev/null 2>&1 & fi } function rest_of_network () { #netmask echo $CMDLINE | grep -q netmask if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*netmask=} NETMASK=${TEMPVAR%% *} /sbin/ifconfig eth0 $IP netmask $NETMASK nm=`/usr/bin/nmconv.py -obits $NETMASK` NETMASK="/$nm $NETMASK" #echo $NETMASK update_db_settings HostNETMASK${MYTHDEFAULT} "$NETMASK" else printhl " Netmask not found" fi #gateway echo $CMDLINE | grep -q gateway if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*gateway=} GATEWAY=${TEMPVAR%% *} /sbin/route add default gw $GATEWAY update_db_settings HostGW${MYTHDEFAULT} "$GATEWAY" else printhl " Gateway not found" fi #dns echo $CMDLINE | grep -q dns if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*dns=} DNS=${TEMPVAR%% *} echo "nameserver $DNS" >> /etc/resolv.conf update_db_settings HostDNS${MYTHDEFAULT} "$DNS" else printhl " DNS not found" fi } function init_network { echo $CMDLINE |grep -q netdev if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*netdev=} MYTHDEFAULT=${TEMPVAR%% *} else MYTHDEFAULT="eth0" fi echo $CMDLINE | grep -q ip if [ $? -eq 0 ] then update_db_settings HostDefaulteth0 0 update_db_settings HostDefault${MYTHDEFAULT} 1 update_db_settings HostActiveonbooteth0 0 update_db_settings HostActiveonboot${MYTHDEFAULT} 1 update_db_settings HostNetDevice ${MYTHDEFAULT} TEMPVAR=${CMDLINE#*ip=} IP=${TEMPVAR%% *} if [ "$IP" == "dhcp" ] then /sbin/dhcpcd $MYTHDEFAULT update_db_settings HostUseDHCP${MYTHDEFAULT} 0 else /sbin/ifconfig ${MYTHDEFAULT} $IP update_db_settings HostUseDHCP${MYTHDEFAULT} 1 update_db_settings HostIP${MYTHDEFAULT} "$IP" rest_of_network fi fi } function init_remote { echo $CMDLINE | grep -q remoteport if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*remoteport=} REMOTEPORT=${TEMPVAR%% *} if [ x"$ReceiverType" = "xSerial" ] then if [ -e /dev/$REMOTEPORT ] then /usr/bin/setserial /dev/$REMOTEPORT uart none /sbin/modprobe lirc_serial update_db_settings HostReceiverType Serial update_db_settings HostSerialPortlirc "$REMOTEPORT" fi fi fi echo $CMDLINE | grep -q remote if [ $? -eq 0 ] then TEMPVAR=${CMDLINE#*remote=} Remotetype=${TEMPVAR%% *} setupremote else scan_for_usb_remote fi } #-----------------------