Posts

ipcalc where have you been hiding

Somehow I've lived this long and never stumbled upon ipcalc.  It made scripting a secondary interface and route file very easy. I wanted to be able to dynamically configure /etc/sysconfig/network-scripts/route-eth1 during boot.  I was working on my own convoluted sed script to get the right values, but ipcalc was already there and simplified my work. Normally, I'd put something like: ADDRESS0=6.6.1.0 NETMASK0=255.255.255.0 GATEWAY0=6.6.1.1 But in Amazon, some of these values can vary and for puppet to be able to distribute to any of my environments across my AZs: VPC_CIDR_URI="http://169.254.169.254/latest/meta-data/network/interfaces/macs/${ETH0_MAC}/vpc-ipv4-cidr-block" SUBNET_CIDR_URI="http://169.254.169.254/latest/meta-data/network/interfaces/macs/${ETH1_MAC}/subnet-ipv4-cidr-block" ADDRESS0=`ipcalc -n ${VPC_CIDR_RANGE} | sed -e's/^NETWORK/ADDRESS0/'` NETMASK0=`ipcalc -m ${VPC_CIDR_RANGE} | sed -e's/^NETMASK/NETMASK0/'` GAT...

Getting tab copy and paste right with rxvt-unicode option

I  have always liked xterm, but moved to rxvt years ago for a couple of its features.  Recently I moved to urxvt256c for all my terminal needs. When I use the AWS cli tools, which output tabs as whitespace, my double click selection has started including the tabs.  Maybe it has done this for a while, I don't know exactly when it started, but it is annoying since a double click selection which grabs a tab can screw up a command line paste if there is 1 file in the directory. So you get: ssh $(i2ip thisisthe1localfile.txt i-1234567) instead of ssh $(i2ip i-1234567) thanks to bash's autocomplete. After some googling I found what I should have found originally: https://github.com/jhelwig/rxvt-unicode-ppa/blob/master/doc/rxvt.1.pod -ptab|+ptab If enabled (default), "Horizontal Tab" characters are being stored as actual wide characters in the screen buffer, which makes it possible to select and paste them. Since a horizontal tab is a cursor movement and not an ...

Bash functions to simply finding instance IPs when using AWS CLI

We have both EC2 and VPC nodes. Sometimes it is convenient to run bash commands without having to copy and paste the values from the WebUI. Here are a couple of bash functions to do that: function i2ip () {   local NAME="$1"   local IP   for IP in `ec2-describe-instances --filter instance-state-name=running --filter instance-id=${NAME:?MISSING_VALUE} | grep ^INSTANCE | awk '{ if ( $4 ~ /^ec2/ ) print $4; else print $12; }'` ; do   echo ${IP}   done } function n2ip () {   local NAME="$1"   local IP   for IP in `ec2-describe-instances --filter instance-state-name=running --filter tag:Name=${NAME:?MISSING_VALUE} | grep ^INSTANCE | awk '{ if ( $4 ~ /^ec2/ ) print $4; else print $12; }'` ; do   echo ${IP}   done } you might do something like this: rsync -av --progress logstash $(n2ip rpmbuild-node):/tmp/. where "rpmbuild-node" was the value of a tag "Name" on the instance. I decided to return all of the values so I could handle t...

YAML Syntax Highlighting in gedit

Reference URLS: http://blog.dentcat.com/2009/09/highlighting-yaml-in-gedit_02.html http://codesauce.com/posts/gedit3-yaml-syntax-highlighting/ http://superuser.com/questions/353391/custom-gedit-syntax-highlighting-for-dummies sudo yum install subversion cd /tmp && svn checkout http://masood.googlecode.com/svn/trunk/yaml-language-spec/ cd yaml-language-spec/ sudo cp yaml.lang /usr/share/gtksourceview-3.0/language-specs/ sudo chmod 644 /usr/share/gtksourceview-3.0/language-specs/yaml.lang

The importance of /var/lock/subsys

I was experimenting with shutdown scripts today when I discovered the importance of the /var/lock/subsys  directory. I didn't realize that there was code in /etc/rc that checked for the existence of a lock file before trying to stop a service.  I guess I never had need to really look at this before.  I banged my head repeated only why the K* scripts I had created weren't working.  Until I finally looked at /etc/rc and realized it was only executing K* scripts for services that had touch /var/lock/subsys/<SERVICENAME>. Duh, should have looked there first.

Fedora 17 on Dell 530s

yum -y update (umask 022; sudo http_proxy=http://proxy:3128 ftp_proxy=http://proxy:3128 yum install yum-plugin-fastestmirror yum-plugin-{downloadonly,keys,priorities,remove-with-leaves,show-leaves,verify} nedit rxvt-unicode-256color xscreensaver\* xorg\*font\*Type1 xorg\*font\*misc screen dump rxvt rxvt-unicode-256color) yum groupinstall LXDE yum install kernel-devel gcc bison vi /etc/yum.repos.d/google-chrome.repo [google-chrome] name=google-chrome baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64 enabled=1 gpgcheck=1 gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub chmod 644  /etc/yum.repos.d/google-chrome.repo chown root:root  /etc/yum.repos.d/google-chrome.repo yum install google-chrome-stable sudoedit /etc/default/grub # s/rhgb quiet/verbose/ sudo grub2-mkconfig -o /boot/grub2/grub.cfg (umask 022; sudo yum -y groupinstall "Development Tools" "Development Libraries") Installing virtualbox curl http://d...

Fixing microsoft encoding weirdness

Common problem:  Team members use Microsoft for editing.  Microsoft editors do weird things to text files (no eol, etc)  Need to fix in a perforce project but don't want to have to do a lot of manual work. First, create a script file to give perforce for the editor command: > cat urxvt-perforce #!/bin/bash urxvt -geometry 240x80 -e vim $* Next, update perforce, then add the problem files to a change list (make sure that you don't include binary files in the list).  Open the files using the script. Once in vim, use the doargs command to make life nice (reference:  http://vim.wikia.com/wiki/File_format#cite_note-4 ): :argdo set ff=unix|update :argdo set ff=unix|w diff against have revision and IFF good, submit.