Posts Tagged Linux

MCOD – 9.28.2011 – Simple OS X Bash Changes

Macintosh Command of the Day Sept 28, 2011

I have no idea why I did not do this sooner!

On my Macs I always had that md5sum the command doesn’t exist, and I hate that the output of the md5 command that does exist is not the same as the GNU tools. Sure it’s BSD (And I’ll always love my BSD), but I think compatibility to the GNU tools buys more for BSD and OS X than incompatibility.

Add this to your ~/.bashrc (and source it or restart your terminal)

alias md5sum='md5 -r '

Now your md5sum <filename> works the same as on the 1,000,000,000 Linux boxes out there.

Also in my .bashrc on my Macbook Air is

alias ll='ls -Falh'
alias lg='ls -Falh|grep -i '
declare -x EDITOR="/usr/bin/vim"
declare -x JAVA_HOME="/usr/"
-Jon

 

, , , , , , , , , ,

No Comments

Ubuntu codenames, my own cheat sheet, rant, and link

I love Ubuntu.

I use it everywhere. I love the Debian based dpkg, the default installs, the Amazon AWS compatible EUC cloud.

I’m also a big fan of cool names, I like having printers and domains and whatever on some big, geeky, internal naming schema, like everything relates to Norse mythology or Star Trek.

But, I CANNOT STAND the code names for Ubuntu projects being used to refer to the version. I’m running Ubuntu 9.04, or 8.04 LTS, or 10.04 LTS, etc. I am not running Ubuntu Honey Badger, or whatever code name they developed under.

This is only annoying when I’m trying to find instructions about how to do something and people say things like  ’Well, I tried this and it worked on Hoary’. WTF is a Hoary? Please, don’t tell me, I don’t care.

So, for my own sanity I am posting this rant, and linking to the page with a list of Development Codes for Ubuntu, as I’m sure, going forward, I’m going to need it.

https://wiki.ubuntu.com/DevelopmentCodeNames

And for my quick use, the versions I use most:

8.04 Hardy Heron

9.04 Jaunty Jackalope

10.04 Lucid lynx

11.04 Natty Narwhal

 

, , , ,

No Comments

LCOD 5.29.2011 – 2 quick TCP port check scripts in Python

Disclaimer : These scripts could be considered malicious and should only be used to test servers with permission from the server administrator. I accept no responsibility for your use of these scripts, and make no warranty about their usefulness either express or implied.

 

I often find myself troubleshooting someone’s network connectivity, or one of my servers ability to receive connections or mass connections.

For this, nmap is invaluable, but sometimes it’s easier to just send someone a script to run, especially in larger companies where things like nmap, and other port scanners are frowned on.

So, here are 2 scripts that take the same arguments HOST PORT.

They are tcpcheck.py (here is the gzipped version), and tcpcheck-bulk.py (here is the gzipped version).

tcpcheck.py makes 1 connection to a TCP port and reports success or failure.

Example usage and output  :

./tcpcheck.py jonzobrist.com 80
Success. Connected to jonzobrist.com on port: 80

./tcpcheck.py jonzobrist.com 81
Failure. Cannot connect to jonzobrist.com on port: 81

tcpcheck-bulk.py is hard wired to attempt 1500 connections to a TCP port and reports success/failures.

Example usage and output is :

./tcpcheck-bulk.py jonzobrist.com 80
Done with jonzobrist.com on port: 80
Done. Failures : 0 Successes : 1500

This script was very useful when we tried to determine server performance over a link that seemed to be killing our connections.

Please feel free to use it, and share if it helped.

, , , , , , , ,

No Comments

Delete lots of EC2 EBS volumes

Here is a quick script to delete lots of EBS volumes on Amazon EC2.

The output from something like

ec2-describe-instances i-6fc30f01 | grep ‘^BLOCKDEVICE’ | awk ‘{ print $3 }’ > delete-these-volumes.txt

Then run

./delete-volumes.sh delete-these-volumes.txt

Can be fed into this script (you may want to edit the file first, I accept no responsibility for you deleting your volumes, with or without my script.

Download the gzipped script here.

 

#!/bin/bash
if [ "${1}" ]
then
for V in `cat ${1}`
do
ec2-detach-volume ${V}
echo “Waiting for ${V} to detach”
while ! ec2-describe-volumes ${V} | grep -q available
do
echo -n “.”
sleep 1
done
ec2-delete-volume ${V}
echo “Volume ${V} deleted at `date`”
done
else
echo “Usage : ${0} filename”
echo “Where filename is a file with volumes to be deleted”
exit 1
fi

Example output from me deleting 60 real volumes:

time delete-volumes-list.sh i-6fc30f01.info.delvolumes
Client.IncorrectState: Volume ‘vol-3bab1d50′is in the ‘available’ state.
Waiting for vol-3bab1d50 to detach
VOLUME vol-3bab1d50
Volume vol-3bab1d50 deleted at Mon May 23 10:53:56 MDT 2011
ATTACHMENT vol-33ab1d58 i-6fc30f01 /dev/sdh2 detaching 2011-05-23T16:15:08+0000
Waiting for vol-33ab1d58 to detach
VOLUME vol-33ab1d58
Volume vol-33ab1d58 deleted at Mon May 23 10:54:08 MDT 2011
ATTACHMENT vol-07ab1d6c i-6fc30f01 /dev/sdh3 detaching 2011-05-23T16:15:08+0000
Waiting for vol-07ab1d6c to detach
VOLUME vol-07ab1d6c
Volume vol-07ab1d6c deleted at Mon May 23 10:54:21 MDT 2011
ATTACHMENT vol-17ab1d7c i-6fc30f01 /dev/sdh4 detaching 2011-05-23T16:15:08+0000
Waiting for vol-17ab1d7c to detach
VOLUME vol-17ab1d7c
Volume vol-17ab1d7c deleted at Mon May 23 10:54:33 MDT 2011
ATTACHMENT vol-f9ab1d92 i-6fc30f01 /dev/sdh5 detaching 2011-05-23T16:15:08+0000
Waiting for vol-f9ab1d92 to detach
VOLUME vol-f9ab1d92
Volume vol-f9ab1d92 deleted at Mon May 23 10:54:46 MDT 2011
ATTACHMENT vol-c1ab1daa i-6fc30f01 /dev/sdh6 detaching 2011-05-23T16:15:08+0000
Waiting for vol-c1ab1daa to detach
VOLUME vol-c1ab1daa
Volume vol-c1ab1daa deleted at Mon May 23 10:54:58 MDT 2011
ATTACHMENT vol-ddab1db6 i-6fc30f01 /dev/sdh7 detaching 2011-05-23T16:15:08+0000
Waiting for vol-ddab1db6 to detach
VOLUME vol-ddab1db6
Volume vol-ddab1db6 deleted at Mon May 23 10:55:12 MDT 2011
ATTACHMENT vol-a5ab1dce i-6fc30f01 /dev/sdh8 detaching 2011-05-23T16:15:08+0000
Waiting for vol-a5ab1dce to detach
VOLUME vol-a5ab1dce
Volume vol-a5ab1dce deleted at Mon May 23 10:55:24 MDT 2011
ATTACHMENT vol-8bab1de0 i-6fc30f01 /dev/sdh9 detaching 2011-05-23T16:15:08+0000
Waiting for vol-8bab1de0 to detach
VOLUME vol-8bab1de0
Volume vol-8bab1de0 deleted at Mon May 23 10:55:37 MDT 2011
ATTACHMENT vol-85ab1dee i-6fc30f01 /dev/sdh10 detaching 2011-05-23T16:15:08+0000
Waiting for vol-85ab1dee to detach
VOLUME vol-85ab1dee
Volume vol-85ab1dee deleted at Mon May 23 10:55:49 MDT 2011
ATTACHMENT vol-67a81e0c i-6fc30f01 /dev/sdh11 detaching 2011-05-23T16:15:08+0000
Waiting for vol-67a81e0c to detach
VOLUME vol-67a81e0c
Volume vol-67a81e0c deleted at Mon May 23 10:56:01 MDT 2011
ATTACHMENT vol-4da81e26 i-6fc30f01 /dev/sdh12 detaching 2011-05-23T16:15:08+0000
Waiting for vol-4da81e26 to detach
VOLUME vol-4da81e26
Volume vol-4da81e26 deleted at Mon May 23 10:56:17 MDT 2011
ATTACHMENT vol-57a81e3c i-6fc30f01 /dev/sdh13 detaching 2011-05-23T16:15:08+0000
Waiting for vol-57a81e3c to detach
VOLUME vol-57a81e3c
Volume vol-57a81e3c deleted at Mon May 23 10:56:29 MDT 2011
ATTACHMENT vol-1fa81e74 i-6fc30f01 /dev/sdh14 detaching 2011-05-23T16:15:08+0000
Waiting for vol-1fa81e74 to detach
VOLUME vol-1fa81e74
Volume vol-1fa81e74 deleted at Mon May 23 10:56:42 MDT 2011
ATTACHMENT vol-c9a81ea2 i-6fc30f01 /dev/sdi1 detaching 2011-05-23T16:15:08+0000
Waiting for vol-c9a81ea2 to detach
VOLUME vol-c9a81ea2
Volume vol-c9a81ea2 deleted at Mon May 23 10:56:54 MDT 2011
ATTACHMENT vol-afa81ec4 i-6fc30f01 /dev/sdi2 detaching 2011-05-23T16:15:08+0000
Waiting for vol-afa81ec4 to detach
VOLUME vol-afa81ec4
Volume vol-afa81ec4 deleted at Mon May 23 10:57:07 MDT 2011
ATTACHMENT vol-9fa81ef4 i-6fc30f01 /dev/sdi3 detaching 2011-05-23T16:15:08+0000
Waiting for vol-9fa81ef4 to detach
VOLUME vol-9fa81ef4
Volume vol-9fa81ef4 deleted at Mon May 23 10:57:20 MDT 2011
ATTACHMENT vol-6fa91f04 i-6fc30f01 /dev/sdi4 detaching 2011-05-23T16:15:08+0000
Waiting for vol-6fa91f04 to detach
VOLUME vol-6fa91f04
Volume vol-6fa91f04 deleted at Mon May 23 10:57:33 MDT 2011
ATTACHMENT vol-7da91f16 i-6fc30f01 /dev/sdi5 detaching 2011-05-23T16:15:08+0000
Waiting for vol-7da91f16 to detach
VOLUME vol-7da91f16
Volume vol-7da91f16 deleted at Mon May 23 10:57:45 MDT 2011
ATTACHMENT vol-4fa91f24 i-6fc30f01 /dev/sdi6 detaching 2011-05-23T16:15:08+0000
Waiting for vol-4fa91f24 to detach
VOLUME vol-4fa91f24
Volume vol-4fa91f24 deleted at Mon May 23 10:57:58 MDT 2011
ATTACHMENT vol-57a91f3c i-6fc30f01 /dev/sdi7 detaching 2011-05-23T16:15:08+0000
Waiting for vol-57a91f3c to detach
VOLUME vol-57a91f3c
Volume vol-57a91f3c deleted at Mon May 23 10:58:10 MDT 2011
ATTACHMENT vol-33a91f58 i-6fc30f01 /dev/sdi8 detaching 2011-05-23T16:15:08+0000
Waiting for vol-33a91f58 to detach
VOLUME vol-33a91f58
Volume vol-33a91f58 deleted at Mon May 23 10:58:24 MDT 2011
ATTACHMENT vol-07a91f6c i-6fc30f01 /dev/sdi9 detaching 2011-05-23T16:15:08+0000
Waiting for vol-07a91f6c to detach
VOLUME vol-07a91f6c
Volume vol-07a91f6c deleted at Mon May 23 10:58:36 MDT 2011
ATTACHMENT vol-fba91f90 i-6fc30f01 /dev/sdi10 detaching 2011-05-23T16:15:08+0000
Waiting for vol-fba91f90 to detach
VOLUME vol-fba91f90
Volume vol-fba91f90 deleted at Mon May 23 10:58:49 MDT 2011
ATTACHMENT vol-fda91f96 i-6fc30f01 /dev/sdi11 detaching 2011-05-23T16:15:08+0000
Waiting for vol-fda91f96 to detach
VOLUME vol-fda91f96
Volume vol-fda91f96 deleted at Mon May 23 10:59:01 MDT 2011
ATTACHMENT vol-c9a91fa2 i-6fc30f01 /dev/sdi12 detaching 2011-05-23T16:15:08+0000
Waiting for vol-c9a91fa2 to detach
VOLUME vol-c9a91fa2
Volume vol-c9a91fa2 deleted at Mon May 23 10:59:14 MDT 2011
ATTACHMENT vol-afa91fc4 i-6fc30f01 /dev/sdi13 detaching 2011-05-23T16:15:08+0000
Waiting for vol-afa91fc4 to detach
VOLUME vol-afa91fc4
Volume vol-afa91fc4 deleted at Mon May 23 10:59:27 MDT 2011
ATTACHMENT vol-bda91fd6 i-6fc30f01 /dev/sdi14 detaching 2011-05-23T16:15:08+0000
Waiting for vol-bda91fd6 to detach
VOLUME vol-bda91fd6
Volume vol-bda91fd6 deleted at Mon May 23 10:59:39 MDT 2011
ATTACHMENT vol-85a91fee i-6fc30f01 /dev/sdj1 detaching 2011-05-23T16:15:08+0000
Waiting for vol-85a91fee to detach
VOLUME vol-85a91fee
Volume vol-85a91fee deleted at Mon May 23 10:59:52 MDT 2011
ATTACHMENT vol-6d962006 i-6fc30f01 /dev/sdj2 detaching 2011-05-23T16:15:08+0000
Waiting for vol-6d962006 to detach
VOLUME vol-6d962006
Volume vol-6d962006 deleted at Mon May 23 11:00:05 MDT 2011
ATTACHMENT vol-7196201a i-6fc30f01 /dev/sdj3 detaching 2011-05-23T16:15:08+0000
Waiting for vol-7196201a to detach
VOLUME vol-7196201a
Volume vol-7196201a deleted at Mon May 23 11:00:17 MDT 2011
ATTACHMENT vol-59962032 i-6fc30f01 /dev/sdj4 detaching 2011-05-23T16:15:08+0000
Waiting for vol-59962032 to detach
VOLUME vol-59962032
Volume vol-59962032 deleted at Mon May 23 11:00:29 MDT 2011
ATTACHMENT vol-2196204a i-6fc30f01 /dev/sdj5 detaching 2011-05-23T16:15:08+0000
Waiting for vol-2196204a to detach
VOLUME vol-2196204a
Volume vol-2196204a deleted at Mon May 23 11:00:42 MDT 2011
ATTACHMENT vol-3596205e i-6fc30f01 /dev/sdj6 detaching 2011-05-23T16:15:08+0000
Waiting for vol-3596205e to detach
VOLUME vol-3596205e
Volume vol-3596205e deleted at Mon May 23 11:00:54 MDT 2011
ATTACHMENT vol-0796206c i-6fc30f01 /dev/sdj7 detaching 2011-05-23T16:15:08+0000
Waiting for vol-0796206c to detach
VOLUME vol-0796206c
Volume vol-0796206c deleted at Mon May 23 11:01:07 MDT 2011
ATTACHMENT vol-ed962086 i-6fc30f01 /dev/sdj8 detaching 2011-05-23T16:15:08+0000
Waiting for vol-ed962086 to detach
VOLUME vol-ed962086
Volume vol-ed962086 deleted at Mon May 23 11:01:19 MDT 2011
ATTACHMENT vol-ff962094 i-6fc30f01 /dev/sdj9 detaching 2011-05-23T16:15:08+0000
Waiting for vol-ff962094 to detach
VOLUME vol-ff962094
Volume vol-ff962094 deleted at Mon May 23 11:01:32 MDT 2011
ATTACHMENT vol-fd962096 i-6fc30f01 /dev/sdj10 detaching 2011-05-23T16:15:08+0000
Waiting for vol-fd962096 to detach
VOLUME vol-fd962096
Volume vol-fd962096 deleted at Mon May 23 11:01:45 MDT 2011
ATTACHMENT vol-d39620b8 i-6fc30f01 /dev/sdj11 detaching 2011-05-23T16:15:08+0000
Waiting for vol-d39620b8 to detach
VOLUME vol-d39620b8
Volume vol-d39620b8 deleted at Mon May 23 11:01:57 MDT 2011
ATTACHMENT vol-a59620ce i-6fc30f01 /dev/sdj12 detaching 2011-05-23T16:15:08+0000
Waiting for vol-a59620ce to detach
VOLUME vol-a59620ce
Volume vol-a59620ce deleted at Mon May 23 11:02:10 MDT 2011
ATTACHMENT vol-6f972104 i-6fc30f01 /dev/sdj13 detaching 2011-05-23T16:15:08+0000
Waiting for vol-6f972104 to detach
VOLUME vol-6f972104
Volume vol-6f972104 deleted at Mon May 23 11:02:23 MDT 2011
ATTACHMENT vol-5d972136 i-6fc30f01 /dev/sdj14 detaching 2011-05-23T16:15:08+0000
Waiting for vol-5d972136 to detach
VOLUME vol-5d972136
Volume vol-5d972136 deleted at Mon May 23 11:02:36 MDT 2011
ATTACHMENT vol-3b972150 i-6fc30f01 /dev/sdk1 detaching 2011-05-23T16:15:08+0000
Waiting for vol-3b972150 to detach
VOLUME vol-3b972150
Volume vol-3b972150 deleted at Mon May 23 11:02:48 MDT 2011
ATTACHMENT vol-3797215c i-6fc30f01 /dev/sdk2 detaching 2011-05-23T16:15:08+0000
Waiting for vol-3797215c to detach
VOLUME vol-3797215c
Volume vol-3797215c deleted at Mon May 23 11:03:01 MDT 2011
ATTACHMENT vol-1d972176 i-6fc30f01 /dev/sdk3 detaching 2011-05-23T16:15:08+0000
Waiting for vol-1d972176 to detach
VOLUME vol-1d972176
Volume vol-1d972176 deleted at Mon May 23 11:03:13 MDT 2011
ATTACHMENT vol-ef972184 i-6fc30f01 /dev/sdk4 detaching 2011-05-23T16:15:08+0000
Waiting for vol-ef972184 to detach
VOLUME vol-ef972184
Volume vol-ef972184 deleted at Mon May 23 11:03:26 MDT 2011
ATTACHMENT vol-fd972196 i-6fc30f01 /dev/sdk5 detaching 2011-05-23T16:15:08+0000
Waiting for vol-fd972196 to detach
VOLUME vol-fd972196
Volume vol-fd972196 deleted at Mon May 23 11:03:38 MDT 2011
ATTACHMENT vol-c19721aa i-6fc30f01 /dev/sdk6 detaching 2011-05-23T16:15:08+0000
Waiting for vol-c19721aa to detach
VOLUME vol-c19721aa
Volume vol-c19721aa deleted at Mon May 23 11:03:51 MDT 2011
ATTACHMENT vol-af9721c4 i-6fc30f01 /dev/sdk7 detaching 2011-05-23T16:15:08+0000
Waiting for vol-af9721c4 to detach
VOLUME vol-af9721c4
Volume vol-af9721c4 deleted at Mon May 23 11:04:03 MDT 2011
ATTACHMENT vol-a59721ce i-6fc30f01 /dev/sdk8 detaching 2011-05-23T16:15:08+0000
Waiting for vol-a59721ce to detach
VOLUME vol-a59721ce
Volume vol-a59721ce deleted at Mon May 23 11:04:16 MDT 2011
ATTACHMENT vol-8d9721e6 i-6fc30f01 /dev/sdk9 detaching 2011-05-23T16:15:08+0000
Waiting for vol-8d9721e6 to detach
VOLUME vol-8d9721e6
Volume vol-8d9721e6 deleted at Mon May 23 11:04:28 MDT 2011
ATTACHMENT vol-9d9721f6 i-6fc30f01 /dev/sdk10 detaching 2011-05-23T16:15:08+0000
Waiting for vol-9d9721f6 to detach
VOLUME vol-9d9721f6
Volume vol-9d9721f6 deleted at Mon May 23 11:04:41 MDT 2011
ATTACHMENT vol-33942258 i-6fc30f01 /dev/sdk11 detaching 2011-05-23T16:15:08+0000
Waiting for vol-33942258 to detach
VOLUME vol-33942258
Volume vol-33942258 deleted at Mon May 23 11:04:53 MDT 2011
ATTACHMENT vol-1794227c i-6fc30f01 /dev/sdk12 detaching 2011-05-23T16:15:08+0000
Waiting for vol-1794227c to detach
VOLUME vol-1794227c
Volume vol-1794227c deleted at Mon May 23 11:05:06 MDT 2011
ATTACHMENT vol-fb942290 i-6fc30f01 /dev/sdk13 detaching 2011-05-23T16:15:08+0000
Waiting for vol-fb942290 to detach
VOLUME vol-fb942290
Volume vol-fb942290 deleted at Mon May 23 11:05:19 MDT 2011
ATTACHMENT vol-d99422b2 i-6fc30f01 /dev/sdk14 detaching 2011-05-23T16:15:08+0000
Waiting for vol-d99422b2 to detach
VOLUME vol-d99422b2
Volume vol-d99422b2 deleted at Mon May 23 11:05:31 MDT 2011
ATTACHMENT vol-839422e8 i-6fc30f01 /dev/sdl1 detaching 2011-05-23T16:15:08+0000
Waiting for vol-839422e8 to detach
VOLUME vol-839422e8
Volume vol-839422e8 deleted at Mon May 23 11:05:44 MDT 2011
ATTACHMENT vol-9d9422f6 i-6fc30f01 /dev/sdl2 detaching 2011-05-23T16:15:08+0000
Waiting for vol-9d9422f6 to detach
VOLUME vol-9d9422f6
Volume vol-9d9422f6 deleted at Mon May 23 11:05:56 MDT 2011
ATTACHMENT vol-6595230e i-6fc30f01 /dev/sdl3 detaching 2011-05-23T16:15:08+0000
Waiting for vol-6595230e to detach
VOLUME vol-6595230e
Volume vol-6595230e deleted at Mon May 23 11:06:10 MDT 2011
ATTACHMENT vol-7d952316 i-6fc30f01 /dev/sdl4 detaching 2011-05-23T16:15:08+0000
Waiting for vol-7d952316 to detach
VOLUME vol-7d952316
Volume vol-7d952316 deleted at Mon May 23 11:06:22 MDT 2011
real 12m38.753s
user 18m46.140s
sys 0m38.000s

, , , , , , ,

1 Comment

My EC2 EBS RAID-0 creation script

I want to write up a full howto/tutorial, but have not had the time.

Here is the script that I referred to in my post at http://jonzobrist.com/2011/04/16/ec2-raid0-on-linux-with-ebs-volumes-notes/

This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License HERE for more details.

http://jonzobrist.com/files/setup-ec2-raid-0.zip

http://jonzobrist.com/files/setup-ec2-raid-0.sh.gz

This script needs an AWS command line setup, and may need some minor tweaking if you’re not running a Ubuntu server.

Ubuntu’s latest AMI’s are available for 10.04 here.

Please feel free to submit patches, comments, or questions.

Thanks to everyone whose helpful posts online and in the AWS forums helped me with this script. I could not have done it with out your generous sharing of work.

Enjoy!

 

, , , , , , , , , , ,

No Comments

Getting started with Chef.

I write a lot of scripts, configure a lot of systems, and do a lot of snapshot related backup/restore/sync stuff on servers in house, and in the cloud.
Chef is a Ruby-based configuration management engine. There is a good intro here.

I set up a Chef Server. There’s a good overview here.

I followed the instructions to setup a Chef server from this Wiki on Opscode.

I also referred to the information from Grig Gheorghiu’s blog here.

Now that my server is up, I’m hoping to port my server configurations to Chef, with heavy reliance on EC2 and hopefully UEC.

, , , , , ,

4 Comments

LCOD – 7.24.10 – Get su to respect /etc/security/limits.conf

, , ,

1 Comment

LCOD – 4.12.10 – Quick Mysqlreport to e-mail setup

This will be a quick install to setup your server to e-mail you daily mysql reports using the cool mysqlreport application at hackmysql.com

Click to continue reading “LCOD – 4.12.10 – Quick Mysqlreport to e-mail setup”

, , , , , , , ,

No Comments

LCOD – 6.18.09 Useful command line grepping (grep!)

There are a few regular expressions I find myself using all the time via grep on the command line. Here are a few, along with a few frequently used commands I can’t live without.

Find the non comment parts of a file.
(Useful if you want to see or compare the active parts of a config file.)
Most Unix config files use # as a comment tag, indicating everything after the # is a comment.
grep ‘^[^#]‘ filename.conf

To break this down, first we have grep , which is a command line program to find lines that match a regular expression pattern, and display them. The single quotes indicate that we’re passing the entire section enclosed in single quotes as the first argument, which doesn’t matter as much in this example, but it’s good to practice, so when you have a space or some other character, you won’t be confused when your shell interprits it. The regular expression used is
^[^#]
Which is slightly trick, as far as regular expressions go, for only one reason; the character ^ is used twice, with different meanings.
Normally the ^ is regular expression for the start of a line, and we use it here as this, the first time. The second time, inside the brackets, it means NOT.
Brackets in regular expressions are like a giant OR statement, with every non-escape character (like the forward slash / ) as a possible match. This can hang people up when they expect [bob] to match the full word bob, instead of just the first b.
Then we have the #, which just matches our comment character, #.
Then the closing bracket, since we’re not doing any other options.
The net result of this is to match any line that has a # right after the start of the line.

To do the same thing on a config file that uses a ; as a comment indicator:
grep ‘^[;]‘ filename.conf

OR, to be even trickier, you could just add the # and ; in the same set of brackets, like
grep ‘^[;#] fliename.conf

Note the order of items inside the bracket doesn’t really matter in this case.

Next, often times I have a file with a bunch of empty lines in it, and I want to quickly get rid of them all. To do this I use a combination of a simple grep and a output redirect.

grep . filename
The . character is a regular expression match for any character, but it won’t match empty lines (the regular expression ^$ does though).
To get this into the file, first redirect it to a new file, then move the file back.
grep . filename > newfile
mv newfile filename

or, if you want to sort, just run
sort newfile > filename

perhaps you now want to just get the unique lines
uniq newfile > filename

Of course, I should mention the very obvious ones.
Grepping for words in files.

grep Word filename

Note that grep is case sensitive, but you can turn that off with the -i flag.

grep -i word filename

There is an infinite amount of uses for grep, but the foundation for grep/sed/awk/perl use for patterns is regular expressions. More than any single book I’ve read about techonlogy, the O’Reilly book “Mastering Regular Expressions”, by Jeffrey Friedl has helped me the most in my IT career. I highly suggest you buy and read it.

, , , ,

No Comments

LCOD 2.23.09 Setup Polycom Soundstation 6000 w/Asterisk

Setup/install notes, Polycom Soundstation IP 6000 with Asterisk 1.4

Have tftp setup, in this we use /tftpboot as the main tftp folder, and it’s world readable/writable, (LIMIT ACCESS VIA IPTABLES/FIREWALL/SOMETHING)
Have a dhcp server setup that’s giving out the normal things for SIP phones,
option tftp-server-name “[ASTERISK-SERVER-IP";
option time-offset -23400; # Mountain Standard Time
option ntp-servers 10.0.2.1;

Have asterisk up and running, make a SIP extension/entry like you would for a normal SIP client, although don't use type=friend, use type=peer
like this for extension 101, username 101, password temp
[101]
type=peer
username=101
secret=temp
host=dynamic
context=[your default context for phones]
qualify=150
accountcode=[optional accounting code]
mailbox=[extension for mailbox]

reload asterisk’s sip module
asterisk -vvvngrd
asterisk*>CLI>sip reload

Setup the Polycom:
download the latest rpm for firmware for trixbox from

http://yum.trixbox.org/centos/5/RPMS/

this time it was:

http://yum.trixbox.org/centos/5/RPMS/firmware-polycom-3.0.1-2.noarch.rpm

unzip this, put the tftpboot files into your tftpboot dir, put the setup-polycom.rpm_tmp_update in
/usr/local/sbin/setup-polycom.rpm_tmp_update

check which NIC your asterisk interface system is on and run
/usr/local/sbin/setup-polycom.rpm_tmp_update

(my ntp server doesn’t like our SIP clients sntp requests, so I use time.nist.gov and nat that outbound for the phones)
edit /tftpboot/server.cfg
change
tcpIpApp.sntp.address=”192.43.244.18″

Now download the latest version of the sip firwmare from polycom

http://downloads.polycom.com/voice/voip/sp_ss_sip/spip_ssip_3_1_2_release_sig_combined.zip

unzip and put all the files in /tftpboot/

edit /tftpboot/000000000000.cfg
add server.cfg on the CONFIG_FILES line, so mine looks like this

note there were 2 other application lines but i left them the same as they looked like they were for SPIP300/500′s

now, per conference phone, copy the /tftpboot/000000000000.cfg to /tftpboot/[phone mac address].cfg
the mac address is also the serial number of the phone (on the back!)
I’m not sure if it’s case sensitive but I did all lower case and it worked, tail your tftp servers logs to see what’s getting requested.

edit the /tftpboot/[phone mac address].cfg
on the line where you added server.cfg, add a custom config for this device, calling it whatever you want, so if you wanted, call it conference1.cfg, your application line would look like:

now edit that file /tftpboot/conference1.cfg (or whatever you called it)
username and password should match what you put in asterisk’s sip.conf
it should look something like this

< ?xml version="1.0" encoding="UTF-8" standalone="yes"?>


reg.1.address="101"
reg.1.label="101"
reg.1.auth.userId="101"
reg.1.auth.password="password"
reg.1.lineKeys="6"
/>

I mostly followed the directions from here (I am using a self compiled asterisk, version 1.4.19.1 on Gentoo Linux, not trixbox)

http://www.sureteq.com/asterisk/polycom.htm

and used the following links for reference:

http://www.voip-info.org/wiki/view/polycom+trixbox

http://www.voip-info.org/wiki/view/Polycom+Phones

http://www.polycom.com/support/voice/soundstation_ip_series/soundstation_ip6000.html

http://blog.voipsupply.com/new-products/polycom-sip-firmware-31-released-whats-in-it-for-me

http://blog.voipsupply.com/voip-software/unleash-your-polycom-soundpoint-ip-phone%e2%80%a6introducing-the-polycom-productivity-suite-package

http://yum.trixbox.org/centos/5/RPMS/repodata/repoview/firmware-polycom-0-3.0.1-2.html

http://www.voip-info.org/wiki/view/Asterisk%40Home+Handbook+Wiki+Chapter+7#7224HowtouseProvisioningCentralBootServe

http://www.asteriskvoipnews.com/polycom/polycom_releases_soundstation_ip_7000_and_ip_6000_conference_phone.html

, , ,

No Comments

Easy AdSense by Unreal