📄 w_scan_start.sh
字号:
# I don't actually know which generic dvb Modules are *really* needed here # may be i should add some more here? # which generic dvb modules should be always loaded? MODULES_TO_LOAD="videodev v4l1_compat \ v4l2_common video_buf dvb_core ves1820 \ dvb_ttpci \ budget_ci budget_av budget_ci budget " # module ves1820 doesnt state that it needs dvb-ttpci (hg from 08/2006), therefore # my algorithm will fail and depmod will not add the dependency. :-( # may be more modules? # which modules should *not* be loaded? # i.e. ivtv as it will be found by the automatic algorithm below.. MODULES_BLACKLISTED="ivtv" #------------------------------------------ usb device search ----------------- if [ -e /sys/bus/usb/devices ] && [ -e /lib/modules/$(uname -r)/modules.usbmap ]; then for i in /sys/bus/usb/devices/*; do if [ ! -e $i/idVendor ]; then # no Vendor ID given, ignore this item continue fi read bDeviceSubClass < $i/bDeviceSubClass read bDeviceClass < $i/bDeviceClass class=$bDeviceClass$bDeviceSubClass # accept only USB Ethernet Networking, USB Video, USB Miscellaneous Device Cable Based # and USB Vendor Specific Class/Subclass if [ "$class" != "0206" ] && [ "$bDeviceClass" != "0e" ] && [ "$class" != "ef03" ] && [ "$class" != "ffff" ]; then continue fi class_name="unknown" vendor_name="unknown" device_name="unknown" subvendor_name="unknown" driver="" read idVendor < $i/idVendor read idProduct < $i/idProduct # avoid errors if ressource not available if [ ! -e $(pwd)/usb.ids ] || [ ! -e $(pwd)/usb.classes ]; then DEBUG_LOADDRIVER=false fi if [ $DEBUG_LOADDRIVER == true ]; then while read line; do if [ "${line:0:4}" == "$class" ]; then class_name=${line:6:40} break fi done < $(pwd)/usb.classes while read line; do if [ "${line:0:4}" == "$idVendor" ]; then vendor_name=${line:6:80} while read line; do if [ "${line:0:6}" == "||$idProduct" ]; then device_name=${line:8:80} fi if [ "${line:0:2}" != "||" ]; then # next pci id break fi done break fi done < $(pwd)/usb.ids fi while read line; do data=$line for id in "usb module" match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi \ bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass \ bInterfaceSubClass bInterfaceProtocol driver_info; do if [ "$id" == "usb module" ]; then d=${data:0:21} fi if [ "$id" == "idVendor" ]; then if [ "${data:35:4}" != "$idVendor" ]; then break fi fi if [ "$id" == "idProduct" ]; then if [ "${data:44:4}" != "$idProduct" ] && [ "${data:45:4}" != "ffff" ]; then break fi driver=$d fi if [ "$driver" != "" ]; then break fi done done < /lib/modules/$(uname -r)/modules.usbmap MODULES_TO_LOAD="$MODULES_TO_LOAD$driver " if [ $DEBUG_LOADDRIVER == true ]; then echo "----------------------------------------------------------------------------" echo $i echo "vendor: $idVendor ($vendor_name)" echo "product: $idProduct ($device_name)" echo "class: $class ($class_name)" echo "module: $driver" fi done else # fallback solution :-( # which usb modules should be loaded if auto detection fails? echo "WARNING: using stupid fallback solution for usb devices." MODULES_TO_LOAD="$MODULES_TO_LOADcinergyT2 ttusb_dec \ dvb-ttusb-budget dvb-usb-vp7045 dvb-usb-umt-010 \ dvb-usb-nova-t-usb2 dvb-usb-dtt200u dvb-usb-digitv \ dvb-usb-dibusb-mc dvb-usb-cxusb dvb-usb-a800 " fi #-------------------------------------- end usb device search ----------------- #------------------------------------------ pci device search ----------------- if [ -e /sys/bus/pci/devices ] && [ -e /lib/modules/$(uname -r)/modules.pcimap ]; then for i in /sys/bus/pci/devices/*; do read class < $i/class # accept only PCI Multimedia video controller, PCI Multimedia controller (not specified) and # PCI Network controller (not specified) if [ "${class:2:4}" != "0480" ] && [ "${class:2:4}" != "0400" ] && [ "${class:2:4}" != "0280" ]; then continue fi class_name="unknown" vendor_name="unknown" device_name="unknown" subvendor_name="unknown" driver="" read vendor < $i/vendor read device < $i/device read subvendor < $i/subsystem_vendor read subdevice < $i/subsystem_device # avoid errors if ressource not available if [ ! -e $(pwd)/pci.ids ] || [ ! -e $(pwd)/pci.classes ]; then DEBUG_LOADDRIVER=false fi if [ $DEBUG_LOADDRIVER == true ]; then while read line; do if [ "${line:0:4}" == "${class:2:4}" ]; then class_name=${line:5:40} break fi done < $(pwd)/pci.classes while read line; do if [ "${line:0:4}" == "${vendor:2:4}" ]; then vendor_name=${line:5:80} while read line; do if [ "${line:0:6}" == "||${device:2:4}" ]; then device_name=${line:7:80} fi if [ "${line:0:2}" != "||" ]; then # next pci id break fi done break fi done < $(pwd)/pci.ids while read line; do if [ "${line:0:4}" == "${subvendor:2:4}" ]; then subvendor_name=${line:5:80} break fi done < $(pwd)/pci.ids fi while read line; do data=$line for id in "pci module" vendor device subvendor subdevice class class_mask driver_data; do if [ "$id" == "pci module" ]; then d=${data:0:21} fi if [ "$id" == "vendor" ]; then if [ "${data:27:4}" != "${vendor:2:4}" ]; then break fi fi if [ "$id" == "device" ]; then if [ "${data:38:4}" != "${device:2:4}" ] && [ "${data:38:4}" != "ffff" ]; then break fi fi if [ "$id" == "subvendor" ]; then if [ "${data:49:4}" != "${subvendor:2:4}" ] && [ "${data:49:4}" != "ffff" ]; then break fi fi if [ "$id" == "subdevice" ]; then if [ "${data:60:4}" != "${subdevice:2:4}" ] && [ "${data:60:4}" != "ffff" ]; then break fi driver=$d fi if [ "$driver" != "" ]; then break fi done done < /lib/modules/$(uname -r)/modules.pcimap MODULES_TO_LOAD="$MODULES_TO_LOAD$driver " if [ $DEBUG_LOADDRIVER == true ]; then echo "----------------------------------------------------------------------------" echo $i echo "vendor: $vendor ($vendor_name)" echo "device: $device ($device_name)" echo "subvendor: $subvendor ($subvendor_name)" echo "subdevice: $subdevice" echo "class: ${class:0:6} ($class_name)" echo "module: $driver" fi done else # fallback solution :-( # which pci modules should be loaded if auto detection fails? echo "WARNING: using stupid fallback solution for pci devices." MODULES_TO_LOAD="$MODULES_TO_LOADb2c2-flexcop-pci \ tda1004x ves1x93 ves1820 cx24110 \ mt352 saa7146 saa7146_vv " fi #-------------------------------------- end pci device search ----------------- #-------------------------------------- loading kernel modules ---------------- for m in $MODULES_TO_LOAD; do blacklisted=false for n in $MODULES_BLACKLISTED; do if [ "$n" == "$m" ]; then blacklisted=true break fi done if [ $blacklisted == false ]; then PATTERN=$(echo $m | sed 's/-/_/g') MODULES=$(lsmod | grep $PATTERN) echo "Checking for kernel module $m.." module_loaded=false for ml in $MODULES; do if [ "$PATTERN" == "$ml" ]; then module_loaded=true break fi done if [ $module_loaded == false ]; then echo_not_loaded echo " Loading module $m..." modprobe $m eval_retval if [ -f $UDEVSTART ]; then $UDEVSTART fi else echo_loaded fi fi done sleep 3 # give udev time to create all device nodes #---------------------------------- end loading kernel modules ----------------}function DoScan (){ if [ -e channels.conf-$DATE ]; then rm -f channels.conf-$DATE fi touch channels.conf-$DATE WHAT_TO_SCAN=$($W_SCAN -f? 2>&1) echo "Checking for DVB-T..." if [ ${WHAT_TO_SCAN:0:2} != 0 ]; then echo_yes else echo_no fi echo "Checking for DVB-C..." if [ ${WHAT_TO_SCAN:3:2} != 0 ]; then echo_yes else echo_no fi echo -e -n $SUCCESS echo "****************************************************************" echo "* *" echo "* Channel scan will take some minutes - have a cup of coffee.. *" echo "* PRESS ANY KEY TO CONTINUE OR CTRL+C TO EXIT. *" echo "* *" echo "****************************************************************" echo -e -n $NORMAL && tput sgr0 read echo -e -n $NORMAL echo -e -n "\\033[1;34m" if [ ${WHAT_TO_SCAN:0:2} != 0 ]; then $W_SCAN >> channels.conf-$DATE fi if [ ${WHAT_TO_SCAN:3:2} != 0 ]; then $W_SCAN -fc >> channels.conf-$DATE fi echo -e -n $NORMAL}function CopyConf (){ if [ -s channels.conf-$DATE ]; then clear echo -e -n $SUCCESS echo "****************************************************************" echo "* *" echo "* w_scan is done. *" echo -e "* The output file is called "$FAILURE"channels.conf-$DATE"$SUCCESS". *" echo "* Should I copy this to default location for you? [y/n] *" echo "* *" echo "****************************************************************" echo -e -n $NORMAL && tput sgr0 read RESPONSE echo -e -n $NORMAL if [ "$RESPONSE" != "y" ]; then echo "Copying channels.conf skipped - okay." echo "The channels.conf generated can be found at" echo -n -e "\\033[1;34m" echo "$(pwd)/channels.conf-$DATE" echo "" echo -e -n $NORMAL else if [ -d /etc/vdr ]; then mv /etc/vdr/channels.conf /etc/vdr/channels.conf-backup$DATE cp channels.conf-$DATE /etc/vdr/channels.conf fi if [ -d /var/lib/vdr ]; then mv /var/lib/vdr/channels.conf /var/lib/vdr/channels.conf-backup$DATE cp channels.conf-$DATE /var/lib/vdr/channels.conf fi fi else clear echo -e -n $FAILURE echo "****************************************************************" echo "* *" echo "* Something went wrong. The channels.conf generated is *EMPTY*!*" echo "* To analyze your problem I recommend the command *" echo "* './w_scan 2>&1 | tee w_scan.log-dvbt && *" echo "* ./w_scan -fc 2>&1 | tee w_scan.log-dvbc' *" echo "* *" echo "* w_scan will report the problem into the logfiles *" echo "* w_scan.log-dvbt and w_scan.log-dvbc. *" echo "* *" echo "* PRESS ANY KEY TO CONTINUE *" echo "****************************************************************" echo -e -n $NORMAL read fi}# the program itself.# init global vars here (if not avoidable..)# and start functions# --wirbelecho -e -n $NORMALCheckBinary "$W_SCAN"CheckVersionsGreetingStopVDRLoadDriverDoScanCopyConfStartVDR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -