Wednesday, January 24, 2007
Creating FC5 a rescue disk in USB stick from windows
All of us who love linux have this little pieces of it we do not dare to try, maybe we think we don't need to know how it is done, maybe it just looks too complicated to be bothered, maybe we are rushing to the nice, more exciting parts of our new Linux book and ALWAYS skip this one part. Why.. we will never need it?... WRONG! sooner or later we will need to know that piece of info.
In my particular case we are talking about creating a Rescue/Boot disc for linux (Fedora Core 5).
Why would you ever need to know this? I can think many scenarios. USB are for more portable and withstand more heavy usage than CDs and DVDs, so they are more likely to be ready when disaster strikes. Not all servers/desktops/laptops have CD-ROMs, even less likely they will have DVD-ROM drive. Normally I use a rescueCD+Net install from DVD. It is a fact that the more media is required on an installation, more things you have to go sour. (that LAST 4th CD of Fedora has a tiny scratch... and there goes those 30 mins of your life...).
So let's get to it:
In your distro you will find : \Images\bootdisk.img this contains ALL the necessary files required for the rescue media to be booted. Sadly it is not as easy as coying the file to the USB Drive. But it is not that hard either.
If you are on linux you could just do this:
dd if=diskboot.img of=/dev/sda1
et voilá! but as Mr. Murphy will have it, the server that is down will be for sure the ONLY one with linux and a DVD.
So, in your laptop you have windows installed, and a DVD ROM... (yes you know you have windows there!! admit it!)
Normally, you can read around and they will suggest that you use the rawrite utility, or it nice GUI cousin rawwritewin, but sadly those two
will only write to a Floppy Drive or will complain that they have no info in the sectors of that drive. So we are in trouble. Please stand up, and cheer our saviour:
dd for win which you can find here
Go ahead, download that and extract it to a directory, after that just type:
dd if=D:\diskboot.img of=\\.\E:
where D drive is your DVD-ROM and E: is your USB stick.
And you are ready.
Remember not all BIOS are created equal, be sure to check the boot order and see if USB is available at all. Else just like me you would have just wasted some time creating your own
USB FC5 rescue disk!!
Hope this help!! See ya!
Sunday, January 21, 2007
I deleted zlib in a live environment!
I really don't know what the BIG deal about RHEL is; if anything i have found it to be annoying, HARD to upgrade (rpms are scarce). Definitively CentOS is wiser choice. Try upgrading to PHP 5.2 on RHEL 4! now... just for kicks try the upgrade on a X86_64 platform. I have been going crazy about this. Some good soul posted his experiences on a 686 platform:
http://www.jasonlitka.com/2006/11/30/upgrading-php-520-rhel-centos/
I have being trying to get all the dependencies for X86_64 and it is very very hard. While i was going crazy about getting a succesful spec build:
rpmbuild -bb php.sec
I get many many many dependencies issues (sqlite,mysql-dev,libpng,etc,etc,etc,etc) I bump that it is complaing about a libc flag not being there "-fPIC", I start searching the web for references for this happening to someone else, and i find several places pointing to a solution by simply updating the zlib libraries.
Never I suspected i was about to venture into dark, scary, uncharted territory. So being as naive as i can i write
http://www.jasonlitka.com/2006/11/30/upgrading-php-520-rhel-centos/
I have being trying to get all the dependencies for X86_64 and it is very very hard. While i was going crazy about getting a succesful spec build:
rpmbuild -bb php.sec
I get many many many dependencies issues (sqlite,mysql-dev,libpng,etc,etc,etc,etc) I bump that it is complaing about a libc flag not being there "-fPIC", I start searching the web for references for this happening to someone else, and i find several places pointing to a solution by simply updating the zlib libraries.
Never I suspected i was about to venture into dark, scary, uncharted territory. So being as naive as i can i write
rpm -e --nodeps zlib(dont remember the full name)
Let the fun begin:
First i notice that wget, ssh, up2date,rpm or mostly anything else for that matter is working anymore, uh oh. Let me say it again: Uh oh.
Funny thing, this is a colocation server. I am i a different Country, i have no access to the server. I call up the people at The Planet, they suggest i get an OS reload. NOT a choice, there is a lot of valuable data there that would take DAYS to restore since i would have to upload everything again. (whole story being that i HAD to build the .rpm there since there is no php 5.2 rpm for RHEL and i dont have access to another server with the same characteristics).
I noticed that ftp is about the only service currently working. So i went to grab zlib at
First i notice that wget, ssh, up2date,rpm or mostly anything else for that matter is working anymore, uh oh. Let me say it again: Uh oh.
Funny thing, this is a colocation server. I am i a different Country, i have no access to the server. I call up the people at The Planet, they suggest i get an OS reload. NOT a choice, there is a lot of valuable data there that would take DAYS to restore since i would have to upload everything again. (whole story being that i HAD to build the .rpm there since there is no php 5.2 rpm for RHEL and i dont have access to another server with the same characteristics).
I noticed that ftp is about the only service currently working. So i went to grab zlib at
http://www.zlib.net/
Since gunzip or tar are not working i had to extract the files in some other server and upload the files already extracted.
After that i cross my fingers and write
After that i cross my fingers and write
./configure
Nope, not working so i read further and notice that i should write for my system
./configure --shared --lib=/usr/lib64
I got away with this one easily... scared but no harm done.
I hope this helps someone. I learned that if you get a collocation server... do yourself a favor and get NAS.
Bye!
I got away with this one easily... scared but no harm done.
I hope this helps someone. I learned that if you get a collocation server... do yourself a favor and get NAS.
Bye!
Sunday, December 10, 2006
Asterisk + Freetds +MSSQL 2000
If you are anything like my surely you like to steer clear of all things NOT opensource (i.e. Microsoft) althought I got to admit i have always had a soft spot for Solaris (mmm thinking about it I don't were they stand these days in OpenSource world...) but there comes time that it is unavoidable to work with some of this stuff.
One of the things I love about linux is that it will handle all/most things you throw at it and MSSQL Server integration is one of those, here is my recipe:
Ok lets start cooking.
freetds part
#tar -xzvzf freetds-stable.tgz
# cd freetds-0.64
#./configure --prefix=/usr/local/freetds --with-tdsver=8.0 (we will be installing inito /usr/local/freetds dir, and since we will be using it for MSSQL we us version 8.0 of TDS)
#make
#make install
DBD-Sybase part
#tar -xvzf DBD-Sybase-1.07.tar.gz
#cd DBD-Sybase-1.07
#export set SYBASE=/usr/local/freetds
#export set LD_LIBRARY_PATH (this is REALLY really really important step, it will save you dealing with the Dynaloader.pm error which took me a LONG LONG LONG time to figure out... i wish i had this recipe in my hands a few years ago...)
#./configure
#make
#make install
Ok, now I will throw out a little example on how to use this with Asterisk::AGI this next program connects to MSSQL and checks if the callerid of the calling party is a client.
alright aaaall together now:
#!/usr/bin/perl
use Asterisk::AGI;
use DBI;
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse(); #Read in the initial data
#Connect to MSSQL Server
$user = "user";
$passwd = "password";
$dbh = DBI->connect("DBI:Sybase:server=10.1.34.0", $user, $passwd, {PrintError => 0});
$dbh->do("use Clients");
unless ($dbh) {
die "Unable for connect to server $DBI::errstr";
}
$AGI->verbose("Checking IF client",1);
$sql = "select count(*) from clients where ClientPhone=\"$input{callerid}\"";
$sth = $dbh->prepare($sql);
$sth->execute();
while ( my @row = $sth->fetchrow_array( ) ) {
$isclient=$row[0];
}
$sth->finish();
$dbh->disconnect();
if ($isclient > 0)
{
$AGI->verbose("$input{callerid} is a client!!",1);
$AGI->stream_file('you are a client');
}
else
{
$AGI->verbose("$input{callerid} is not a client!!",1);
$AGI->stream_file('you are not a client');
}
Pretty neat huh? I thought so!! Good luck!
One of the things I love about linux is that it will handle all/most things you throw at it and MSSQL Server integration is one of those, here is my recipe:
- freetds , an open source Tabular Data Stream implementation. TDS is the protocol that databases such as Sybase and MSSQL "speak", there are many versions of it, MS SQL 2000 version is TDS 8.0
- DBD-Sybase Perl Module, although the name can seem misleading, since Sybase and MSSQL both "speak" TDS it allows the Perl DBI driver to work with both. As of this writing the latest version is 1.07
Ok lets start cooking.
freetds part
#tar -xzvzf freetds-stable.tgz
# cd freetds-0.64
#./configure --prefix=/usr/local/freetds --with-tdsver=8.0 (we will be installing inito /usr/local/freetds dir, and since we will be using it for MSSQL we us version 8.0 of TDS)
#make
#make install
DBD-Sybase part
#tar -xvzf DBD-Sybase-1.07.tar.gz
#cd DBD-Sybase-1.07
#export set SYBASE=/usr/local/freetds
#export set LD_LIBRARY_PATH (this is REALLY really really important step, it will save you dealing with the Dynaloader.pm error which took me a LONG LONG LONG time to figure out... i wish i had this recipe in my hands a few years ago...)
#./configure
#make
#make install
Ok, now I will throw out a little example on how to use this with Asterisk::AGI this next program connects to MSSQL and checks if the callerid of the calling party is a client.
alright aaaall together now:
#!/usr/bin/perl
use Asterisk::AGI;
use DBI;
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse(); #Read in the initial data
#Connect to MSSQL Server
$user = "user";
$passwd = "password";
$dbh = DBI->connect("DBI:Sybase:server=10.1.34.0", $user, $passwd, {PrintError => 0});
$dbh->do("use Clients");
unless ($dbh) {
die "Unable for connect to server $DBI::errstr";
}
$AGI->verbose("Checking IF client",1);
$sql = "select count(*) from clients where ClientPhone=\"$input{callerid}\"";
$sth = $dbh->prepare($sql);
$sth->execute();
while ( my @row = $sth->fetchrow_array( ) ) {
$isclient=$row[0];
}
$sth->finish();
$dbh->disconnect();
if ($isclient > 0)
{
$AGI->verbose("$input{callerid} is a client!!",1);
$AGI->stream_file('you are a client');
}
else
{
$AGI->verbose("$input{callerid} is not a client!!",1);
$AGI->stream_file('you are not a client');
}
Pretty neat huh? I thought so!! Good luck!
Thursday, December 7, 2006
/bin/rm: Argument list too long.
"what, a savvy guy like me having problems with a simple shell command like rm? Pleaaasee!!"
Linux always finds a way to make you humble again. Just when you begin to get cocky it has a way of slapping you behind the head and keeping you alert again. I just had such an experience...
while trying to delete a big directory (big as in many files....) i do this:
#rm -fr 200611*
and i get this:
/bin/rm: Argument list too long.
oh the agony... the intrigue... but don't worry... there is a way around this (as everything else in Linux).
strange as it seems most of the /bin/ commands have a limit of items it can process in order to avoid buffer overflows...so now it is time to ask our dear bash shell to help us out.
try this instead:
#find . -name '200611*'|xargs rm
this very simple script finds all files in the current directory which names starts with 200611 and then deletes them, passing the results via xargs and deleting them. xargs takes care for us to process batches of information big enough so the system may handle them without causing a buffer overflow. If more than one batch is needed, no problem xargs takes care of this.
Got slapped in the back also? kinda makes me feel in kindergarten all over again... don't eat the crayon...don't eat the crayon...
Friday, December 1, 2006
Modifying Asterisk Meetme enter/leave sounds Part 2
Ok, so im still dealing with modifying app_meetme.c enter/leave sounds. It is getting a little bit complicated.
I've found a little ms dos/windows utility called bin2h , you can find it here:
http://jonripley.com/windows/Software/bin2h/
this utility successfully converts binary files (audio, images) into a hex array that can be used in C.
Now my problem basically lies in understanding in which sound format i should record the sounds i want to be played during the enter/leave process of the conference.
The original enter.h files has this commented in the very beginning of the file:
Pretty easy huh? .raw file... 8 bit U-law? WRONG... i can't seem to get this sound file right..
with sox I'm trying the following command
sox audio.wav -r 8000 -c1 audio.ul
then from windows I do: bin2h audio.ul audio.h, replace/rename this into enter.h... recompile asterisk source... and then
NOTHING...
but we are still working on it.. so hopefully we get some results in part 3.
Bye!
I've found a little ms dos/windows utility called bin2h , you can find it here:
http://jonripley.com/windows/Software/bin2h/
this utility successfully converts binary files (audio, images) into a hex array that can be used in C.
Now my problem basically lies in understanding in which sound format i should record the sounds i want to be played during the enter/leave process of the conference.
The original enter.h files has this commented in the very beginning of the file:
00001 /* 00002 * U-law 8-bit audio data 00003 * 00004 * Source: enter.raw
Pretty easy huh? .raw file... 8 bit U-law? WRONG... i can't seem to get this sound file right..
with sox I'm trying the following command
sox audio.wav -r 8000 -c1 audio.ul
then from windows I do: bin2h audio.ul audio.h, replace/rename this into enter.h... recompile asterisk source... and then
NOTHING...
but we are still working on it.. so hopefully we get some results in part 3.
Bye!
Tuesday, November 28, 2006
Modifying Asterisk Meetme enter/leave sounds Part 1
hi there! this is my first post.
Im trying right now to change the sounds made when a person enters or leaves a conference room in Asterisk.
I was somehow disappointed to see that this sounds are HARDCODED into the app_meetme.c file
From the developer documentation I found out that enter and leave functions
call these files:
enter.h
and
leave.h
basically enter.h says this at the very beginning:
00001 /* 00002 * U-law 8-bit audio data 00003 * 00004 * Source: enter.raw 00005 * 00006 * Copyright (C) 1999, Mark Spencer and Linux Support Services 00007 * 00008 * Distributed under the terms of the GNU General Public License 00009 * 00010 */ 00011
00012 static unsigned char enter[] = {
00013 0xba, 0xba, 0xb0, 0xa6, 0xa9, 0xb8, 0xfe, 0x46, 0x42, 0x46,
So now I must find a way to change a wav or gsm file into this type of C array...
Im starting to fiddle around with sox, and i think i can get a raw output there...
now the challenge will be to find a utility that changes this binary output into a valid C array!!
Hope i have some good news in Part 2!!
Subscribe to:
Posts (Atom)