A handy place to share and work on code.
http://gist.github.com/
Wednesday, July 21, 2010
hdvideo2ipod.sh
Here is a little bash script I have been working on to convert h.264 DVB-T transmissions into something a little more compatible with my iPod touch.
converted to a project so we can do some work on it...
http://github.com/Craigosaurous/hdvideo2ipod
converted to a project so we can do some work on it...
http://github.com/Craigosaurous/hdvideo2ipod
Monday, May 17, 2010
Asterisk CallerID look up script for NZ.
It works with by scraping results from yellow pages, where you can feed it a number and if there is a listing that matchs then it returns the company details.
FreePBX Setup
Go to CallerID Lookup Sources and define your own source as following:
Go to Inboud Routes:
Internet Services Setup
Since we are using xinetd, put the following in your /etc/services:
and put the following in xinetd.conf:
Then restart the xinetd daemon with...
Create and install script:
Save as callerid.sh, copy into /usr/local/bin and make it executable...
Make two blank files for the retrieved and unknown callers numbers to be saved, and set the file permissions, and owner to the asterisk user.
Done.
FreePBX Setup
Go to CallerID Lookup Sources and define your own source as following:
Source type: HTTP
cache results: yes ( populates PhoneBook automatically and saves bandwidth)
Host: localhost
Port: 8071
Path: /
Query: [NUMBER]&${CALLERID(name)}
Go to Inboud Routes:
Set the CID Lookup Source to your own source in all Inbound Routes
Internet Services Setup
Since we are using xinetd, put the following in your /etc/services:
asterisklookup 8071/tcp # asterisk lookup
and put the following in xinetd.conf:
service asterisklookup
{
socket_type = stream
protocol = tcp
wait = no
user = asterisk
group = asterisk
server = /usr/local/bin/callerid.sh
disable = no
}
Then restart the xinetd daemon with...
/etc/init.d/xinetd -restart
Create and install script:
#!/bin/sh
read THE_REQUEST
NUMBER=`echo -n $THE_REQUEST | cut -d "?" -f 2`
NUMBER=`echo -n $NUMBER | cut -d "&" -f 1`
INNAME=`echo -n $THE_REQUEST | cut -d "&" -f 2`
INNAME=${INNAME// HTTP\/?.?/}
INNAME=`echo -n ${INNAME} | /usr/bin/strings`
NUMBER=`echo -n ${NUMBER} | /usr/bin/strings`
echo
if [ ${#NUMBER} == 0 ]
then
NUMBER="Unknown"
else
#national number add leading zero
if [ ${NUMBER:0:1} != "0" ]
then
NUMBER="0"${NUMBER}
fi
#international number two leading zero
if [ ${#NUMBER} = 12 ]
then
NUMBER="0"${NUMBER}
fi
NAME=`cat /root/caller-id.txt | grep -i "${NUMBER}" | cut -d "," -f 2 | cut -b 2-`
#not found in local lookup check unknown file
if [ "$NAME" == "" ]
then
NAME=`cat /root/caller-id-unknown.txt | grep -i "${NUMBER}" | cut -d "," -f 2 | cut -b 2-`
fi
#name not found in unknown list check yellow pages
if [ "$NAME" == "" ]
then
NAME=`lynx -connect_timeout=3 -dump http://yellow.co.nz/search/new+zealand/${NUMBER}-1.html 2>/dev/null | grep -i "tick to compare" -A 3 | grep -v -F "[_]" | cut -s -d "]" -f 2`
#result from yellow pages add to local lookup list
if [ "$NAME" != "" ]
then
echo ${NUMBER}, ${NAME} >> /root/caller-id.txt
else
echo ${NUMBER}, Unknown >> /root/caller-id-unknown.txt
fi
fi
NAME=`echo -n ${NAME} | /usr/bin/strings`
#test result returned from local lookup or yellow pages
if [ "$NAME" == "" ]
then
if [ "$INNAME" != "" ]
then
echo $INNAME
else
echo ${NUMBER}
fi
else
echo ${NAME}
fi
Save as callerid.sh, copy into /usr/local/bin and make it executable...
chmod a+x /usr/local/bin/callerid.sh
Make two blank files for the retrieved and unknown callers numbers to be saved, and set the file permissions, and owner to the asterisk user.
echo > caller-id.txt
echo Unknown, Unknown > caller-id-unknown.txt
sudo chown asterisk:asterisk caller-id*
sudo chmod a+rw caller-id*
Done.
Wednesday, May 12, 2010
Myth 0.23 - Upgrade woes
Last night the new install for MythTV 0.23 came down the pike, and showed up in the software updates.
Ya! I thought, and after a lot of downloading and installing it finally arrived, but myth backend had gone away and would start as a service, but would not connect to the database. The backend would run as a program if it was started from the command prompt.
After a lot of looking at files, the internet, and comparisons against the test machine, I discovered that it couldn't access the mysql.txt file, as it was looking for it in /.mythtv, where it should have been in /home/mythtv/.mythtv.
The offending log entries...
2010-05-13 00:46:22.857 mythbackend version: branches/release-0-23-fixes...
2010-05-13 00:46:23.001 Using runtime prefix = /usr
2010-05-13 00:46:23.061 Using configuration directory = /.mythtv
2010-05-13 00:46:23.133 Unable to read configuration file mysql.txt
2010-05-13 00:46:23.193 Empty LocalHostName.
2010-05-13 00:46:23.258 Using localhost value of mythtv
2010-05-13 00:46:23.323 New DB connection, total: 1
2010-05-13 00:46:23.380 Unable to connect to database!
2010-05-13 00:46:23.435 Driver error was [1/1045]:
QMYSQL: Unable to connect
Database error was:
Access denied for user 'mythtv'@'localhost' (using password: YES)
The FIX...
sudo kate /etc/default/mythtv-backend
Change the ARGS line and add the --user $USER command.
ARGS="--user $USER --logfile /var/log/mythtv/mythbackend.log"
Restart the backend service.
sudo /etc/init.d/mythtv-backend restart
If the same problem still exists check the logs first, to determine the correct directory, then check file permissions, or the contents of the mysql.txt file.
Ya!, now I am a happy camper, off to watch some MythTV!
Ya! I thought, and after a lot of downloading and installing it finally arrived, but myth backend had gone away and would start as a service, but would not connect to the database. The backend would run as a program if it was started from the command prompt.
After a lot of looking at files, the internet, and comparisons against the test machine, I discovered that it couldn't access the mysql.txt file, as it was looking for it in /.mythtv, where it should have been in /home/mythtv/.mythtv.
The offending log entries...
2010-05-13 00:46:22.857 mythbackend version: branches/release-0-23-fixes...
2010-05-13 00:46:23.001 Using runtime prefix = /usr
2010-05-13 00:46:23.061 Using configuration directory = /.mythtv
2010-05-13 00:46:23.133 Unable to read configuration file mysql.txt
2010-05-13 00:46:23.193 Empty LocalHostName.
2010-05-13 00:46:23.258 Using localhost value of mythtv
2010-05-13 00:46:23.323 New DB connection, total: 1
2010-05-13 00:46:23.380 Unable to connect to database!
2010-05-13 00:46:23.435 Driver error was [1/1045]:
QMYSQL: Unable to connect
Database error was:
Access denied for user 'mythtv'@'localhost' (using password: YES)
The FIX...
sudo kate /etc/default/mythtv-backend
Change the ARGS line and add the --user $USER command.
ARGS="--user $USER --logfile /var/log/mythtv/mythbackend.log"
Restart the backend service.
sudo /etc/init.d/mythtv-backend restart
If the same problem still exists check the logs first, to determine the correct directory, then check file permissions, or the contents of the mysql.txt file.
Ya!, now I am a happy camper, off to watch some MythTV!
Tuesday, May 11, 2010
MythTV - Convert Recordings to Podcast
A work in progress
Start CPAN Pearl Administrator
sudo cpan
install YAML
install String::Approx
install XML::Simple
install Date::Parse
install Date::Format
install Lingua::EN::Keywords
install Getopt::Long
install File::Temp
WWW::TV didn't install so commented it out on line 333 with a #
find where midentify is hiding on the pc
sudo find | grep midentify
cp to /usr/local/bin
Upgrade FFMPEG drivers to support H264 and AAC
Modify myth2ipod script and change the '-me' option to '-me-method'
Works with MP2 data from the PVR500, but not yet from the h264 DVB-T source
Start CPAN Pearl Administrator
sudo cpan
install YAML
install String::Approx
install XML::Simple
install Date::Parse
install Date::Format
install Lingua::EN::Keywords
install Getopt::Long
install File::Temp
WWW::TV didn't install so commented it out on line 333 with a #
find where midentify is hiding on the pc
sudo find | grep midentify
cp to /usr/local/bin
Upgrade FFMPEG drivers to support H264 and AAC
Modify myth2ipod script and change the '-me' option to '-me-method'
Works with MP2 data from the PVR500, but not yet from the h264 DVB-T source
Thursday, April 1, 2010
MythTV 0.23 and WinTV HVR-4000
Thanks to Jogdur -> http://ubuntuforums.org/showthread.php?t=1320944 for the posting on ubuntu forums, just had to update the link to the mercurial drivers, now living in the /pub/ directory.
Got yourself a new HVR4000? But it doesn't appear to work correctly under MythTV?
Problem is the latest v4l driver drivers are a little broken in kernels up to and including lucid (2.6.32). Kernel 2.6.33 apparently works fine, not running it here yet...
On my test box I'm now running the beta release of Mythbuntu 10.04.
Firmware:
update, 18/5/2010 new version of drivers 1.26.90.0 following script updated
v4l driver:
add repository deb http://archive.ubuntu.com/ubuntu/ karmic universe main restricted multiverse
update, 18/5/2010 new version of drivers 20100517 following script updated accordingly
After the make menu config completes, navigate you way down through the following menus. and disable FireDTV and FloppyDTV.
-->Multimedia Support -> DVB/ATSC adapters -> disable FireDTV and FloppyDTV. Otherwise the compiling will fail
All done tuning on DVB-T now works. With my AMD XP2500 processor and the 10.04 version HD channels still skip, SD looks great, ETI data updating in the program schedule, and no major crashes in my limited testing. Unfortunately no nVidia graphics card in this box, but it is only the test machine...
Got yourself a new HVR4000? But it doesn't appear to work correctly under MythTV?
Problem is the latest v4l driver drivers are a little broken in kernels up to and including lucid (2.6.32). Kernel 2.6.33 apparently works fine, not running it here yet...
On my test box I'm now running the beta release of Mythbuntu 10.04.
Firmware:
update, 18/5/2010 new version of drivers 1.26.90.0 following script updated
wget http://www.wintvcd.co.uk/drivers/88x_2_125_28070_WHQL.zip
unzip -jo 88x_2_125_28070_WHQL.zip Driver88/hcw88bda.sys
sudo dd if=hcw88bda.sys of=/lib/firmware/dvb-fe-cx24116-1.26.90.0.fw skip=105768 bs=1 count=32674
sudo ln -s /lib/firmware/dvb-fe-cx24116-1.26.90.0.fw /lib/firmware/dvb-fe-cx24116.fw
v4l driver:
add repository deb http://archive.ubuntu.com/ubuntu/ karmic universe main restricted multiverse
update, 18/5/2010 new version of drivers 20100517 following script updated accordingly
sudo su
apt-get install build-essential
apt-get install mercurial cvs subversion libncurses-dev
cd /usr/local/src
hg clone http://hg.kewl.org/pub/v4l-dvb-20100517/
cd v4l-dvb-20100517
cd linux/include/linux
ln -s /usr/src/linux-headers-`uname -r`/include/linux/compiler.h ./
cd ../../../
make menuconfig
After the make menu config completes, navigate you way down through the following menus. and disable FireDTV and FloppyDTV.
-->Multimedia Support -> DVB/ATSC adapters -> disable FireDTV and FloppyDTV. Otherwise the compiling will fail
make
make install
depmod -a
reboot
All done tuning on DVB-T now works. With my AMD XP2500 processor and the 10.04 version HD channels still skip, SD looks great, ETI data updating in the program schedule, and no major crashes in my limited testing. Unfortunately no nVidia graphics card in this box, but it is only the test machine...
Monday, January 11, 2010
Linux - Blocking IP addresses
Ever need to block an IP address from connection to you linux box?
This is quite easy and simple to acheive, with IPTABLES...
# sudo iptables -A INPUT -s 1.2.3.4 -j DROP
just modify the ip address to the one required.
Need to view what IP Addresses have been added to the system
# sudo iptables -L
Remove the blocked IP Address from the chain
# sudo iptables -D INPUT -s 1.2.3.4 -j DROP
This is quite easy and simple to acheive, with IPTABLES...
# sudo iptables -A INPUT -s 1.2.3.4 -j DROP
just modify the ip address to the one required.
Need to view what IP Addresses have been added to the system
# sudo iptables -L
Remove the blocked IP Address from the chain
# sudo iptables -D INPUT -s 1.2.3.4 -j DROP
Subscribe to:
Posts (Atom)